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

Side by Side Diff: extensions/renderer/safe_builtins.cc

Issue 1743763004: Use v8::MicrotasksScope internally in V8RecursionScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8rs-2-endofscope
Patch Set: v8_helpers Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | extensions/renderer/v8_helpers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/renderer/safe_builtins.h" 5 #include "extensions/renderer/safe_builtins.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "extensions/renderer/script_context.h" 10 #include "extensions/renderer/script_context.h"
11 #include "extensions/renderer/v8_helpers.h" 11 #include "extensions/renderer/v8_helpers.h"
12 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
15 using namespace v8_helpers; 16 using namespace v8_helpers;
16 17
17 namespace { 18 namespace {
18 19
19 const char kClassName[] = "extensions::SafeBuiltins"; 20 const char kClassName[] = "extensions::SafeBuiltins";
20 21
21 // Documentation for makeCallback in the JavaScript, out here to reduce the 22 // Documentation for makeCallback in the JavaScript, out here to reduce the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); 194 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
194 int argc = args_length - first_arg_index; 195 int argc = args_length - first_arg_index;
195 scoped_ptr<v8::Local<v8::Value> []> argv(new v8::Local<v8::Value>[argc]); 196 scoped_ptr<v8::Local<v8::Value> []> argv(new v8::Local<v8::Value>[argc]);
196 for (int i = 0; i < argc; ++i) { 197 for (int i = 0; i < argc; ++i) {
197 CHECK(IsTrue(args->Has(context, i + first_arg_index))); 198 CHECK(IsTrue(args->Has(context, i + first_arg_index)));
198 // Getting a property value could throw an exception. 199 // Getting a property value could throw an exception.
199 if (!GetProperty(context, args, i + first_arg_index, &argv[i])) 200 if (!GetProperty(context, args, i + first_arg_index, &argv[i]))
200 return; 201 return;
201 } 202 }
202 203
204 blink::WebScopedMicrotaskSuppression microtasks_scope;
203 v8::Local<v8::Value> return_value; 205 v8::Local<v8::Value> return_value;
204 if (function->Call(context, recv, argc, argv.get()).ToLocal(&return_value)) 206 if (function->Call(context, recv, argc, argv.get()).ToLocal(&return_value))
205 info.GetReturnValue().Set(return_value); 207 info.GetReturnValue().Set(return_value);
206 } 208 }
207 209
208 static void Save(const v8::FunctionCallbackInfo<v8::Value>& info) { 210 static void Save(const v8::FunctionCallbackInfo<v8::Value>& info) {
209 CHECK(info.Length() == 2 && info[0]->IsString() && info[1]->IsObject()); 211 CHECK(info.Length() == 2 && info[0]->IsString() && info[1]->IsObject());
210 SaveImpl(*v8::String::Utf8Value(info[0]), 212 SaveImpl(*v8::String::Utf8Value(info[0]),
211 info[1], 213 info[1],
212 info.GetIsolate()->GetCurrentContext()); 214 info.GetIsolate()->GetCurrentContext());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 246
245 v8::Local<v8::Object> SafeBuiltins::GetString() const { 247 v8::Local<v8::Object> SafeBuiltins::GetString() const {
246 return Load("String", context_->v8_context()); 248 return Load("String", context_->v8_context());
247 } 249 }
248 250
249 v8::Local<v8::Object> SafeBuiltins::GetError() const { 251 v8::Local<v8::Object> SafeBuiltins::GetError() const {
250 return Load("Error", context_->v8_context()); 252 return Load("Error", context_->v8_context());
251 } 253 }
252 254
253 } // namespace extensions 255 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | extensions/renderer/v8_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698