summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorjam <jam@chromium.org>2016-03-22 22:34:24 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 05:35:38 +0000
commit75c4422d8fdabd231f40a6c9235f4512f0170268 (patch)
tree95d8a4b3b54dc0ff1e22ad25e0fefcc7afb7d832 /extensions
parentb746ad977e2ad04e17a0792bd313f6e9d7a4be74 (diff)
downloadchromium_src-75c4422d8fdabd231f40a6c9235f4512f0170268.zip
chromium_src-75c4422d8fdabd231f40a6c9235f4512f0170268.tar.gz
chromium_src-75c4422d8fdabd231f40a6c9235f4512f0170268.tar.bz2
Remove logic for lazy initialization of WebKit.
See "Extensions impact on startup?" thread on (internal) chrome-fast mailing list from 8/14/2015 for background, which showed that effectively undoing this logic showed a 3% reduction on first_non_empty_paint_time. This lazy initialization used to be a performance win when it was added years ago, but has since become a performance drag. Since it's effectively not used now (since ChromeContentRendererClient::RenderThreadStarted always initializes WebKit through its call to RenderThread::RegisterExtension), just remove this unused logic. Review URL: https://codereview.chromium.org/1821413003 Cr-Commit-Position: refs/heads/master@{#382795}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/renderer/dispatcher.cc140
-rw-r--r--extensions/renderer/dispatcher.h4
2 files changed, 65 insertions, 79 deletions
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index 4bca09c..77a4e7b 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -211,7 +211,6 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate)
content_watcher_(new ContentWatcher()),
source_map_(&ResourceBundle::GetSharedInstance()),
v8_schema_registry_(new V8SchemaRegistry),
- is_webkit_initialized_(false),
user_script_set_manager_observer_(this),
webrequest_used_(false) {
const base::CommandLine& command_line =
@@ -233,6 +232,62 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate)
request_sender_.reset(new RequestSender(this));
PopulateSourceMap();
WakeEventPage::Get()->Init(RenderThread::Get());
+
+ RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension());
+
+ // WebSecurityPolicy whitelists. They should be registered for both
+ // chrome-extension: and chrome-extension-resource.
+ using RegisterFunction = void (*)(const WebString&);
+ RegisterFunction register_functions[] = {
+ // Treat as secure because communication with them is entirely in the
+ // browser, so there is no danger of manipulation or eavesdropping on
+ // communication with them by third parties.
+ WebSecurityPolicy::registerURLSchemeAsSecure,
+ // As far as Blink is concerned, they should be allowed to receive CORS
+ // requests. At the Extensions layer, requests will actually be blocked
+ // unless overridden by the web_accessible_resources manifest key.
+ // TODO(kalman): See what happens with a service worker.
+ WebSecurityPolicy::registerURLSchemeAsCORSEnabled,
+ // Resources should bypass Content Security Policy checks when included in
+ // protected resources. TODO(kalman): What are "protected resources"?
+ WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy,
+ // Extension resources are HTTP-like and safe to expose to the fetch API.
+ // The rules for the fetch API are consistent with XHR.
+ WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI,
+ // Extension resources, when loaded as the top-level document, should
+ // bypass Blink's strict first-party origin checks.
+ WebSecurityPolicy::registerURLSchemeAsFirstPartyWhenTopLevel,
+ };
+
+ WebString extension_scheme(base::ASCIIToUTF16(kExtensionScheme));
+ WebString extension_resource_scheme(base::ASCIIToUTF16(
+ kExtensionResourceScheme));
+ for (RegisterFunction func : register_functions) {
+ func(extension_scheme);
+ func(extension_resource_scheme);
+ }
+
+ // For extensions, we want to ensure we call the IdleHandler every so often,
+ // even if the extension keeps up activity.
+ if (set_idle_notifications_) {
+ forced_idle_timer_.reset(new base::RepeatingTimer);
+ forced_idle_timer_->Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kMaxExtensionIdleHandlerDelayMs),
+ RenderThread::Get(),
+ &RenderThread::IdleHandler);
+ }
+
+ // Initialize host permissions for any extensions that were activated before
+ // WebKit was initialized.
+ for (const std::string& extension_id : active_extension_ids_) {
+ const Extension* extension =
+ RendererExtensionRegistry::Get()->GetByID(extension_id);
+ CHECK(extension);
+ InitOriginPermissions(extension);
+ }
+
+ EnableCustomElementWhiteList();
}
Dispatcher::~Dispatcher() {
@@ -889,67 +944,6 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
return handled;
}
-
-void Dispatcher::WebKitInitialized() {
- RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension());
-
- // WebSecurityPolicy whitelists. They should be registered for both
- // chrome-extension: and chrome-extension-resource.
- using RegisterFunction = void (*)(const WebString&);
- RegisterFunction register_functions[] = {
- // Treat as secure because communication with them is entirely in the
- // browser, so there is no danger of manipulation or eavesdropping on
- // communication with them by third parties.
- WebSecurityPolicy::registerURLSchemeAsSecure,
- // As far as Blink is concerned, they should be allowed to receive CORS
- // requests. At the Extensions layer, requests will actually be blocked
- // unless overridden by the web_accessible_resources manifest key.
- // TODO(kalman): See what happens with a service worker.
- WebSecurityPolicy::registerURLSchemeAsCORSEnabled,
- // Resources should bypass Content Security Policy checks when included in
- // protected resources. TODO(kalman): What are "protected resources"?
- WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy,
- // Extension resources are HTTP-like and safe to expose to the fetch API.
- // The rules for the fetch API are consistent with XHR.
- WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI,
- // Extension resources, when loaded as the top-level document, should
- // bypass Blink's strict first-party origin checks.
- WebSecurityPolicy::registerURLSchemeAsFirstPartyWhenTopLevel,
- };
-
- WebString extension_scheme(base::ASCIIToUTF16(kExtensionScheme));
- WebString extension_resource_scheme(base::ASCIIToUTF16(
- kExtensionResourceScheme));
- for (RegisterFunction func : register_functions) {
- func(extension_scheme);
- func(extension_resource_scheme);
- }
-
- // For extensions, we want to ensure we call the IdleHandler every so often,
- // even if the extension keeps up activity.
- if (set_idle_notifications_) {
- forced_idle_timer_.reset(new base::RepeatingTimer);
- forced_idle_timer_->Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kMaxExtensionIdleHandlerDelayMs),
- RenderThread::Get(),
- &RenderThread::IdleHandler);
- }
-
- // Initialize host permissions for any extensions that were activated before
- // WebKit was initialized.
- for (const std::string& extension_id : active_extension_ids_) {
- const Extension* extension =
- RendererExtensionRegistry::Get()->GetByID(extension_id);
- CHECK(extension);
- InitOriginPermissions(extension);
- }
-
- EnableCustomElementWhiteList();
-
- is_webkit_initialized_ = true;
-}
-
void Dispatcher::IdleNotification() {
if (set_idle_notifications_ && forced_idle_timer_) {
// Dampen the forced delay as well if the extension stays idle for long
@@ -1003,12 +997,10 @@ void Dispatcher::OnActivateExtension(const std::string& extension_id) {
// handler ticking.
RenderThread::Get()->ScheduleIdleHandler(kInitialExtensionIdleHandlerDelayMs);
- if (is_webkit_initialized_) {
- DOMActivityLogger::AttachToWorld(
- DOMActivityLogger::kMainWorldId, extension_id);
+ DOMActivityLogger::AttachToWorld(
+ DOMActivityLogger::kMainWorldId, extension_id);
- InitOriginPermissions(extension);
- }
+ InitOriginPermissions(extension);
UpdateActiveExtensions();
}
@@ -1189,12 +1181,10 @@ void Dispatcher::OnUpdatePermissions(
scoped_ptr<const PermissionSet> withheld =
params.withheld_permissions.ToPermissionSet();
- if (is_webkit_initialized_) {
- UpdateOriginPermissions(
- extension->url(),
- extension->permissions_data()->GetEffectiveHostPermissions(),
- active->effective_hosts());
- }
+ UpdateOriginPermissions(
+ extension->url(),
+ extension->permissions_data()->GetEffectiveHostPermissions(),
+ active->effective_hosts());
extension->permissions_data()->SetPermissions(std::move(active),
std::move(withheld));
@@ -1219,7 +1209,7 @@ void Dispatcher::OnUpdateTabSpecificPermissions(const GURL& visible_url,
extensions::ManifestPermissionSet(), new_hosts,
extensions::URLPatternSet()));
- if (is_webkit_initialized_ && update_origin_whitelist) {
+ if (update_origin_whitelist) {
UpdateOriginPermissions(
extension->url(),
old_effective,
@@ -1237,7 +1227,7 @@ void Dispatcher::OnClearTabSpecificPermissions(
URLPatternSet old_effective =
extension->permissions_data()->GetEffectiveHostPermissions();
extension->permissions_data()->ClearTabSpecificPermissions(tab_id);
- if (is_webkit_initialized_ && update_origin_whitelist) {
+ if (update_origin_whitelist) {
UpdateOriginPermissions(
extension->url(),
old_effective,
diff --git a/extensions/renderer/dispatcher.h b/extensions/renderer/dispatcher.h
index eb4372c..37ab0a3 100644
--- a/extensions/renderer/dispatcher.h
+++ b/extensions/renderer/dispatcher.h
@@ -155,7 +155,6 @@ class Dispatcher : public content::RenderProcessObserver,
// RenderProcessObserver implementation:
bool OnControlMessageReceived(const IPC::Message& message) override;
- void WebKitInitialized() override;
void IdleNotification() override;
void OnRenderProcessShutdown() override;
@@ -298,9 +297,6 @@ class Dispatcher : public content::RenderProcessObserver,
// Mapping of port IDs to tabs. If there is no tab, the value would be -1.
std::map<int, int> port_to_tab_id_map_;
- // True once WebKit has been initialized (and it is therefore safe to poke).
- bool is_webkit_initialized_;
-
// It is important for this to come after the ScriptInjectionManager, so that
// the observer is destroyed before the UserScriptSet.
ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer>