Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.cpp

Issue 2798063003: [Bindings] Remove V8HiddenValue (Closed)
Patch Set: remove files Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "bindings/core/v8/V8HiddenValue.h"
6
7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "bindings/core/v8/V8Binding.h"
10
11 namespace blink {
12
13 v8::Local<v8::Value> V8HiddenValue::GetHiddenValue(ScriptState* script_state,
14 v8::Local<v8::Object> object,
15 v8::Local<v8::String> key) {
16 v8::Local<v8::Context> context = script_state->GetContext();
17 v8::Local<v8::Private> private_key =
18 v8::Private::ForApi(script_state->GetIsolate(), key);
19 v8::Local<v8::Value> value;
20 // Callsites interpret an empty handle has absence of a result.
21 if (!V8CallBoolean(object->HasPrivate(context, private_key)))
22 return v8::Local<v8::Value>();
23 if (object->GetPrivate(context, private_key).ToLocal(&value))
24 return value;
25 return v8::Local<v8::Value>();
26 }
27
28 bool V8HiddenValue::SetHiddenValue(ScriptState* script_state,
29 v8::Local<v8::Object> object,
30 v8::Local<v8::String> key,
31 v8::Local<v8::Value> value) {
32 if (UNLIKELY(value.IsEmpty()))
33 return false;
34 return V8CallBoolean(object->SetPrivate(
35 script_state->GetContext(),
36 v8::Private::ForApi(script_state->GetIsolate(), key), value));
37 }
38
39 bool V8HiddenValue::DeleteHiddenValue(ScriptState* script_state,
40 v8::Local<v8::Object> object,
41 v8::Local<v8::String> key) {
42 // Actually deleting the value would make force the object into dictionary
43 // mode which is unnecessarily slow. Instead, we replace the hidden value with
44 // "undefined".
45 return V8CallBoolean(
46 object->SetPrivate(script_state->GetContext(),
47 v8::Private::ForApi(script_state->GetIsolate(), key),
48 v8::Undefined(script_state->GetIsolate())));
49 }
50
51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698