Chromium Code Reviews| Index: extensions/renderer/script_context.cc |
| diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc |
| index f611ddebf7112e9d6fb6b63aa5d993fb77fc4c07..051a928a7ffecb1e60e2e9f1415efc8ea7369356 100644 |
| --- a/extensions/renderer/script_context.cc |
| +++ b/extensions/renderer/script_context.cc |
| @@ -202,6 +202,23 @@ v8::Local<v8::Value> ScriptContext::CallFunction( |
| function, global, argc, argv))); |
| } |
| +void ScriptContext::SafeCallFunction( |
| + const v8::Local<v8::Function>& function, |
| + int argc, |
| + v8::Local<v8::Value> argv[]) { |
| + v8::HandleScope handle_scope(isolate()); |
| + v8::Context::Scope scope(v8_context()); |
| + v8::MicrotasksScope microtasks( |
| + isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); |
| + v8::Local<v8::Object> global = v8_context()->Global(); |
| + if (web_frame_) { |
| + web_frame_->requestExecuteV8Function(function, global, argc, argv, nullptr); |
| + } else { |
|
Devlin
2016/09/16 18:16:31
This can happen in the case of e.g. ServiceWorker
dcheng
2016/09/27 08:30:57
Handwaving a bit... maybe this is OK? I don't thin
falken
2016/09/28 00:04:14
+nhiroki, +yhirano
I probably don't understand en
yhirano
2016/09/28 05:55:03
This topic is about sync loading on a worker threa
|
| + // TODO(devlin): This probably isn't safe. |
| + function->Call(global, argc, argv); |
| + } |
| +} |
| + |
| v8::Local<v8::Value> ScriptContext::CallFunction( |
| const v8::Local<v8::Function>& function) const { |
| DCHECK(thread_checker_.CalledOnValidThread()); |