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..78f8c3bce3f3160714b3cf62d53a27620dd73959 100644 |
--- a/chrome/browser/profiles/profile_impl.cc |
+++ b/chrome/browser/profiles/profile_impl.cc |
@@ -167,6 +167,24 @@ 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(); |
+} |
+ |
+void RestoreSessionStateOnIOThread( |
+ net::URLRequestContextGetter* url_request_context_getter) { |
+ url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
+ GetCookieMonster()->RestoreOldSessionCookies(); |
+} |
+ |
+void DiscardSessionStateOnIOThread( |
+ net::URLRequestContextGetter* url_request_context_getter) { |
+ url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
+ GetCookieMonster()->DiscardOldSessionCookies(); |
+} |
+ |
} // namespace |
// static |
@@ -229,7 +247,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!"; |
@@ -261,6 +280,9 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
false)); |
OnPrefsLoaded(true); |
} |
+ |
+ session_restore_enabled_ = |
+ command_line->HasSwitch(switches::kEnableRestoreSessionState); |
} |
void ProfileImpl::DoFinalInit() { |
@@ -1551,6 +1573,33 @@ 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()))); |
+} |
+ |
+void ProfileImpl::RestoreSessionState() { |
+ if (!session_restore_enabled_) |
+ return; |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&RestoreSessionStateOnIOThread, |
+ make_scoped_refptr(GetRequestContext()))); |
+} |
+ |
+void ProfileImpl::DiscardSessionState() { |
+ if (!session_restore_enabled_) |
+ return; |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&DiscardSessionStateOnIOThread, |
+ make_scoped_refptr(GetRequestContext()))); |
+} |
+ |
SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
if (!spellcheck_profile_.get()) |
spellcheck_profile_.reset(new SpellCheckProfile(path_)); |