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

Unified Diff: chrome/renderer/extensions/dispatcher.cc

Issue 14569019: Revert the perf-regressing component of r196319. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/dispatcher.cc
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc
index 30b65258abc6a3f7e837b3fc2debe53143140be5..8da074ce0c68621cf28033ef757625135aa0c87d 100644
--- a/chrome/renderer/extensions/dispatcher.cc
+++ b/chrome/renderer/extensions/dispatcher.cc
@@ -1028,13 +1028,29 @@ void Dispatcher::DidCreateScriptContext(
GetOrCreateChrome(v8_context);
- // TODO(kalman): see comment below about ExtensionAPI.
- if (extension && !extension->is_platform_app())
- module_system->Require("miscellaneous_bindings");
- if (context_type != Feature::WEB_PAGE_CONTEXT)
- module_system->Require("json"); // see paranoid comment in json.js
-
- RegisterSchemaGeneratedBindings(module_system.get(), context);
+ // Loading JavaScript is expensive, so only run the full API bindings
+ // generation mechanisms in extension pages (NOT all web pages).
+ switch (context_type) {
+ case Feature::UNSPECIFIED_CONTEXT:
+ case Feature::WEB_PAGE_CONTEXT:
+ // TODO(kalman): see comment below about ExtensionAPI.
+ InstallBindings(module_system.get(), v8_context, "app");
+ InstallBindings(module_system.get(), v8_context, "webstore");
+ break;
+ case Feature::BLESSED_EXTENSION_CONTEXT:
+ case Feature::UNBLESSED_EXTENSION_CONTEXT:
+ case Feature::CONTENT_SCRIPT_CONTEXT:
+ if (extension && !extension->is_platform_app())
+ module_system->Require("miscellaneous_bindings");
+ module_system->Require("json"); // see paranoid comment in json.js
+
+ // TODO(kalman): move this code back out of the switch and execute it
+ // regardless of |context_type|. ExtensionAPI knows how to return the
+ // correct APIs, however, until it doesn't have a 2MB overhead we can't
+ // load it in every process.
+ RegisterSchemaGeneratedBindings(module_system.get(), context);
+ break;
+ }
bool is_within_platform_app = IsWithinPlatformApp(frame);
// Inject custom JS into the platform app context.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698