Chromium Code Reviews| Index: chrome/browser/profiles/profile_impl.cc |
| diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc |
| index 30c73a5822f240339cc5ee61bd71d2964f562ea8..75e6638365f179858fb7ff993ede9307483b1918 100644 |
| --- a/chrome/browser/profiles/profile_impl.cc |
| +++ b/chrome/browser/profiles/profile_impl.cc |
| @@ -167,6 +167,12 @@ FilePath GetMediaCachePath(const FilePath& base) { |
| return base.Append(chrome::kMediaCacheDirname); |
| } |
| +void SaveSessionStateOnIOThread( |
| + net::URLRequestContextGetter* url_request_context_getter) { |
| + url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
| + GetCookieMonster()->SaveSessionCookies(); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -229,7 +235,8 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
| checked_instant_promo_(false), |
| #endif |
| delegate_(delegate), |
| - predictor_(NULL) { |
| + predictor_(NULL), |
| + session_restore_enabled_(false) { |
| DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| "profile files to the root directory!"; |
| @@ -244,6 +251,8 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
| !command_line->HasSwitch(switches::kDisablePreconnect), |
| g_browser_process->profile_manager() == NULL); |
| + session_restore_enabled_ = |
| + command_line->HasSwitch(switches::kEnableRestoreSessionState); |
| if (delegate_) { |
| prefs_.reset(PrefService::CreatePrefService( |
| GetPrefFilePath(), |
| @@ -357,6 +366,12 @@ void ProfileImpl::DoFinalInit() { |
| FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
| + bool restore_old_session_cookies = |
| + session_restore_enabled_ && |
| + (!DidLastSessionExitCleanly() || |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kRestoreLastSession)); |
| + |
| // Make sure we initialize the ProfileIOData after everything else has been |
| // initialized that we might be reading from the IO thread. |
| @@ -364,7 +379,8 @@ void ProfileImpl::DoFinalInit() { |
| cache_max_size, media_cache_path, media_cache_max_size, |
| extensions_cookie_path, app_path, predictor_, |
| g_browser_process->local_state(), |
| - g_browser_process->io_thread()); |
| + g_browser_process->io_thread(), |
| + restore_old_session_cookies); |
| ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| PluginPrefs::GetForProfile(this), &GetResourceContext()); |
| @@ -1551,6 +1567,15 @@ NetworkActionPredictor* ProfileImpl::GetNetworkActionPredictor() { |
| return network_action_predictor_.get(); |
| } |
| +void ProfileImpl::SaveSessionState() { |
| + if (!session_restore_enabled_) |
| + return; |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&SaveSessionStateOnIOThread, |
| + make_scoped_refptr(GetRequestContext()))); |
|
erikwright (departed)
2011/11/29 13:43:22
I'm under the impression that Bind automatically i
marja
2011/11/29 14:58:21
If I remove it, the compile-time assert p1_is_refc
|
| +} |
| + |
| SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
| if (!spellcheck_profile_.get()) |
| spellcheck_profile_.reset(new SpellCheckProfile(path_)); |