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

Unified Diff: chrome/browser/extensions/extension_process_manager.cc

Issue 7672009: Lazy creating of background pages --enable-lazy-background-pages) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix memory leak Created 9 years, 4 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 | « chrome/browser/extensions/extension_menu_manager_unittest.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_process_manager.cc
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index f64624c2588ff844e10f21e1eb4623c78bb0b87d..806968623b580adb85e0ca85fda6e49460839f9b 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/ui/browser_window.h"
@@ -14,6 +15,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h"
#include "content/browser/site_instance.h"
@@ -55,18 +57,20 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager {
ExtensionProcessManager* original_manager_;
};
-static void CreateBackgroundHost(
+static void CreateBackgroundHostForExtensionLoad(
ExtensionProcessManager* manager, const Extension* extension) {
- // Start the process for the master page, if it exists.
- if (extension->background_url().is_valid())
+ // Start the process for the master page, if it exists and we're not lazy.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableLazyBackgroundPages) &&
+ extension->background_url().is_valid())
manager->CreateBackgroundHost(extension, extension->background_url());
}
-static void CreateBackgroundHosts(
+static void CreateBackgroundHostsForProfileStartup(
ExtensionProcessManager* manager, const ExtensionList* extensions) {
for (ExtensionList::const_iterator extension = extensions->begin();
extension != extensions->end(); ++extension) {
- CreateBackgroundHost(manager, *extension);
+ CreateBackgroundHostForExtensionLoad(manager, *extension);
}
}
@@ -288,7 +292,7 @@ void ExtensionProcessManager::Observe(int type,
const NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_EXTENSIONS_READY: {
- CreateBackgroundHosts(this,
+ CreateBackgroundHostsForProfileStartup(this,
Source<Profile>(source).ptr()->GetExtensionService()->extensions());
break;
}
@@ -298,7 +302,7 @@ void ExtensionProcessManager::Observe(int type,
Source<Profile>(source).ptr()->GetExtensionService();
if (service->is_ready()) {
const Extension* extension = Details<const Extension>(details).ptr();
- ::CreateBackgroundHost(this, extension);
+ ::CreateBackgroundHostForExtensionLoad(this, extension);
}
break;
}
@@ -470,6 +474,9 @@ void IncognitoExtensionProcessManager::Observe(
const NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_BROWSER_WINDOW_READY: {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableLazyBackgroundPages))
+ break;
// We want to spawn our background hosts as soon as the user opens an
// incognito window. Watch for new browsers and create the hosts if
// it matches our profile.
@@ -482,7 +489,7 @@ void IncognitoExtensionProcessManager::Observe(
Profile::FromBrowserContext(browsing_instance_->browser_context());
ExtensionService* service = profile->GetExtensionService();
if (service && service->is_ready())
- CreateBackgroundHosts(this, service->extensions());
+ CreateBackgroundHostsForProfileStartup(this, service->extensions());
}
break;
}
« no previous file with comments | « chrome/browser/extensions/extension_menu_manager_unittest.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698