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

Side by Side Diff: net/cookies/cookie_monster.cc

Issue 2874973002: Flush Channel IDs when Cookies get saved to a persistent backend (Closed)
Patch Set: clean up a few things Created 3 years, 7 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
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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "base/metrics/histogram.h" 59 #include "base/metrics/histogram.h"
60 #include "base/profiler/scoped_tracker.h" 60 #include "base/profiler/scoped_tracker.h"
61 #include "base/single_thread_task_runner.h" 61 #include "base/single_thread_task_runner.h"
62 #include "base/strings/string_util.h" 62 #include "base/strings/string_util.h"
63 #include "base/strings/stringprintf.h" 63 #include "base/strings/stringprintf.h"
64 #include "base/threading/thread_task_runner_handle.h" 64 #include "base/threading/thread_task_runner_handle.h"
65 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 65 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
66 #include "net/cookies/canonical_cookie.h" 66 #include "net/cookies/canonical_cookie.h"
67 #include "net/cookies/cookie_util.h" 67 #include "net/cookies/cookie_util.h"
68 #include "net/cookies/parsed_cookie.h" 68 #include "net/cookies/parsed_cookie.h"
69 #include "net/ssl/channel_id_service.h"
69 #include "url/origin.h" 70 #include "url/origin.h"
70 71
71 using base::Time; 72 using base::Time;
72 using base::TimeDelta; 73 using base::TimeDelta;
73 using base::TimeTicks; 74 using base::TimeTicks;
74 75
75 // In steady state, most cookie requests can be satisfied by the in memory 76 // In steady state, most cookie requests can be satisfied by the in memory
76 // cookie monster store. If the cookie request cannot be satisfied by the in 77 // cookie monster store. If the cookie request cannot be satisfied by the in
77 // memory store, the relevant cookies must be fetched from the persistent 78 // memory store, the relevant cookies must be fetched from the persistent
78 // store. The task is queued in CookieMonster::tasks_pending_ if it requires 79 // store. The task is queued in CookieMonster::tasks_pending_ if it requires
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 return cookies_count; 341 return cookies_count;
341 } 342 }
342 343
343 } // namespace 344 } // namespace
344 345
345 CookieMonster::CookieMonster(PersistentCookieStore* store, 346 CookieMonster::CookieMonster(PersistentCookieStore* store,
346 CookieMonsterDelegate* delegate) 347 CookieMonsterDelegate* delegate)
347 : CookieMonster( 348 : CookieMonster(
348 store, 349 store,
349 delegate, 350 delegate,
351 nullptr,
352 base::TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) {}
353
354 CookieMonster::CookieMonster(PersistentCookieStore* store,
355 CookieMonsterDelegate* delegate,
356 ChannelIDService* channel_id_service)
357 : CookieMonster(
358 store,
359 delegate,
360 nullptr,
350 base::TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) {} 361 base::TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) {}
351 362
352 CookieMonster::CookieMonster(PersistentCookieStore* store, 363 CookieMonster::CookieMonster(PersistentCookieStore* store,
353 CookieMonsterDelegate* delegate, 364 CookieMonsterDelegate* delegate,
354 base::TimeDelta last_access_threshold) 365 base::TimeDelta last_access_threshold)
366 : CookieMonster(store, delegate, nullptr, last_access_threshold) {}
367
368 CookieMonster::CookieMonster(PersistentCookieStore* store,
369 CookieMonsterDelegate* delegate,
370 ChannelIDService* channel_id_service,
371 base::TimeDelta last_access_threshold)
355 : initialized_(false), 372 : initialized_(false),
356 started_fetching_all_cookies_(false), 373 started_fetching_all_cookies_(false),
357 finished_fetching_all_cookies_(false), 374 finished_fetching_all_cookies_(false),
358 fetch_strategy_(kUnknownFetch), 375 fetch_strategy_(kUnknownFetch),
359 seen_global_task_(false), 376 seen_global_task_(false),
360 store_(store), 377 store_(store),
361 last_access_threshold_(last_access_threshold), 378 last_access_threshold_(last_access_threshold),
362 delegate_(delegate), 379 delegate_(delegate),
380 channel_id_service_(channel_id_service),
363 last_statistic_record_time_(base::Time::Now()), 381 last_statistic_record_time_(base::Time::Now()),
364 persist_session_cookies_(false), 382 persist_session_cookies_(false),
365 weak_ptr_factory_(this) { 383 weak_ptr_factory_(this) {
366 InitializeHistograms(); 384 InitializeHistograms();
367 cookieable_schemes_.insert( 385 cookieable_schemes_.insert(
368 cookieable_schemes_.begin(), kDefaultCookieableSchemes, 386 cookieable_schemes_.begin(), kDefaultCookieableSchemes,
369 kDefaultCookieableSchemes + kDefaultCookieableSchemesCount); 387 kDefaultCookieableSchemes + kDefaultCookieableSchemesCount);
370 } 388 }
371 389
372 // Task classes for queueing the coming request. 390 // Task classes for queueing the coming request.
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 const SetCookiesCallback& callback) { 873 const SetCookiesCallback& callback) {
856 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( 874 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask(
857 this, url, name, value, domain, path, creation_time, expiration_time, 875 this, url, name, value, domain, path, creation_time, expiration_time,
858 last_access_time, secure, http_only, same_site, priority, callback); 876 last_access_time, secure, http_only, same_site, priority, callback);
859 DoCookieTaskForURL(task, url); 877 DoCookieTaskForURL(task, url);
860 } 878 }
861 879
862 void CookieMonster::FlushStore(const base::Closure& callback) { 880 void CookieMonster::FlushStore(const base::Closure& callback) {
863 DCHECK(thread_checker_.CalledOnValidThread()); 881 DCHECK(thread_checker_.CalledOnValidThread());
864 882
865 if (initialized_ && store_.get()) 883 if (initialized_ && store_.get()) {
884 if (channel_id_service_) {
885 channel_id_service_->GetChannelIDStore()->Flush();
mattm 2017/05/12 00:02:47 What thread is this getting run on? It's unclear b
nharper 2017/05/12 02:47:23 I changed this to do a PostTask on the background_
886 }
866 store_->Flush(callback); 887 store_->Flush(callback);
867 else if (!callback.is_null()) 888 } else if (!callback.is_null()) {
868 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 889 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
890 }
869 } 891 }
870 892
871 void CookieMonster::SetForceKeepSessionState() { 893 void CookieMonster::SetForceKeepSessionState() {
872 DCHECK(thread_checker_.CalledOnValidThread()); 894 DCHECK(thread_checker_.CalledOnValidThread());
873 895
874 if (store_) 896 if (store_)
875 store_->SetForceKeepSessionState(); 897 store_->SetForceKeepSessionState();
876 } 898 }
877 899
878 void CookieMonster::SetAllCookiesAsync(const CookieList& list, 900 void CookieMonster::SetAllCookiesAsync(const CookieList& list,
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 it != hook_map_.end(); ++it) { 2390 it != hook_map_.end(); ++it) {
2369 std::pair<GURL, std::string> key = it->first; 2391 std::pair<GURL, std::string> key = it->first;
2370 if (cookie.IncludeForRequestURL(key.first, opts) && 2392 if (cookie.IncludeForRequestURL(key.first, opts) &&
2371 cookie.Name() == key.second) { 2393 cookie.Name() == key.second) {
2372 it->second->Notify(cookie, cause); 2394 it->second->Notify(cookie, cause);
2373 } 2395 }
2374 } 2396 }
2375 } 2397 }
2376 2398
2377 } // namespace net 2399 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698