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

Unified Diff: Source/bindings/core/v8/custom/V8MessageEventCustom.cpp

Issue 1184603002: bindings: Use hidden value instead of ForceSet() in V8MessageEventCustom (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/custom/V8MessageEventCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp b/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp
index d36fe3bb0376c82aa8475ae03487083896e02a21..e5d5d1072aac04d0bc628fa66a88dee69f2011f9 100644
--- a/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp
+++ b/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp
@@ -45,6 +45,12 @@ namespace blink {
void V8MessageEvent::dataAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
+ v8::Local<v8::Value> cachedData = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate()));
+ if (!cachedData.IsEmpty()) {
+ v8SetReturnValue(info, cachedData);
+ return;
+ }
+
MessageEvent* event = V8MessageEvent::toImpl(info.Holder());
v8::Local<v8::Value> result;
@@ -84,16 +90,9 @@ void V8MessageEvent::dataAttributeGetterCustom(const v8::PropertyCallbackInfo<v8
break;
}
- // Overwrite the data attribute so it returns the cached result in future invocations.
- // This custom getter handler will not be called again.
- // TODO(bashi): We use ForceSet() here, and we use hidden values in other
- // places (e.g. V8CustomEventCustom.cpp). We should use the same way to
- // handle "any" attributes.
- v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly);
- if (!v8CallBoolean(info.Holder()->ForceSet(info.GetIsolate()->GetCurrentContext(), v8AtomicString(info.GetIsolate(), "data"), result, dataAttr))) {
- v8SetReturnValue(info, v8::Null(info.GetIsolate()));
- return;
- }
+ // Store the result as a hidden value so this callback returns the cached
+ // result in future invocations.
+ V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate()), result);
v8SetReturnValue(info, result);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698