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

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.h ('k') | chrome/browser/ui/browser_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_impl_io_data.h" 5 #include "chrome/browser/profiles/profile_impl_io_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const FilePath& cookie_path, 84 const FilePath& cookie_path,
85 const FilePath& origin_bound_cert_path, 85 const FilePath& origin_bound_cert_path,
86 const FilePath& cache_path, 86 const FilePath& cache_path,
87 int cache_max_size, 87 int cache_max_size,
88 const FilePath& media_cache_path, 88 const FilePath& media_cache_path,
89 int media_cache_max_size, 89 int media_cache_max_size,
90 const FilePath& extensions_cookie_path, 90 const FilePath& extensions_cookie_path,
91 const FilePath& app_path, 91 const FilePath& app_path,
92 chrome_browser_net::Predictor* predictor, 92 chrome_browser_net::Predictor* predictor,
93 PrefService* local_state, 93 PrefService* local_state,
94 IOThread* io_thread) { 94 IOThread* io_thread,
95 bool restore_old_session_cookies) {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
96 DCHECK(!io_data_->lazy_params_.get()); 97 DCHECK(!io_data_->lazy_params_.get());
97 DCHECK(predictor); 98 DCHECK(predictor);
98 99
99 LazyParams* lazy_params = new LazyParams; 100 LazyParams* lazy_params = new LazyParams;
100 101
101 lazy_params->cookie_path = cookie_path; 102 lazy_params->cookie_path = cookie_path;
102 lazy_params->origin_bound_cert_path = origin_bound_cert_path; 103 lazy_params->origin_bound_cert_path = origin_bound_cert_path;
103 lazy_params->cache_path = cache_path; 104 lazy_params->cache_path = cache_path;
104 lazy_params->cache_max_size = cache_max_size; 105 lazy_params->cache_max_size = cache_max_size;
105 lazy_params->media_cache_path = media_cache_path; 106 lazy_params->media_cache_path = media_cache_path;
106 lazy_params->media_cache_max_size = media_cache_max_size; 107 lazy_params->media_cache_max_size = media_cache_max_size;
107 lazy_params->extensions_cookie_path = extensions_cookie_path; 108 lazy_params->extensions_cookie_path = extensions_cookie_path;
109 lazy_params->restore_old_session_cookies = restore_old_session_cookies;
108 110
109 io_data_->lazy_params_.reset(lazy_params); 111 io_data_->lazy_params_.reset(lazy_params);
110 112
111 // Keep track of isolated app path separately so we can use it on demand. 113 // Keep track of isolated app path separately so we can use it on demand.
112 io_data_->app_path_ = app_path; 114 io_data_->app_path_ = app_path;
113 115
114 io_data_->predictor_.reset(predictor); 116 io_data_->predictor_.reset(predictor);
115 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), 117 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(),
116 local_state, 118 local_state,
117 io_thread); 119 io_thread);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Don't use existing origin-bound certs and use an in-memory store. 313 // Don't use existing origin-bound certs and use an in-memory store.
312 origin_bound_cert_service = new net::OriginBoundCertService( 314 origin_bound_cert_service = new net::OriginBoundCertService(
313 new net::DefaultOriginBoundCertStore(NULL)); 315 new net::DefaultOriginBoundCertStore(NULL));
314 } 316 }
315 317
316 // setup cookie store 318 // setup cookie store
317 if (!cookie_store) { 319 if (!cookie_store) {
318 DCHECK(!lazy_params_->cookie_path.empty()); 320 DCHECK(!lazy_params_->cookie_path.empty());
319 321
320 scoped_refptr<SQLitePersistentCookieStore> cookie_db = 322 scoped_refptr<SQLitePersistentCookieStore> cookie_db =
321 new SQLitePersistentCookieStore(lazy_params_->cookie_path); 323 new SQLitePersistentCookieStore(
324 lazy_params_->cookie_path,
325 lazy_params_->restore_old_session_cookies);
322 cookie_db->SetClearLocalStateOnExit( 326 cookie_db->SetClearLocalStateOnExit(
323 profile_params->clear_local_state_on_exit); 327 profile_params->clear_local_state_on_exit);
324 cookie_store = 328 cookie_store =
325 new net::CookieMonster(cookie_db.get(), 329 new net::CookieMonster(cookie_db.get(),
326 profile_params->cookie_monster_delegate); 330 profile_params->cookie_monster_delegate);
331 if (command_line.HasSwitch(switches::kEnableRestoreSessionState))
332 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true);
327 } 333 }
328 334
329 net::CookieMonster* extensions_cookie_store = 335 net::CookieMonster* extensions_cookie_store =
330 new net::CookieMonster( 336 new net::CookieMonster(
331 new SQLitePersistentCookieStore( 337 new SQLitePersistentCookieStore(
332 lazy_params_->extensions_cookie_path), NULL); 338 lazy_params_->extensions_cookie_path,
339 lazy_params_->restore_old_session_cookies), NULL);
333 // Enable cookies for devtools and extension URLs. 340 // Enable cookies for devtools and extension URLs.
334 const char* schemes[] = {chrome::kChromeDevToolsScheme, 341 const char* schemes[] = {chrome::kChromeDevToolsScheme,
335 chrome::kExtensionScheme}; 342 chrome::kExtensionScheme};
336 extensions_cookie_store->SetCookieableSchemes(schemes, 2); 343 extensions_cookie_store->SetCookieableSchemes(schemes, 2);
337 344
338 main_context->set_cookie_store(cookie_store); 345 main_context->set_cookie_store(cookie_store);
339 media_request_context_->set_cookie_store(cookie_store); 346 media_request_context_->set_cookie_store(cookie_store);
340 extensions_context->set_cookie_store(extensions_cookie_store); 347 extensions_context->set_cookie_store(extensions_cookie_store);
341 348
342 // Setup origin bound cert service. 349 // Setup origin bound cert service.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 cookie_store = new net::CookieMonster(NULL, NULL); 464 cookie_store = new net::CookieMonster(NULL, NULL);
458 app_http_cache->set_mode( 465 app_http_cache->set_mode(
459 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); 466 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
460 } 467 }
461 468
462 // Use an app-specific cookie store. 469 // Use an app-specific cookie store.
463 if (!cookie_store) { 470 if (!cookie_store) {
464 DCHECK(!cookie_path.empty()); 471 DCHECK(!cookie_path.empty());
465 472
466 scoped_refptr<SQLitePersistentCookieStore> cookie_db = 473 scoped_refptr<SQLitePersistentCookieStore> cookie_db =
467 new SQLitePersistentCookieStore(cookie_path); 474 new SQLitePersistentCookieStore(cookie_path, false);
468 cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_); 475 cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_);
469 // TODO(creis): We should have a cookie delegate for notifying the cookie 476 // TODO(creis): We should have a cookie delegate for notifying the cookie
470 // extensions API, but we need to update it to understand isolated apps 477 // extensions API, but we need to update it to understand isolated apps
471 // first. 478 // first.
472 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); 479 cookie_store = new net::CookieMonster(cookie_db.get(), NULL);
473 } 480 }
474 481
475 context->SetCookieStore(cookie_store); 482 context->SetCookieStore(cookie_store);
476 context->SetHttpTransactionFactory(app_http_cache); 483 context->SetHttpTransactionFactory(app_http_cache);
477 484
478 return context; 485 return context;
479 } 486 }
480 487
481 scoped_refptr<ChromeURLRequestContext> 488 scoped_refptr<ChromeURLRequestContext>
482 ProfileImplIOData::AcquireMediaRequestContext() const { 489 ProfileImplIOData::AcquireMediaRequestContext() const {
483 DCHECK(media_request_context_); 490 DCHECK(media_request_context_);
484 return media_request_context_; 491 return media_request_context_;
485 } 492 }
486 493
487 scoped_refptr<ChromeURLRequestContext> 494 scoped_refptr<ChromeURLRequestContext>
488 ProfileImplIOData::AcquireIsolatedAppRequestContext( 495 ProfileImplIOData::AcquireIsolatedAppRequestContext(
489 scoped_refptr<ChromeURLRequestContext> main_context, 496 scoped_refptr<ChromeURLRequestContext> main_context,
490 const std::string& app_id) const { 497 const std::string& app_id) const {
491 // We create per-app contexts on demand, unlike the others above. 498 // We create per-app contexts on demand, unlike the others above.
492 scoped_refptr<ChromeURLRequestContext> app_request_context = 499 scoped_refptr<ChromeURLRequestContext> app_request_context =
493 InitializeAppRequestContext(main_context, app_id); 500 InitializeAppRequestContext(main_context, app_id);
494 DCHECK(app_request_context); 501 DCHECK(app_request_context);
495 return app_request_context; 502 return app_request_context;
496 } 503 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.h ('k') | chrome/browser/ui/browser_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698