summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-16 21:35:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-16 21:35:06 +0000
commit98b356a36bc9291a4f222d092afeeea0d5b5f379 (patch)
tree71fbda3964df30ef354afd36e3a9aba32978f762 /testing
parent31781107f6bda92e732fed805f62e8512bc78149 (diff)
downloadpdfium-98b356a36bc9291a4f222d092afeeea0d5b5f379.tar.xz
Use UnownedPtr<> to v8::Isolates.
Isolates are long-lived, but this may catch a few things. Introduce CFX_V8IsolateDeleter for unique_ptr<v8::Isolate> usage. Fix Dispose()/SetIsolate(nullptr) ordering in cjs_runtime.cpp Remove one unused isolate member. Flip protected -> private in one place. Change-Id: I26cdd120f799192e93b0d9d04dcde8f348dc21f3 Reviewed-on: https://pdfium-review.googlesource.com/37931 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/js_embedder_test.cpp19
-rw-r--r--testing/js_embedder_test.h7
2 files changed, 11 insertions, 15 deletions
diff --git a/testing/js_embedder_test.cpp b/testing/js_embedder_test.cpp
index 1ca957b44f..9821a21166 100644
--- a/testing/js_embedder_test.cpp
+++ b/testing/js_embedder_test.cpp
@@ -15,15 +15,15 @@ JSEmbedderTest::~JSEmbedderTest() {}
void JSEmbedderTest::SetUp() {
v8::Isolate::CreateParams params;
params.array_buffer_allocator = m_pArrayBufferAllocator.get();
- m_pIsolate = v8::Isolate::New(params);
+ m_pIsolate.reset(v8::Isolate::New(params));
- EmbedderTest::SetExternalIsolate(m_pIsolate);
+ EmbedderTest::SetExternalIsolate(isolate());
EmbedderTest::SetUp();
- v8::Isolate::Scope isolate_scope(m_pIsolate);
- v8::HandleScope handle_scope(m_pIsolate);
- FXJS_PerIsolateData::SetUp(m_pIsolate);
- m_Engine = pdfium::MakeUnique<CFXJS_Engine>(m_pIsolate);
+ v8::Isolate::Scope isolate_scope(isolate());
+ v8::HandleScope handle_scope(isolate());
+ FXJS_PerIsolateData::SetUp(isolate());
+ m_Engine = pdfium::MakeUnique<CFXJS_Engine>(isolate());
m_Engine->InitializeEngine();
}
@@ -31,12 +31,7 @@ void JSEmbedderTest::TearDown() {
m_Engine->ReleaseEngine();
m_Engine.reset();
EmbedderTest::TearDown();
- m_pIsolate->Dispose();
- m_pIsolate = nullptr;
-}
-
-v8::Isolate* JSEmbedderTest::isolate() {
- return m_pIsolate;
+ m_pIsolate.reset();
}
v8::Local<v8::Context> JSEmbedderTest::GetV8Context() {
diff --git a/testing/js_embedder_test.h b/testing/js_embedder_test.h
index 44245e3024..089670e25b 100644
--- a/testing/js_embedder_test.h
+++ b/testing/js_embedder_test.h
@@ -7,6 +7,7 @@
#include <memory>
+#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/cfxjs_engine.h"
#include "testing/embedder_test.h"
@@ -18,13 +19,13 @@ class JSEmbedderTest : public EmbedderTest {
void SetUp() override;
void TearDown() override;
- v8::Isolate* isolate();
+ v8::Isolate* isolate() const { return m_pIsolate.get(); }
+ CFXJS_Engine* engine() const { return m_Engine.get(); }
v8::Local<v8::Context> GetV8Context();
- CFXJS_Engine* engine() { return m_Engine.get(); }
private:
std::unique_ptr<CFX_V8ArrayBufferAllocator> m_pArrayBufferAllocator;
- v8::Isolate* m_pIsolate = nullptr;
+ std::unique_ptr<v8::Isolate, CFX_V8IsolateDeleter> m_pIsolate;
std::unique_ptr<CFXJS_Engine> m_Engine;
};