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

Unified Diff: extensions/renderer/console.cc

Issue 1167423002: Use V8 Maybe APIs in extensions/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 | « extensions/renderer/blob_native_handler.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/console.cc
diff --git a/extensions/renderer/console.cc b/extensions/renderer/console.cc
index 172c5915bd06430c3a63d8684f6beb2d98ada31d..110288e999293b0095e6ad967b692e105d6f9ded 100644
--- a/extensions/renderer/console.cc
+++ b/extensions/renderer/console.cc
@@ -14,6 +14,7 @@
#include "content/public/renderer/render_view_visitor.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/extension_helper.h"
+#include "extensions/renderer/v8_maybe_helpers.h"
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
@@ -82,12 +83,17 @@ void BindLogMethod(v8::Isolate* isolate,
v8::Local<v8::Object> target,
const std::string& name,
LogMethod log_method) {
+ CHECK(name.size() < v8::String::kMaxLength);
v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(
isolate,
&BoundLogMethodCallback,
v8::External::New(isolate, reinterpret_cast<void*>(log_method)));
- target->Set(v8::String::NewFromUtf8(isolate, name.c_str()),
- tmpl->GetFunction());
+ v8::Local<v8::String> property = ToV8String(isolate, name.c_str());
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Function> function;
+ if (!tmpl->GetFunction(context).ToLocal(&function))
+ NOTREACHED();
+ SetProperty(context, target, property, function);
}
} // namespace
« no previous file with comments | « extensions/renderer/blob_native_handler.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698