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

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

Issue 1769273004: Remove V8RecrusionScope, cleanup call sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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/safe_builtins.cc ('k') | extensions/renderer/utils_native_handler.cc » ('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/script_context.h" 5 #include "extensions/renderer/script_context.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 11 matching lines...) Expand all
22 #include "extensions/common/manifest_handlers/sandboxed_page_info.h" 22 #include "extensions/common/manifest_handlers/sandboxed_page_info.h"
23 #include "extensions/common/permissions/permissions_data.h" 23 #include "extensions/common/permissions/permissions_data.h"
24 #include "extensions/renderer/renderer_extension_registry.h" 24 #include "extensions/renderer/renderer_extension_registry.h"
25 #include "extensions/renderer/v8_helpers.h" 25 #include "extensions/renderer/v8_helpers.h"
26 #include "gin/per_context_data.h" 26 #include "gin/per_context_data.h"
27 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 27 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
28 #include "third_party/WebKit/public/web/WebDataSource.h" 28 #include "third_party/WebKit/public/web/WebDataSource.h"
29 #include "third_party/WebKit/public/web/WebDocument.h" 29 #include "third_party/WebKit/public/web/WebDocument.h"
30 #include "third_party/WebKit/public/web/WebFrame.h" 30 #include "third_party/WebKit/public/web/WebFrame.h"
31 #include "third_party/WebKit/public/web/WebLocalFrame.h" 31 #include "third_party/WebKit/public/web/WebLocalFrame.h"
32 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
33 #include "third_party/WebKit/public/web/WebView.h" 32 #include "third_party/WebKit/public/web/WebView.h"
34 #include "v8/include/v8.h" 33 #include "v8/include/v8.h"
35 34
36 using content::V8ValueConverter; 35 using content::V8ValueConverter;
37 36
38 namespace extensions { 37 namespace extensions {
39 38
40 namespace { 39 namespace {
41 40
42 std::string GetContextTypeDescriptionString(Feature::Context context_type) { 41 std::string GetContextTypeDescriptionString(Feature::Context context_type) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 177 }
179 178
180 v8::Local<v8::Value> ScriptContext::CallFunction( 179 v8::Local<v8::Value> ScriptContext::CallFunction(
181 const v8::Local<v8::Function>& function, 180 const v8::Local<v8::Function>& function,
182 int argc, 181 int argc,
183 v8::Local<v8::Value> argv[]) const { 182 v8::Local<v8::Value> argv[]) const {
184 DCHECK(thread_checker_.CalledOnValidThread()); 183 DCHECK(thread_checker_.CalledOnValidThread());
185 v8::EscapableHandleScope handle_scope(isolate()); 184 v8::EscapableHandleScope handle_scope(isolate());
186 v8::Context::Scope scope(v8_context()); 185 v8::Context::Scope scope(v8_context());
187 186
188 blink::WebScopedMicrotaskSuppression suppression; 187 v8::MicrotasksScope microtasks(
188 isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
189 if (!is_valid_) { 189 if (!is_valid_) {
190 return handle_scope.Escape( 190 return handle_scope.Escape(
191 v8::Local<v8::Primitive>(v8::Undefined(isolate()))); 191 v8::Local<v8::Primitive>(v8::Undefined(isolate())));
192 } 192 }
193 193
194 v8::Local<v8::Object> global = v8_context()->Global(); 194 v8::Local<v8::Object> global = v8_context()->Global();
195 if (!web_frame_) 195 if (!web_frame_)
196 return handle_scope.Escape(function->Call(global, argc, argv)); 196 return handle_scope.Escape(function->Call(global, argc, argv));
197 return handle_scope.Escape( 197 return handle_scope.Escape(
198 v8::Local<v8::Value>(web_frame_->callFunctionEvenIfScriptDisabled( 198 v8::Local<v8::Value>(web_frame_->callFunctionEvenIfScriptDisabled(
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // Prepend extensions:: to |name| so that internal code can be differentiated 427 // Prepend extensions:: to |name| so that internal code can be differentiated
428 // from external code in stack traces. This has no effect on behaviour. 428 // from external code in stack traces. This has no effect on behaviour.
429 std::string internal_name = 429 std::string internal_name =
430 base::StringPrintf("extensions::%s", *v8::String::Utf8Value(name)); 430 base::StringPrintf("extensions::%s", *v8::String::Utf8Value(name));
431 431
432 if (internal_name.size() >= v8::String::kMaxLength) { 432 if (internal_name.size() >= v8::String::kMaxLength) {
433 NOTREACHED() << "internal_name is too long."; 433 NOTREACHED() << "internal_name is too long.";
434 return v8::Undefined(isolate()); 434 return v8::Undefined(isolate());
435 } 435 }
436 436
437 blink::WebScopedMicrotaskSuppression suppression; 437 v8::MicrotasksScope microtasks(
438 isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
438 v8::TryCatch try_catch(isolate()); 439 v8::TryCatch try_catch(isolate());
439 try_catch.SetCaptureMessage(true); 440 try_catch.SetCaptureMessage(true);
440 v8::ScriptOrigin origin( 441 v8::ScriptOrigin origin(
441 v8_helpers::ToV8StringUnsafe(isolate(), internal_name.c_str())); 442 v8_helpers::ToV8StringUnsafe(isolate(), internal_name.c_str()));
442 v8::Local<v8::Script> script; 443 v8::Local<v8::Script> script;
443 if (!v8::Script::Compile(v8_context(), code, &origin).ToLocal(&script)) { 444 if (!v8::Script::Compile(v8_context(), code, &origin).ToLocal(&script)) {
444 exception_handler.Run(try_catch); 445 exception_handler.Run(try_catch);
445 return v8::Undefined(isolate()); 446 return v8::Undefined(isolate());
446 } 447 }
447 448
(...skipping 21 matching lines...) Expand all
469 v8::Local<v8::Value> argv[]) { 470 v8::Local<v8::Value> argv[]) {
470 return context_->CallFunction(function, argc, argv); 471 return context_->CallFunction(function, argc, argv);
471 } 472 }
472 473
473 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { 474 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() {
474 v8::HandleScope handle_scope(context_->isolate()); 475 v8::HandleScope handle_scope(context_->isolate());
475 return gin::PerContextData::From(context_->v8_context())->context_holder(); 476 return gin::PerContextData::From(context_->v8_context())->context_holder();
476 } 477 }
477 478
478 } // namespace extensions 479 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/safe_builtins.cc ('k') | extensions/renderer/utils_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698