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

Unified Diff: chrome/browser/profiles/profile_window.cc

Issue 149883004: Fix sketchy User Manager code :( (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/profiles/profile_window.cc
diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc
index 5dc41915e9792b8904908149f3316f0e56e14f81..7292f73a300dfa87643dd90d40888494cf6bdb1c 100644
--- a/chrome/browser/profiles/profile_window.cc
+++ b/chrome/browser/profiles/profile_window.cc
@@ -43,6 +43,7 @@ class BrowserAddedObserver : public chrome::BrowserListObserver {
virtual void OnBrowserAdded(Browser* browser) OVERRIDE {
Alexei Svitkine (slow) 2014/02/06 22:02:12 I think this should check for the profile of the b
noms (inactive) 2014/02/06 22:51:34 Done.
DCHECK(!callback_.is_null());
Alexei Svitkine (slow) 2014/02/06 22:02:12 This check should probably be in the ctor.
noms (inactive) 2014/02/06 22:51:34 Done.
callback_.Run();
Alexei Svitkine (slow) 2014/02/06 22:02:12 I think this should unregister itself as an observ
noms (inactive) 2014/02/06 22:51:34 Done.
+ base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
profiles::ProfileSwitchingDoneCallback callback_;
@@ -93,10 +94,14 @@ void OpenBrowserWindowForProfile(
}
// If there is a callback, create an observer to make sure it is only
- // run when the browser has been completely created.
- scoped_ptr<BrowserAddedObserver> browser_added_observer;
+ // run when the browser has been completely created. This observer will
+ // delete itself that happens. This should not leak, because we are passing
Alexei Svitkine (slow) 2014/02/06 22:02:12 Missing a word after "delete itself".
noms (inactive) 2014/02/06 22:51:34 Done.
+ // |always_create| = true to FindOrCreateNewWindow below, which ends up
+ // calling LaunchBrowser and opens a new window. If for whatever reason that
+ // fails, either something has crashed, or the observer will be cleaned up
+ // when a different browser is opened.
if (!callback.is_null())
- browser_added_observer.reset(new BrowserAddedObserver(callback));
+ new BrowserAddedObserver(callback);
// We already dealt with the case when |always_create| was false and a browser
// existed, which means that here a browser definitely needs to be created.

Powered by Google App Engine
This is Rietveld 408576698