summaryrefslogtreecommitdiff
path: root/fxjs/fxjs_v8.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-02-05 18:52:09 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-05 18:52:09 +0000
commit57e097750846bf3ffc3e4e2ef9e78be8a82c69de (patch)
tree080a0d644b816cc6d2cb0b00f4c9629020894316 /fxjs/fxjs_v8.cpp
parent13c4d1b46641fb3041800cad3032e7e60026e3f4 (diff)
downloadpdfium-57e097750846bf3ffc3e4e2ef9e78be8a82c69de.tar.xz
Use unique pointer in CFXJS_PerObjectData.
Also use the actual type information, not void* and remove casts. Template function not required to wrap virtual dtors. Change-Id: I9397cae136c3c395a368a1ef0ce8162d9b586076 Reviewed-on: https://pdfium-review.googlesource.com/25290 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/fxjs_v8.cpp')
-rw-r--r--fxjs/fxjs_v8.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index f1555b2e96..2161076e36 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -6,9 +6,12 @@
#include "fxjs/fxjs_v8.h"
+#include <memory>
+#include <utility>
#include <vector>
#include "fxjs/cfxjse_runtimedata.h"
+#include "fxjs/cjs_object.h"
#include "third_party/base/allocator/partition_allocator/partition_alloc.h"
// Keep this consistent with the values defined in gin/public/context_holder.h
@@ -25,8 +28,9 @@ static wchar_t kPerObjectDataTag[] = L"CFXJS_PerObjectData";
class CFXJS_PerObjectData {
public:
- explicit CFXJS_PerObjectData(int nObjDefID)
- : m_ObjDefID(nObjDefID), m_pPrivate(nullptr) {}
+ explicit CFXJS_PerObjectData(int nObjDefID) : m_ObjDefID(nObjDefID) {}
+
+ ~CFXJS_PerObjectData() = default;
static void SetInObject(CFXJS_PerObjectData* pData,
v8::Local<v8::Object> pObj) {
@@ -48,7 +52,7 @@ class CFXJS_PerObjectData {
}
const int m_ObjDefID;
- void* m_pPrivate;
+ std::unique_ptr<CJS_Object> m_pPrivate;
};
class CFXJS_ObjDefinition {
@@ -540,15 +544,16 @@ void CFXJS_Engine::Error(const WideString& message) {
GetIsolate()->ThrowException(NewString(message.AsStringView()));
}
-void CFXJS_Engine::SetObjectPrivate(v8::Local<v8::Object> pObj, void* p) {
+void CFXJS_Engine::SetObjectPrivate(v8::Local<v8::Object> pObj,
+ std::unique_ptr<CJS_Object> p) {
CFXJS_PerObjectData* pPerObjectData =
CFXJS_PerObjectData::GetFromObject(pObj);
if (!pPerObjectData)
return;
- pPerObjectData->m_pPrivate = p;
+ pPerObjectData->m_pPrivate = std::move(p);
}
-void* CFXJS_Engine::GetObjectPrivate(v8::Local<v8::Object> pObj) {
+CJS_Object* CFXJS_Engine::GetObjectPrivate(v8::Local<v8::Object> pObj) {
CFXJS_PerObjectData* pData = CFXJS_PerObjectData::GetFromObject(pObj);
if (!pData && !pObj.IsEmpty()) {
// It could be a global proxy object.
@@ -559,7 +564,7 @@ void* CFXJS_Engine::GetObjectPrivate(v8::Local<v8::Object> pObj) {
v->ToObject(context).ToLocalChecked());
}
}
- return pData ? pData->m_pPrivate : nullptr;
+ return pData ? pData->m_pPrivate.get() : nullptr;
}
v8::Local<v8::Array> CFXJS_Engine::GetConstArray(const WideString& name) {