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

Side by Side Diff: content/browser/net/sqlite_persistent_cookie_store.cc

Issue 1103003002: Delete session cookies immediately after loading the cookie DB. (attempt #2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove non-determinism from unit test. Created 5 years, 8 months 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
« no previous file with comments | « no previous file | content/browser/net/sqlite_persistent_cookie_store_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/net/sqlite_persistent_cookie_store.h" 5 #include "content/browser/net/sqlite_persistent_cookie_store.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 694 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
695 50); 695 50);
696 696
697 UMA_HISTOGRAM_CUSTOM_TIMES( 697 UMA_HISTOGRAM_CUSTOM_TIMES(
698 "Cookie.TimeInitializeDomainMap", 698 "Cookie.TimeInitializeDomainMap",
699 base::Time::Now() - start, 699 base::Time::Now() - start,
700 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 700 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
701 50); 701 50);
702 702
703 initialized_ = true; 703 initialized_ = true;
704
705 if (!restore_old_session_cookies_)
706 DeleteSessionCookiesOnStartup();
704 return true; 707 return true;
705 } 708 }
706 709
707 void SQLitePersistentCookieStore::Backend::ChainLoadCookies( 710 void SQLitePersistentCookieStore::Backend::ChainLoadCookies(
708 const LoadedCallback& loaded_callback) { 711 const LoadedCallback& loaded_callback) {
709 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 712 DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
710 IncrementTimeDelta increment(&cookie_load_duration_); 713 IncrementTimeDelta increment(&cookie_load_duration_);
711 714
712 bool load_success = true; 715 bool load_success = true;
713 716
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 } 1292 }
1290 } 1293 }
1291 1294
1292 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() { 1295 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() {
1293 base::AutoLock locked(lock_); 1296 base::AutoLock locked(lock_);
1294 force_keep_session_state_ = true; 1297 force_keep_session_state_ = true;
1295 } 1298 }
1296 1299
1297 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() { 1300 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() {
1298 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 1301 DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
1299 if (!db_->Execute("DELETE FROM cookies WHERE persistent == 0")) 1302 if (!db_->Execute("DELETE FROM cookies WHERE persistent != 1"))
1300 LOG(WARNING) << "Unable to delete session cookies."; 1303 LOG(WARNING) << "Unable to delete session cookies.";
1301 } 1304 }
1302 1305
1303 void SQLitePersistentCookieStore::Backend::PostBackgroundTask( 1306 void SQLitePersistentCookieStore::Backend::PostBackgroundTask(
1304 const tracked_objects::Location& origin, const base::Closure& task) { 1307 const tracked_objects::Location& origin, const base::Closure& task) {
1305 if (!background_task_runner_->PostTask(origin, task)) { 1308 if (!background_task_runner_->PostTask(origin, task)) {
1306 LOG(WARNING) << "Failed to post task from " << origin.ToString() 1309 LOG(WARNING) << "Failed to post task from " << origin.ToString()
1307 << " to background_task_runner_."; 1310 << " to background_task_runner_.";
1308 } 1311 }
1309 } 1312 }
1310 1313
1311 void SQLitePersistentCookieStore::Backend::PostClientTask( 1314 void SQLitePersistentCookieStore::Backend::PostClientTask(
1312 const tracked_objects::Location& origin, const base::Closure& task) { 1315 const tracked_objects::Location& origin, const base::Closure& task) {
1313 if (!client_task_runner_->PostTask(origin, task)) { 1316 if (!client_task_runner_->PostTask(origin, task)) {
1314 LOG(WARNING) << "Failed to post task from " << origin.ToString() 1317 LOG(WARNING) << "Failed to post task from " << origin.ToString()
1315 << " to client_task_runner_."; 1318 << " to client_task_runner_.";
1316 } 1319 }
1317 } 1320 }
1318 1321
1319 void SQLitePersistentCookieStore::Backend::FinishedLoadingCookies( 1322 void SQLitePersistentCookieStore::Backend::FinishedLoadingCookies(
1320 const LoadedCallback& loaded_callback, 1323 const LoadedCallback& loaded_callback,
1321 bool success) { 1324 bool success) {
1322 PostClientTask(FROM_HERE, base::Bind(&Backend::CompleteLoadInForeground, this, 1325 PostClientTask(FROM_HERE, base::Bind(&Backend::CompleteLoadInForeground, this,
1323 loaded_callback, success)); 1326 loaded_callback, success));
1324 if (success && !restore_old_session_cookies_)
1325 DeleteSessionCookiesOnStartup();
1326 } 1327 }
1327 1328
1328 SQLitePersistentCookieStore::SQLitePersistentCookieStore( 1329 SQLitePersistentCookieStore::SQLitePersistentCookieStore(
1329 const base::FilePath& path, 1330 const base::FilePath& path,
1330 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, 1331 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
1331 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, 1332 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
1332 bool restore_old_session_cookies, 1333 bool restore_old_session_cookies,
1333 storage::SpecialStoragePolicy* special_storage_policy, 1334 storage::SpecialStoragePolicy* special_storage_policy,
1334 net::CookieCryptoDelegate* crypto_delegate) 1335 net::CookieCryptoDelegate* crypto_delegate)
1335 : backend_(new Backend(path, 1336 : backend_(new Backend(path,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 (config.session_cookie_mode == 1440 (config.session_cookie_mode ==
1440 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { 1441 CookieStoreConfig::RESTORED_SESSION_COOKIES)) {
1441 cookie_monster->SetPersistSessionCookies(true); 1442 cookie_monster->SetPersistSessionCookies(true);
1442 } 1443 }
1443 } 1444 }
1444 1445
1445 return cookie_monster; 1446 return cookie_monster;
1446 } 1447 }
1447 1448
1448 } // namespace content 1449 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/net/sqlite_persistent_cookie_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698