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

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

Issue 1052373003: Add Finch experiment to cookie monster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | net/cookies/cookie_monster.h » ('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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
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 16 matching lines...) Expand all
462 UMA_HISTOGRAM_CUSTOM_TIMES( 460 UMA_HISTOGRAM_CUSTOM_TIMES(
463 "Cookie.TimeLoadDBQueueWait", 461 "Cookie.TimeLoadDBQueueWait",
464 base::Time::Now() - posted_at, 462 base::Time::Now() - posted_at,
465 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 463 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
466 50); 464 50);
467 465
468 if (!InitializeDatabase()) { 466 if (!InitializeDatabase()) {
469 PostClientTask(FROM_HERE, base::Bind( 467 PostClientTask(FROM_HERE, base::Bind(
470 &Backend::CompleteLoadInForeground, this, loaded_callback, false)); 468 &Backend::CompleteLoadInForeground, this, loaded_callback, false));
471 } else { 469 } else {
470 if (!restore_old_session_cookies_)
471 DeleteSessionCookiesOnStartup();
erikwright (departed) 2015/04/07 22:37:09 Isn't this ineffective here? I would think it shou
472 ChainLoadCookies(loaded_callback); 472 ChainLoadCookies(loaded_callback);
473 } 473 }
474 } 474 }
475 475
476 void SQLitePersistentCookieStore::Backend::LoadKeyAndNotifyInBackground( 476 void SQLitePersistentCookieStore::Backend::LoadKeyAndNotifyInBackground(
477 const std::string& key, 477 const std::string& key,
478 const LoadedCallback& loaded_callback, 478 const LoadedCallback& loaded_callback,
479 const base::Time& posted_at) { 479 const base::Time& posted_at) {
480 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 480 DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
481 IncrementTimeDelta increment(&cookie_load_duration_); 481 IncrementTimeDelta increment(&cookie_load_duration_);
482 482
483 UMA_HISTOGRAM_CUSTOM_TIMES( 483 UMA_HISTOGRAM_CUSTOM_TIMES(
484 "Cookie.TimeKeyLoadDBQueueWait", 484 "Cookie.TimeKeyLoadDBQueueWait",
485 base::Time::Now() - posted_at, 485 base::Time::Now() - posted_at,
486 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 486 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
487 50); 487 50);
488 488
489 bool success = false; 489 bool success = false;
490 if (InitializeDatabase()) { 490 if (InitializeDatabase()) {
491 if (!restore_old_session_cookies_)
492 DeleteSessionCookiesOnStartup();
erikwright (departed) 2015/04/07 22:37:09 This makes me think that, in fact, we have a bug a
erikchen 2015/04/08 17:44:26 I agree that the previous behavior was incorrect.
491 std::map<std::string, std::set<std::string> >::iterator 493 std::map<std::string, std::set<std::string> >::iterator
492 it = keys_to_load_.find(key); 494 it = keys_to_load_.find(key);
493 if (it != keys_to_load_.end()) { 495 if (it != keys_to_load_.end()) {
494 success = LoadCookiesForDomains(it->second); 496 success = LoadCookiesForDomains(it->second);
495 keys_to_load_.erase(it); 497 keys_to_load_.erase(it);
496 } else { 498 } else {
497 success = true; 499 success = true;
498 } 500 }
499 } 501 }
500 502
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | net/cookies/cookie_monster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698