OLD | NEW |
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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), | 688 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), |
689 50); | 689 50); |
690 | 690 |
691 UMA_HISTOGRAM_CUSTOM_TIMES( | 691 UMA_HISTOGRAM_CUSTOM_TIMES( |
692 "Cookie.TimeInitializeDomainMap", | 692 "Cookie.TimeInitializeDomainMap", |
693 base::Time::Now() - start, | 693 base::Time::Now() - start, |
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 initialized_ = true; | 697 initialized_ = true; |
| 698 |
| 699 if (!restore_old_session_cookies_) |
| 700 DeleteSessionCookiesOnStartup(); |
698 return true; | 701 return true; |
699 } | 702 } |
700 | 703 |
701 void SQLitePersistentCookieStore::Backend::ChainLoadCookies( | 704 void SQLitePersistentCookieStore::Backend::ChainLoadCookies( |
702 const LoadedCallback& loaded_callback) { | 705 const LoadedCallback& loaded_callback) { |
703 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); | 706 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
704 IncrementTimeDelta increment(&cookie_load_duration_); | 707 IncrementTimeDelta increment(&cookie_load_duration_); |
705 | 708 |
706 bool load_success = true; | 709 bool load_success = true; |
707 | 710 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 } | 1286 } |
1284 } | 1287 } |
1285 | 1288 |
1286 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() { | 1289 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() { |
1287 base::AutoLock locked(lock_); | 1290 base::AutoLock locked(lock_); |
1288 force_keep_session_state_ = true; | 1291 force_keep_session_state_ = true; |
1289 } | 1292 } |
1290 | 1293 |
1291 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() { | 1294 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() { |
1292 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); | 1295 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
1293 if (!db_->Execute("DELETE FROM cookies WHERE persistent == 0")) | 1296 if (!db_->Execute("DELETE FROM cookies WHERE persistent != 1")) |
1294 LOG(WARNING) << "Unable to delete session cookies."; | 1297 LOG(WARNING) << "Unable to delete session cookies."; |
1295 } | 1298 } |
1296 | 1299 |
1297 void SQLitePersistentCookieStore::Backend::PostBackgroundTask( | 1300 void SQLitePersistentCookieStore::Backend::PostBackgroundTask( |
1298 const tracked_objects::Location& origin, const base::Closure& task) { | 1301 const tracked_objects::Location& origin, const base::Closure& task) { |
1299 if (!background_task_runner_->PostTask(origin, task)) { | 1302 if (!background_task_runner_->PostTask(origin, task)) { |
1300 LOG(WARNING) << "Failed to post task from " << origin.ToString() | 1303 LOG(WARNING) << "Failed to post task from " << origin.ToString() |
1301 << " to background_task_runner_."; | 1304 << " to background_task_runner_."; |
1302 } | 1305 } |
1303 } | 1306 } |
1304 | 1307 |
1305 void SQLitePersistentCookieStore::Backend::PostClientTask( | 1308 void SQLitePersistentCookieStore::Backend::PostClientTask( |
1306 const tracked_objects::Location& origin, const base::Closure& task) { | 1309 const tracked_objects::Location& origin, const base::Closure& task) { |
1307 if (!client_task_runner_->PostTask(origin, task)) { | 1310 if (!client_task_runner_->PostTask(origin, task)) { |
1308 LOG(WARNING) << "Failed to post task from " << origin.ToString() | 1311 LOG(WARNING) << "Failed to post task from " << origin.ToString() |
1309 << " to client_task_runner_."; | 1312 << " to client_task_runner_."; |
1310 } | 1313 } |
1311 } | 1314 } |
1312 | 1315 |
1313 void SQLitePersistentCookieStore::Backend::FinishedLoadingCookies( | 1316 void SQLitePersistentCookieStore::Backend::FinishedLoadingCookies( |
1314 const LoadedCallback& loaded_callback, | 1317 const LoadedCallback& loaded_callback, |
1315 bool success) { | 1318 bool success) { |
1316 PostClientTask(FROM_HERE, base::Bind(&Backend::CompleteLoadInForeground, this, | 1319 PostClientTask(FROM_HERE, base::Bind(&Backend::CompleteLoadInForeground, this, |
1317 loaded_callback, success)); | 1320 loaded_callback, success)); |
1318 if (success && !restore_old_session_cookies_) | |
1319 DeleteSessionCookiesOnStartup(); | |
1320 } | 1321 } |
1321 | 1322 |
1322 SQLitePersistentCookieStore::SQLitePersistentCookieStore( | 1323 SQLitePersistentCookieStore::SQLitePersistentCookieStore( |
1323 const base::FilePath& path, | 1324 const base::FilePath& path, |
1324 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, | 1325 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, |
1325 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 1326 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
1326 bool restore_old_session_cookies, | 1327 bool restore_old_session_cookies, |
1327 storage::SpecialStoragePolicy* special_storage_policy, | 1328 storage::SpecialStoragePolicy* special_storage_policy, |
1328 net::CookieCryptoDelegate* crypto_delegate) | 1329 net::CookieCryptoDelegate* crypto_delegate) |
1329 : backend_(new Backend(path, | 1330 : backend_(new Backend(path, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 (config.session_cookie_mode == | 1434 (config.session_cookie_mode == |
1434 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { | 1435 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { |
1435 cookie_monster->SetPersistSessionCookies(true); | 1436 cookie_monster->SetPersistSessionCookies(true); |
1436 } | 1437 } |
1437 } | 1438 } |
1438 | 1439 |
1439 return cookie_monster; | 1440 return cookie_monster; |
1440 } | 1441 } |
1441 | 1442 |
1442 } // namespace content | 1443 } // namespace content |
OLD | NEW |