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

Unified Diff: chrome/renderer/module_system.cc

Issue 9835039: Make app_custom_bindings.js lazily evaluated so it doesn't execute on every page load. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lazy load webstore bindings as well Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/module_system.cc
diff --git a/chrome/renderer/module_system.cc b/chrome/renderer/module_system.cc
index 8d45dfe1f45c7c186b7b61ecfcce588e9265a698..151be28a524a242accf9562ffb373eeefbc8c37f 100644
--- a/chrome/renderer/module_system.cc
+++ b/chrome/renderer/module_system.cc
@@ -29,6 +29,16 @@ ModuleSystem::ModuleSystem(SourceMap* source_map)
ModuleSystem::~ModuleSystem() {
}
+ModuleSystem::NativesEnabledScope::NativesEnabledScope(
+ ModuleSystem* module_system)
+ : module_system_(module_system) {
+ module_system_->set_natives_enabled(true);
not at google - send to devlin 2012/03/25 22:42:58 This won't work with nested "natives enabled" scop
koz (OOO until 15th September) 2012/03/26 01:36:09 Good point. I've made it a counter and removed the
+}
+
+ModuleSystem::NativesEnabledScope::~NativesEnabledScope() {
+ module_system_->set_natives_enabled(false);
+}
+
void ModuleSystem::Require(const std::string& module_name) {
v8::HandleScope handle_scope;
RequireForJsInner(v8::String::New(module_name.c_str()));
@@ -91,8 +101,12 @@ v8::Handle<v8::Value> ModuleSystem::GetterRouter(
ModuleSystem* module_system = static_cast<ModuleSystem*>(
v8::Handle<v8::External>::Cast(module_system_value)->Value());
- v8::Handle<v8::Object> module = module_system->RequireForJsInner(
- parameters->Get(v8::String::New(kModuleName))->ToString())->ToObject();
+ v8::Handle<v8::Object> module;
+ {
+ NativesEnabledScope scope(module_system);
+ module = module_system->RequireForJsInner(
+ parameters->Get(v8::String::New(kModuleName))->ToString())->ToObject();
not at google - send to devlin 2012/03/25 22:42:58 (see comment above)
koz (OOO until 15th September) 2012/03/26 01:36:09 Done.
+ }
v8::Handle<v8::String> field =
parameters->Get(v8::String::New(kModuleField))->ToString();

Powered by Google App Engine
This is Rietveld 408576698