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

Unified Diff: extensions/renderer/object_backed_native_handler.cc

Issue 1422383003: [Extensions] Make handler_function a hidden property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test Created 5 years, 2 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 | « chrome/test/data/extensions/api_test/bindings/handler_function_type_checking.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/object_backed_native_handler.cc
diff --git a/extensions/renderer/object_backed_native_handler.cc b/extensions/renderer/object_backed_native_handler.cc
index 879da23dd7696361345cc99f100b2e212c084614..45d2dd3dcf2e543d61cb873cbdc378f0de72819f 100644
--- a/extensions/renderer/object_backed_native_handler.cc
+++ b/extensions/renderer/object_backed_native_handler.cc
@@ -41,7 +41,8 @@ void ObjectBackedNativeHandler::Router(
v8::Local<v8::Object> data = args.Data().As<v8::Object>();
v8::Local<v8::Value> handler_function_value =
- data->Get(v8::String::NewFromUtf8(args.GetIsolate(), kHandlerFunction));
+ data->GetHiddenValue(
+ v8::String::NewFromUtf8(args.GetIsolate(), kHandlerFunction));
// See comment in header file for why we do this.
if (handler_function_value.IsEmpty() ||
handler_function_value->IsUndefined()) {
@@ -51,7 +52,9 @@ void ObjectBackedNativeHandler::Router(
"Extension view no longer exists");
return;
}
- DCHECK(handler_function_value->IsExternal());
+ // This CHECK is *important*. Otherwise, we'll go around happily executing
+ // something random. See crbug.com/548273.
+ CHECK(handler_function_value->IsExternal());
static_cast<HandlerFunction*>(
handler_function_value.As<v8::External>()->Value())->Run(args);
}
@@ -64,7 +67,7 @@ void ObjectBackedNativeHandler::RouteFunction(
v8::Context::Scope context_scope(context_->v8_context());
v8::Local<v8::Object> data = v8::Object::New(isolate);
- data->Set(
+ data->SetHiddenValue(
v8::String::NewFromUtf8(isolate, kHandlerFunction),
v8::External::New(isolate, new HandlerFunction(handler_function)));
v8::Local<v8::FunctionTemplate> function_template =
@@ -86,11 +89,12 @@ void ObjectBackedNativeHandler::Invalidate() {
for (size_t i = 0; i < router_data_.Size(); i++) {
v8::Local<v8::Object> data = router_data_.Get(i);
v8::Local<v8::Value> handler_function_value =
- data->Get(v8::String::NewFromUtf8(isolate, kHandlerFunction));
+ data->GetHiddenValue(
+ v8::String::NewFromUtf8(isolate, kHandlerFunction));
CHECK(!handler_function_value.IsEmpty());
delete static_cast<HandlerFunction*>(
handler_function_value.As<v8::External>()->Value());
- data->Delete(v8::String::NewFromUtf8(isolate, kHandlerFunction));
+ data->DeleteHiddenValue(v8::String::NewFromUtf8(isolate, kHandlerFunction));
}
router_data_.Clear();
« no previous file with comments | « chrome/test/data/extensions/api_test/bindings/handler_function_type_checking.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698