diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-16 21:35:06 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-16 21:35:06 +0000 |
commit | 98b356a36bc9291a4f222d092afeeea0d5b5f379 (patch) | |
tree | 71fbda3964df30ef354afd36e3a9aba32978f762 /fxjs/cfx_v8.h | |
parent | 31781107f6bda92e732fed805f62e8512bc78149 (diff) | |
download | pdfium-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 'fxjs/cfx_v8.h')
-rw-r--r-- | fxjs/cfx_v8.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fxjs/cfx_v8.h b/fxjs/cfx_v8.h index 08a18935ea..04468d5281 100644 --- a/fxjs/cfx_v8.h +++ b/fxjs/cfx_v8.h @@ -20,7 +20,7 @@ class CFX_V8 { explicit CFX_V8(v8::Isolate* pIsolate); virtual ~CFX_V8(); - v8::Isolate* GetIsolate() const { return m_isolate; } + v8::Isolate* GetIsolate() const { return m_pIsolate.Get(); } v8::Local<v8::Value> NewNull(); v8::Local<v8::Value> NewUndefined(); @@ -59,10 +59,11 @@ class CFX_V8 { v8::Local<v8::Value> pValue); protected: - void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } + void SetIsolate(v8::Isolate* pIsolate) { m_pIsolate = pIsolate; } + void DisposeIsolate(); private: - v8::Isolate* m_isolate; + UnownedPtr<v8::Isolate> m_pIsolate; }; class CFX_V8ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { @@ -72,4 +73,9 @@ class CFX_V8ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { void Free(void* data, size_t length) override; }; +// Use with std::unique_ptr<v8::Isolate> to dispose of isolates correctly. +struct CFX_V8IsolateDeleter { + inline void operator()(v8::Isolate* ptr) { ptr->Dispose(); } +}; + #endif // FXJS_CFX_V8_H_ |