diff options
-rw-r--r-- | chrome/browser/sessions/session_restore.cc | 24 | ||||
-rw-r--r-- | chrome/browser/sessions/session_restore.h | 6 | ||||
-rw-r--r-- | chrome/browser/sessions/session_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser_init_browsertest.cc | 3 |
4 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 9f8e83b..c92ddea 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -45,11 +45,11 @@ using content::NavigationController; using content::WebContents; -// Are we in the process of restoring? -static bool restoring = false; - namespace { +// Pointers to profiles for which the session restore is in progress. +std::set<const Profile*>* profiles_getting_restored = NULL; + // TabLoader ------------------------------------------------------------------ // Initial delay (see class decription for details). @@ -493,7 +493,12 @@ class SessionRestoreImpl : public content::NotificationObserver { ~SessionRestoreImpl() { STLDeleteElements(&windows_); - restoring = false; + DCHECK(profiles_getting_restored); + profiles_getting_restored->erase(profile_); + if (profiles_getting_restored->empty()) { + delete profiles_getting_restored; + profiles_getting_restored = NULL; + } g_browser_process->ReleaseModule(); } @@ -870,7 +875,10 @@ Browser* SessionRestore::RestoreSession(Profile* profile, NOTREACHED(); return NULL; } - restoring = true; + if (profiles_getting_restored == NULL) + profiles_getting_restored = new std::set<const Profile*>(); + profiles_getting_restored->insert(profile); + profile->set_restored_last_session(true); // SessionRestoreImpl takes care of deleting itself when done. SessionRestoreImpl* restorer = new SessionRestoreImpl( @@ -904,6 +912,8 @@ void SessionRestore::RestoreForeignSessionTab(Profile* profile, } // static -bool SessionRestore::IsRestoring() { - return restoring; +bool SessionRestore::IsRestoring(const Profile* profile) { + return (profiles_getting_restored && + profiles_getting_restored->find(profile) != + profiles_getting_restored->end()); } diff --git a/chrome/browser/sessions/session_restore.h b/chrome/browser/sessions/session_restore.h index 4ed27f0..ba1dc0f 100644 --- a/chrome/browser/sessions/session_restore.h +++ b/chrome/browser/sessions/session_restore.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,8 +55,8 @@ class SessionRestore { static void RestoreForeignSessionTab(Profile* profile, const SessionTab& tab); - // Returns true if we're in the process of restoring. - static bool IsRestoring(); + // Returns true if we're in the process of restoring |profile|. + static bool IsRestoring(const Profile* profile); // The max number of non-selected tabs SessionRestore loads when restoring // a session. A value of 0 indicates all tabs are loaded at once. diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 68c7d67..aad8ae9 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -462,7 +462,7 @@ void SessionService::Init() { bool SessionService::ShouldNewWindowStartSession() { if (!has_open_trackable_browsers_ && !BrowserInit::InProcessStartup() && - !SessionRestore::IsRestoring() + !SessionRestore::IsRestoring(profile()) #if defined(OS_MACOSX) // OSX has a fairly different idea of application lifetime than the // other platforms. We need to check that we aren't opening a window diff --git a/chrome/browser/ui/browser_init_browsertest.cc b/chrome/browser/ui/browser_init_browsertest.cc index 1ab3823..6a5cf42 100644 --- a/chrome/browser/ui/browser_init_browsertest.cc +++ b/chrome/browser/ui/browser_init_browsertest.cc @@ -450,7 +450,8 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, UpdateWithTwoProfiles) { browser_init.Start(dummy, profile_manager->user_data_dir(), profile1, last_opened_profiles, &return_code); - while (SessionRestore::IsRestoring()) + while (SessionRestore::IsRestoring(profile1) || + SessionRestore::IsRestoring(profile2)) MessageLoop::current()->RunAllPending(); // The startup URLs are ignored, and instead the last open sessions are |