summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/v8_helpers.h
diff options
context:
space:
mode:
authorbashi <bashi@chromium.org>2015-06-25 17:40:10 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-26 00:40:39 +0000
commit61ca3c7b545104ac3edda633a80a62808d281b23 (patch)
treee1b85899059fe615e7b5ddc2da065599c8f318e4 /extensions/renderer/v8_helpers.h
parentbc058b83eb43ae22d50cfe864ef17b0f6693cce1 (diff)
downloadchromium_src-61ca3c7b545104ac3edda633a80a62808d281b23.zip
chromium_src-61ca3c7b545104ac3edda633a80a62808d281b23.tar.gz
chromium_src-61ca3c7b545104ac3edda633a80a62808d281b23.tar.bz2
extensions: Use V8 Maybe APIs in NativeHandler
Also make NativeHandler::NewInstance() return MaybeLocal<Object> because it can fail while running V8 APIs. BUG=479065 Review URL: https://codereview.chromium.org/1192763002 Cr-Commit-Position: refs/heads/master@{#336302}
Diffstat (limited to 'extensions/renderer/v8_helpers.h')
-rw-r--r--extensions/renderer/v8_helpers.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/extensions/renderer/v8_helpers.h b/extensions/renderer/v8_helpers.h
index 385490f..77e2eb8 100644
--- a/extensions/renderer/v8_helpers.h
+++ b/extensions/renderer/v8_helpers.h
@@ -22,6 +22,12 @@ inline bool ToV8String(v8::Isolate* isolate,
.ToLocal(out);
}
+inline bool ToV8String(v8::Isolate* isolate,
+ const std::string& str,
+ v8::Local<v8::String>* out) {
+ return ToV8String(isolate, str.c_str(), out);
+}
+
// Converts |str| to a V8 string.
// This crashes when strlen(str) > v8::String::kMaxLength.
inline v8::Local<v8::String> ToV8StringUnsafe(
@@ -100,6 +106,16 @@ inline v8::Local<v8::Value> GetPropertyUnsafe(
.ToLocalChecked();
}
+// Wraps v8::Function::Call(). Returns true on success.
+inline bool CallFunction(v8::Local<v8::Context> context,
+ v8::Local<v8::Function> function,
+ v8::Local<v8::Value> recv,
+ int argc,
+ v8::Local<v8::Value> argv[],
+ v8::Local<v8::Value>* out) {
+ return function->Call(context, recv, argc, argv).ToLocal(out);
+}
+
} // namespace v8_helpers
} // namespace extensions