diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-02-08 20:16:09 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-08 20:16:09 +0000 |
commit | b3f1046cb2c9bb7fc2a2579b76c8e65b24323002 (patch) | |
tree | c687a105ebece091f5a2386f88855c163ba7e6cc /fxjs/fxjs_v8.h | |
parent | f0e386de64e030f6d692acfa27e2bc0a50018710 (diff) | |
download | pdfium-b3f1046cb2c9bb7fc2a2579b76c8e65b24323002.tar.xz |
Make CFXJS_Engine::SetObjectPrivate() static.
Avoids call to CFXJS_Engine::EngineFromIsolateCurrentContext() during
the Dispose() path, which feels scary because there aren't guarantees
about it having an engine at isolate "dispose" time. Fortunately, |this|
is not used, so make that fact clear.
Replace some c-style callbacks with std::function while we're at it.
Change-Id: Ia1a1a1fcc085d8657939e6f8c8d34fc511afddfe
Reviewed-on: https://pdfium-review.googlesource.com/25970
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/fxjs_v8.h')
-rw-r--r-- | fxjs/fxjs_v8.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fxjs/fxjs_v8.h b/fxjs/fxjs_v8.h index 0592847bb2..2c53b65d3a 100644 --- a/fxjs/fxjs_v8.h +++ b/fxjs/fxjs_v8.h @@ -14,6 +14,7 @@ #ifndef FXJS_FXJS_V8_H_ #define FXJS_FXJS_V8_H_ +#include <functional> #include <map> #include <memory> #include <vector> @@ -131,17 +132,21 @@ class CFXJS_Engine : public CJS_V8 { explicit CFXJS_Engine(v8::Isolate* pIsolate); ~CFXJS_Engine() override; - using Constructor = void (*)(CFXJS_Engine* pEngine, - v8::Local<v8::Object> obj); - using Destructor = void (*)(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + using Constructor = + std::function<void(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj)>; + using Destructor = std::function<void(v8::Local<v8::Object> obj)>; static CFXJS_Engine* EngineFromIsolateCurrentContext(v8::Isolate* pIsolate); static CFXJS_Engine* EngineFromContext(v8::Local<v8::Context> pContext); - static void SetEngineInContext(CFXJS_Engine* pEngine, - v8::Local<v8::Context> pContext); static int GetObjDefnID(v8::Local<v8::Object> pObj); + static void SetObjectPrivate(v8::Local<v8::Object> pObj, + std::unique_ptr<CJS_Object> p); + static void FreeObjectPrivate(v8::Local<v8::Object> pObj); + + void SetIntoContext(v8::Local<v8::Context> pContext); + // Always returns a valid, newly-created objDefnID. int DefineObj(const char* sObjName, FXJSOBJTYPE eObjType, @@ -178,12 +183,8 @@ class CFXJS_Engine : public CJS_V8 { v8::Local<v8::Object> GetThisObj(); v8::Local<v8::Object> NewFXJSBoundObject(int nObjDefnID, bool bStatic = false); - - // Native object binding. - void SetObjectPrivate(v8::Local<v8::Object> pObj, - std::unique_ptr<CJS_Object> p); + // Retrieve native object binding. CJS_Object* GetObjectPrivate(v8::Local<v8::Object> pObj); - static void FreeObjectPrivate(v8::Local<v8::Object> pObj); void Error(const WideString& message); |