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

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

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Delegated Created 8 years, 2 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/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index d370c268c555b51ae652538ac323cac0c26de36b..943ad18fef68d82bb22634cd2e5e96058a6681b2 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/file_select_helper.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
#include "chrome/browser/ui/browser.h"
@@ -64,6 +65,11 @@ using content::WebContents;
namespace extensions {
+bool ExtensionHost::Delegate::KeepsBrowserProcessAlive() {
+ // By default hosts do not keep the browser process alive.
+ return false;
+}
+
// Helper class that rate-limits the creation of renderer processes for
// ExtensionHosts, to avoid blocking the UI.
class ExtensionHost::ProcessCreationQueue {
@@ -125,6 +131,7 @@ class ExtensionHost::ProcessCreationQueue {
// ExtensionHost
ExtensionHost::ExtensionHost(const Extension* extension,
+ Delegate* delegate,
SiteInstance* site_instance,
const GURL& url,
chrome::ViewType host_type)
@@ -132,6 +139,7 @@ ExtensionHost::ExtensionHost(const Extension* extension,
extension_id_(extension->id()),
profile_(Profile::FromBrowserContext(
site_instance->GetBrowserContext())),
+ delegate_(delegate),
render_view_host_(NULL),
did_stop_loading_(false),
document_element_available_(false),
@@ -154,6 +162,9 @@ ExtensionHost::ExtensionHost(const Extension* extension,
// be the same extension that this points to.
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile_));
+
+ if (delegate_->KeepsBrowserProcessAlive())
+ browser::StartKeepAlive();
}
ExtensionHost::~ExtensionHost() {
@@ -167,6 +178,9 @@ ExtensionHost::~ExtensionHost() {
content::Source<Profile>(profile_),
content::Details<ExtensionHost>(this));
ProcessCreationQueue::GetInstance()->Remove(this);
+
+ if (delegate_->KeepsBrowserProcessAlive())
+ browser::EndKeepAlive();
}
void ExtensionHost::CreateView(Browser* browser) {

Powered by Google App Engine
This is Rietveld 408576698