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

Side by Side Diff: chrome/renderer/extensions/dispatcher.cc

Issue 23679004: Remove more calls to HandleScope default ctor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/dispatcher.h" 5 #include "chrome/renderer/extensions/dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore"); 372 module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore");
373 } 373 }
374 374
375 // Calls a method |method_name| in a module |module_name| belonging to the 375 // Calls a method |method_name| in a module |module_name| belonging to the
376 // module system from |context|. Intended as a callback target from 376 // module system from |context|. Intended as a callback target from
377 // ChromeV8ContextSet::ForEach. 377 // ChromeV8ContextSet::ForEach.
378 void CallModuleMethod(const std::string& module_name, 378 void CallModuleMethod(const std::string& module_name,
379 const std::string& method_name, 379 const std::string& method_name,
380 const base::ListValue* args, 380 const base::ListValue* args,
381 ChromeV8Context* context) { 381 ChromeV8Context* context) {
382 v8::HandleScope handle_scope; 382 v8::HandleScope handle_scope(context->isolate());
383 v8::Context::Scope context_scope(context->v8_context()); 383 v8::Context::Scope context_scope(context->v8_context());
384 384
385 scoped_ptr<content::V8ValueConverter> converter( 385 scoped_ptr<content::V8ValueConverter> converter(
386 content::V8ValueConverter::create()); 386 content::V8ValueConverter::create());
387 387
388 std::vector<v8::Handle<v8::Value> > arguments; 388 std::vector<v8::Handle<v8::Value> > arguments;
389 for (base::ListValue::const_iterator it = args->begin(); it != args->end(); 389 for (base::ListValue::const_iterator it = args->begin(); it != args->end();
390 ++it) { 390 ++it) {
391 arguments.push_back(converter->ToV8Value(*it, context->v8_context())); 391 arguments.push_back(converter->ToV8Value(*it, context->v8_context()));
392 } 392 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 CHECK(value->IsObject()); 639 CHECK(value->IsObject());
640 return v8::Handle<v8::Object>::Cast(value); 640 return v8::Handle<v8::Object>::Cast(value);
641 } 641 }
642 642
643 v8::Handle<v8::Object> new_object = v8::Object::New(); 643 v8::Handle<v8::Object> new_object = v8::Object::New();
644 object->Set(key, new_object); 644 object->Set(key, new_object);
645 return new_object; 645 return new_object;
646 } 646 }
647 647
648 void Dispatcher::AddOrRemoveBindingsForContext(ChromeV8Context* context) { 648 void Dispatcher::AddOrRemoveBindingsForContext(ChromeV8Context* context) {
649 v8::HandleScope handle_scope; 649 v8::HandleScope handle_scope(context->isolate());
650 v8::Context::Scope context_scope(context->v8_context()); 650 v8::Context::Scope context_scope(context->v8_context());
651 651
652 // TODO(kalman): Make the bindings registration have zero overhead then run 652 // TODO(kalman): Make the bindings registration have zero overhead then run
653 // the same code regardless of context type. 653 // the same code regardless of context type.
654 switch (context->context_type()) { 654 switch (context->context_type()) {
655 case Feature::UNSPECIFIED_CONTEXT: 655 case Feature::UNSPECIFIED_CONTEXT:
656 case Feature::WEB_PAGE_CONTEXT: { 656 case Feature::WEB_PAGE_CONTEXT: {
657 // Web page context; it's too expensive to run the full bindings code. 657 // Web page context; it's too expensive to run the full bindings code.
658 // Hard-code that the app and webstore APIs are available... 658 // Hard-code that the app and webstore APIs are available...
659 RegisterBinding("app", context); 659 RegisterBinding("app", context);
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 RenderView* background_view = 1562 RenderView* background_view =
1563 ExtensionHelper::GetBackgroundPage(extension_id); 1563 ExtensionHelper::GetBackgroundPage(extension_id);
1564 if (background_view) { 1564 if (background_view) {
1565 background_view->Send(new ExtensionHostMsg_EventAck( 1565 background_view->Send(new ExtensionHostMsg_EventAck(
1566 background_view->GetRoutingID())); 1566 background_view->GetRoutingID()));
1567 } 1567 }
1568 } 1568 }
1569 } 1569 }
1570 1570
1571 } // namespace extensions 1571 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698