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..01e0b297f751faf4df171bd2c918421b12b8962d 100644 |
| --- a/extensions/renderer/script_context.cc |
| +++ b/extensions/renderer/script_context.cc |
| @@ -202,6 +202,22 @@ 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 { |
| + // TODO(devlin): This probably isn't safe. |
|
dcheng
2016/10/04 05:58:49
Hmm, is it possible to attach devtools to a servic
Devlin
2016/10/04 19:40:05
That sounds like a question for falken. :) Regard
falken
2016/10/05 00:19:55
Yes, you can attach DevTools to service workers an
dgozman
2016/10/05 01:25:42
This should be fine as long as you execute JS via
|
| + function->Call(global, argc, argv); |
| + } |
| +} |
| + |
| v8::Local<v8::Value> ScriptContext::CallFunction( |
| const v8::Local<v8::Function>& function) const { |
| DCHECK(thread_checker_.CalledOnValidThread()); |