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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 if (!db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)")) | 424 if (!db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)")) |
425 return false; | 425 return false; |
426 | 426 |
427 return true; | 427 return true; |
428 } | 428 } |
429 | 429 |
430 } // namespace | 430 } // namespace |
431 | 431 |
432 void SQLitePersistentCookieStore::Backend::Load( | 432 void SQLitePersistentCookieStore::Backend::Load( |
433 const LoadedCallback& loaded_callback) { | 433 const LoadedCallback& loaded_callback) { |
434 // This function should be called only once per instance. | |
erikwright (departed)
2015/04/13 13:47:11
Why did this change?
erikchen
2015/04/27 22:00:13
I removed this change.
| |
435 DCHECK(!db_.get()); | |
436 PostBackgroundTask(FROM_HERE, base::Bind( | 434 PostBackgroundTask(FROM_HERE, base::Bind( |
437 &Backend::LoadAndNotifyInBackground, this, | 435 &Backend::LoadAndNotifyInBackground, this, |
438 loaded_callback, base::Time::Now())); | 436 loaded_callback, base::Time::Now())); |
439 } | 437 } |
440 | 438 |
441 void SQLitePersistentCookieStore::Backend::LoadCookiesForKey( | 439 void SQLitePersistentCookieStore::Backend::LoadCookiesForKey( |
442 const std::string& key, | 440 const std::string& key, |
443 const LoadedCallback& loaded_callback) { | 441 const LoadedCallback& loaded_callback) { |
444 { | 442 { |
445 base::AutoLock locked(metrics_lock_); | 443 base::AutoLock locked(metrics_lock_); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), | 673 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), |
676 50); | 674 50); |
677 | 675 |
678 UMA_HISTOGRAM_CUSTOM_TIMES( | 676 UMA_HISTOGRAM_CUSTOM_TIMES( |
679 "Cookie.TimeInitializeDomainMap", | 677 "Cookie.TimeInitializeDomainMap", |
680 base::Time::Now() - start, | 678 base::Time::Now() - start, |
681 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), | 679 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), |
682 50); | 680 50); |
683 | 681 |
684 initialized_ = true; | 682 initialized_ = true; |
683 | |
684 if (!restore_old_session_cookies_) | |
685 DeleteSessionCookiesOnStartup(); | |
686 | |
685 return true; | 687 return true; |
686 } | 688 } |
687 | 689 |
688 void SQLitePersistentCookieStore::Backend::ChainLoadCookies( | 690 void SQLitePersistentCookieStore::Backend::ChainLoadCookies( |
689 const LoadedCallback& loaded_callback) { | 691 const LoadedCallback& loaded_callback) { |
690 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); | 692 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
691 IncrementTimeDelta increment(&cookie_load_duration_); | 693 IncrementTimeDelta increment(&cookie_load_duration_); |
692 | 694 |
693 bool load_success = true; | 695 bool load_success = true; |
694 | 696 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 LOG(WARNING) << "Failed to post task from " << origin.ToString() | 1263 LOG(WARNING) << "Failed to post task from " << origin.ToString() |
1262 << " to client_task_runner_."; | 1264 << " to client_task_runner_."; |
1263 } | 1265 } |
1264 } | 1266 } |
1265 | 1267 |
1266 void SQLitePersistentCookieStore::Backend::FinishedLoadingCookies( | 1268 void SQLitePersistentCookieStore::Backend::FinishedLoadingCookies( |
1267 const LoadedCallback& loaded_callback, | 1269 const LoadedCallback& loaded_callback, |
1268 bool success) { | 1270 bool success) { |
1269 PostClientTask(FROM_HERE, base::Bind(&Backend::CompleteLoadInForeground, this, | 1271 PostClientTask(FROM_HERE, base::Bind(&Backend::CompleteLoadInForeground, this, |
1270 loaded_callback, success)); | 1272 loaded_callback, success)); |
1271 if (success && !restore_old_session_cookies_) | |
1272 DeleteSessionCookiesOnStartup(); | |
1273 } | 1273 } |
1274 | 1274 |
1275 SQLitePersistentCookieStore::SQLitePersistentCookieStore( | 1275 SQLitePersistentCookieStore::SQLitePersistentCookieStore( |
1276 const base::FilePath& path, | 1276 const base::FilePath& path, |
1277 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, | 1277 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, |
1278 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 1278 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
1279 bool restore_old_session_cookies, | 1279 bool restore_old_session_cookies, |
1280 storage::SpecialStoragePolicy* special_storage_policy, | 1280 storage::SpecialStoragePolicy* special_storage_policy, |
1281 net::CookieCryptoDelegate* crypto_delegate) | 1281 net::CookieCryptoDelegate* crypto_delegate) |
1282 : backend_(new Backend(path, | 1282 : backend_(new Backend(path, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 (config.session_cookie_mode == | 1386 (config.session_cookie_mode == |
1387 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { | 1387 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { |
1388 cookie_monster->SetPersistSessionCookies(true); | 1388 cookie_monster->SetPersistSessionCookies(true); |
1389 } | 1389 } |
1390 } | 1390 } |
1391 | 1391 |
1392 return cookie_monster; | 1392 return cookie_monster; |
1393 } | 1393 } |
1394 | 1394 |
1395 } // namespace content | 1395 } // namespace content |
OLD | NEW |