diff options
author | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-23 20:16:19 +0000 |
---|---|---|
committer | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-23 20:16:19 +0000 |
commit | 70599542bb4ee6d0182a2d8ab2a7878a8f56bb39 (patch) | |
tree | fb70ae8164d3680623a21845e3b555c012f901f4 | |
parent | 9c06e96528535ed6717aaece0144d92da7311e0c (diff) | |
download | chromium_src-70599542bb4ee6d0182a2d8ab2a7878a8f56bb39.zip chromium_src-70599542bb4ee6d0182a2d8ab2a7878a8f56bb39.tar.gz chromium_src-70599542bb4ee6d0182a2d8ab2a7878a8f56bb39.tar.bz2 |
Fix: enable restoring multiple profiles asynchronously on startup.
Restoring multiple profiles asynchronously at the same time
was not possible. This resulted in only some of the needed profiles getting restored when relaunching Chromium after update.
BUG=99088
TEST=See bug.
Review URL: http://codereview.chromium.org/9141013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118721 0039d316-1c4b-4281-b951-d872f2087c98
-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 |