From 398206ce0943c935a8da55d382e60e7be16099cf Mon Sep 17 00:00:00 2001
From: "atwilson@chromium.org"
 <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Mon, 21 Jun 2010 01:46:08 +0000
Subject: Added BackgroundContentsService to manage lifecycle of
 BackgroundContents.

If --restore-background-contents flag is passed, stores the URLs of running
BackgroundContents in preferences so they can be re-launched when the browser
restarts.

Moved logic to shutdown background contents into BackgroundContentsService so
we can use this to coordinate when to keep the browser process running.

BUG=43382
TEST=new tests

Review URL: http://codereview.chromium.org/2104018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50329 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/test/testing_browser_process.h | 11 +++++++++--
 chrome/test/testing_profile.h         |  3 +++
 2 files changed, 12 insertions(+), 2 deletions(-)

(limited to 'chrome/test')

diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index fdfe776..bf1744f 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -26,6 +26,7 @@ class TestingBrowserProcess : public BrowserProcess {
  public:
   TestingBrowserProcess()
       : shutdown_event_(new base::WaitableEvent(true, false)),
+        module_ref_count_(0),
         app_locale_("en") {
   }
 
@@ -125,10 +126,15 @@ class TestingBrowserProcess : public BrowserProcess {
   }
 
   virtual unsigned int AddRefModule() {
-    return 1;
+    return ++module_ref_count_;
   }
   virtual unsigned int ReleaseModule() {
-    return 1;
+    DCHECK(module_ref_count_ > 0);
+    return --module_ref_count_;
+  }
+
+  unsigned int module_ref_count() {
+    return module_ref_count_;
   }
 
   virtual bool IsShuttingDown() {
@@ -165,6 +171,7 @@ class TestingBrowserProcess : public BrowserProcess {
  private:
   NotificationService notification_service_;
   scoped_ptr<base::WaitableEvent> shutdown_event_;
+  unsigned int module_ref_count_;
   scoped_ptr<Clipboard> clipboard_;
   std::string app_locale_;
 
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index 50bd1fe..adc8d95 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -265,6 +265,9 @@ class TestingProfile : public Profile {
   virtual DesktopNotificationService* GetDesktopNotificationService() {
     return NULL;
   }
+  virtual BackgroundContentsService* GetBackgroundContentsService() {
+    return NULL;
+  }
   virtual FilePath last_selected_directory() {
     return last_selected_directory_;
   }
-- 
cgit v1.1