From 309887c444947790b1efee8b2115f0537ce60a03 Mon Sep 17 00:00:00 2001 From: Robo Date: Thu, 24 Mar 2016 01:27:17 +0530 Subject: [PATCH] use v8::private symbols as identifiers for object properties --- native_mate/dictionary.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/native_mate/dictionary.h b/native_mate/dictionary.h index e636ca5d2f57..38927c85374f 100644 --- a/native_mate/dictionary.h +++ b/native_mate/dictionary.h @@ -56,9 +56,16 @@ class Dictionary { template bool GetHidden(const base::StringPiece& key, T* out) const { - v8::Local val = - GetHandle()->GetHiddenValue(StringToV8(isolate_, key)); - return ConvertFromV8(isolate_, val, out); + v8::Local context = isolate_->GetCurrentContext(); + v8::Local privateKey = + v8::Private::ForApi(isolate_, StringToV8(isolate_, key)); + v8::Local value; + v8::Maybe result = + GetHandle()->HasPrivate(context, privateKey); + if (internal::IsTrue(result) && + GetHandle()->GetPrivate(context, privateKey).ToLocal(&value)) + return ConvertFromV8(isolate_, value, out); + return false; } template @@ -78,7 +85,12 @@ class Dictionary { v8::Local v8_value; if (!TryConvertToV8(isolate_, val, &v8_value)) return false; - return GetHandle()->SetHiddenValue(StringToV8(isolate_, key), v8_value); + v8::Local context = isolate_->GetCurrentContext(); + v8::Local privateKey = + v8::Private::ForApi(isolate_, StringToV8(isolate_, key)); + v8::Maybe result = + GetHandle()->SetPrivate(context, privateKey, v8_value); + return !result.IsNothing() && result.FromJust(); } template