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

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

Issue 1780593002: V8 Bindings: Don't attempt to set an empty V8HiddenValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/LayoutTests/storage/indexeddb/empty-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/V8HiddenValue.h" 5 #include "bindings/core/v8/V8HiddenValue.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 10
(...skipping 19 matching lines...) Expand all
30 // Callsites interpret an empty handle has absence of a result. 30 // Callsites interpret an empty handle has absence of a result.
31 if (!v8CallBoolean(object->HasPrivate(context, privateKey))) 31 if (!v8CallBoolean(object->HasPrivate(context, privateKey)))
32 return v8::Local<v8::Value>(); 32 return v8::Local<v8::Value>();
33 if (object->GetPrivate(context, privateKey).ToLocal(&value)) 33 if (object->GetPrivate(context, privateKey).ToLocal(&value))
34 return value; 34 return value;
35 return v8::Local<v8::Value>(); 35 return v8::Local<v8::Value>();
36 } 36 }
37 37
38 bool V8HiddenValue::setHiddenValue(ScriptState* scriptState, v8::Local<v8::Objec t> object, v8::Local<v8::String> key, v8::Local<v8::Value> value) 38 bool V8HiddenValue::setHiddenValue(ScriptState* scriptState, v8::Local<v8::Objec t> object, v8::Local<v8::String> key, v8::Local<v8::Value> value)
39 { 39 {
40 if (UNLIKELY(value.IsEmpty()))
41 return false;
40 return v8CallBoolean(object->SetPrivate(scriptState->context(), v8::Private: :ForApi(scriptState->isolate(), key), value)); 42 return v8CallBoolean(object->SetPrivate(scriptState->context(), v8::Private: :ForApi(scriptState->isolate(), key), value));
41 } 43 }
42 44
43 bool V8HiddenValue::deleteHiddenValue(ScriptState* scriptState, v8::Local<v8::Ob ject> object, v8::Local<v8::String> key) 45 bool V8HiddenValue::deleteHiddenValue(ScriptState* scriptState, v8::Local<v8::Ob ject> object, v8::Local<v8::String> key)
44 { 46 {
45 // Actually deleting the value would make force the object into dictionary m ode which is unnecessarily slow. Instead, we replace the hidden value with "unde fined". 47 // Actually deleting the value would make force the object into dictionary m ode which is unnecessarily slow. Instead, we replace the hidden value with "unde fined".
46 return v8CallBoolean(object->SetPrivate(scriptState->context(), v8::Private: :ForApi(scriptState->isolate(), key), v8::Undefined(scriptState->isolate()))); 48 return v8CallBoolean(object->SetPrivate(scriptState->context(), v8::Private: :ForApi(scriptState->isolate(), key), v8::Undefined(scriptState->isolate())));
47 } 49 }
48 50
49 v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper(ScriptSta te* scriptState, ScriptWrappable* wrappable, v8::Local<v8::String> key) 51 v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper(ScriptSta te* scriptState, ScriptWrappable* wrappable, v8::Local<v8::String> key)
50 { 52 {
51 v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(scriptState->isol ate()); 53 v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(scriptState->isol ate());
52 return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(scriptSta te, wrapper, key); 54 return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(scriptSta te, wrapper, key);
53 } 55 }
54 56
55 } // namespace blink 57 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/storage/indexeddb/empty-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698