summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profile.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 06:12:51 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 06:12:51 +0000
commitf6e7b6d78a6729ab7cc8c3258d3aeb8f73210cdc (patch)
tree69e43602da6edb4210c829adebf673c613d28ee0 /chrome/browser/profile.cc
parent928f1ae98b48114542a239e5b11a19cd4e9a001e (diff)
downloadchromium_src-f6e7b6d78a6729ab7cc8c3258d3aeb8f73210cdc.zip
chromium_src-f6e7b6d78a6729ab7cc8c3258d3aeb8f73210cdc.tar.gz
chromium_src-f6e7b6d78a6729ab7cc8c3258d3aeb8f73210cdc.tar.bz2
Stability fix: do not access Browser* during its destruction
when closing an incognito window that had a download. BUG=59365 TEST=see bug Review URL: http://codereview.chromium.org/3826014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile.cc')
-rw-r--r--chrome/browser/profile.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 0478e5c..9ac5a72 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -115,7 +115,7 @@ bool Profile::IsSyncAccessible() {
//
////////////////////////////////////////////////////////////////////////////////
class OffTheRecordProfileImpl : public Profile,
- public NotificationObserver {
+ public BrowserList::Observer {
public:
explicit OffTheRecordProfileImpl(Profile* real_profile)
: profile_(real_profile),
@@ -123,11 +123,8 @@ class OffTheRecordProfileImpl : public Profile,
request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this);
extension_process_manager_.reset(ExtensionProcessManager::Create(this));
- // Register for browser close notifications so we can detect when the last
- // off-the-record window is closed, in which case we can clean our states
- // (cookies, downloads...).
- registrar_.Add(this, NotificationType::BROWSER_CLOSED,
- NotificationService::AllSources());
+ BrowserList::AddObserver(this);
+
background_contents_service_.reset(
new BackgroundContentsService(this, CommandLine::ForCurrentProcess()));
}
@@ -145,6 +142,8 @@ class OffTheRecordProfileImpl : public Profile,
NewRunnableMethod(
db_tracker_.get(),
&webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory));
+
+ BrowserList::RemoveObserver(this);
}
virtual ProfileId GetRuntimeId() {
@@ -537,18 +536,11 @@ class OffTheRecordProfileImpl : public Profile,
}
}
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value);
- // We are only interested in OTR browser closing.
- if (Source<Browser>(source)->profile() != this)
- return;
+ virtual void OnBrowserAdded(const Browser* browser) {
+ }
- // Let's check if we still have an Off The Record window opened.
- // Note that we check against 1 as this notification is sent before the
- // browser window is actually removed from the list.
- if (BrowserList::GetBrowserCount(this) <= 1)
+ virtual void OnBrowserRemoved(const Browser* browser) {
+ if (BrowserList::GetBrowserCount(this) == 0)
ExitedOffTheRecordMode();
}