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

Unified Diff: extensions/renderer/utils_native_handler.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/set_icon_natives.cc ('k') | extensions/renderer/v8_context_native_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/utils_native_handler.cc
diff --git a/extensions/renderer/utils_native_handler.cc b/extensions/renderer/utils_native_handler.cc
index 209069cb942d3fd74b96a63c0351b3835d5087d7..1ce01d7c3654dd02a4fb0c796e73cd809ab55292 100644
--- a/extensions/renderer/utils_native_handler.cc
+++ b/extensions/renderer/utils_native_handler.cc
@@ -6,6 +6,7 @@
#include "base/strings/stringprintf.h"
#include "extensions/renderer/script_context.h"
+#include "extensions/renderer/v8_maybe_helpers.h"
#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
#include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
@@ -35,7 +36,7 @@ void UtilsNativeHandler::CreateClassWrapper(
v8::HandleScope handle_scope(GetIsolate());
// TODO(fsamuel): Consider moving the source wrapping to ModuleSystem.
- v8::Local<v8::String> source = v8::String::NewFromUtf8(
+ v8::Local<v8::String> source = ToV8String(
GetIsolate(),
base::StringPrintf(
"(function($Object, $Function, privates, cls, superclass) {"
@@ -53,26 +54,31 @@ void UtilsNativeHandler::CreateClassWrapper(
"})",
name.c_str(), name.c_str(), name.c_str()).c_str());
v8::Local<v8::Value> func_as_value = context()->module_system()->RunString(
- source, v8::String::NewFromUtf8(GetIsolate(), name.c_str()));
+ source, ToV8String(GetIsolate(), name.c_str()));
if (func_as_value.IsEmpty() || func_as_value->IsUndefined()) {
args.GetReturnValue().SetUndefined();
return;
}
// TODO(fsamuel): Move privates from ModuleSystem to a shared location.
- v8::Local<v8::Object> natives(context()->module_system()->NewInstance());
- CHECK(!natives.IsEmpty()); // this can happen if v8 has issues
+ v8::Local<v8::Object> natives;
+ if (!context()->module_system()->NewInstance().ToLocal(&natives))
+ NOTREACHED(); // this can happen if v8 has issues
v8::Local<v8::Function> func = func_as_value.As<v8::Function>();
+ v8::Local<v8::Context> v8_context = context()->v8_context();
+ v8::Local<v8::Value> privates = UnsafeGet(
+ v8_context, natives,
+ ToV8String(GetIsolate(), "privates", v8::NewStringType::kInternalized));
+
v8::Local<v8::Value> func_args[] = {
context()->safe_builtins()->GetObjekt(),
context()->safe_builtins()->GetFunction(),
- natives->Get(v8::String::NewFromUtf8(GetIsolate(), "privates",
- v8::String::kInternalizedString)),
+ privates,
cls,
superclass};
v8::Local<v8::Value> result;
{
- v8::TryCatch try_catch;
+ v8::TryCatch try_catch(GetIsolate());
try_catch.SetCaptureMessage(true);
result = context()->CallFunction(func, arraysize(func_args), func_args);
if (try_catch.HasCaught()) {
« no previous file with comments | « extensions/renderer/set_icon_natives.cc ('k') | extensions/renderer/v8_context_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698