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

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

Issue 929303003: clang-formatting files in //net/cookies to clear up a diff. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « net/cookies/canonical_cookie_unittest.cc ('k') | net/cookies/cookie_monster.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 // Brought to you by the letter D and the number 2. 5 // Brought to you by the letter D and the number 2.
6 6
7 #ifndef NET_COOKIES_COOKIE_MONSTER_H_ 7 #ifndef NET_COOKIES_COOKIE_MONSTER_H_
8 #define NET_COOKIES_COOKIE_MONSTER_H_ 8 #define NET_COOKIES_COOKIE_MONSTER_H_
9 9
10 #include <deque> 10 #include <deque>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const std::string& name, 164 const std::string& name,
165 const std::string& value, 165 const std::string& value,
166 const std::string& domain, 166 const std::string& domain,
167 const std::string& path, 167 const std::string& path,
168 const base::Time& expiration_time, 168 const base::Time& expiration_time,
169 bool secure, 169 bool secure,
170 bool http_only, 170 bool http_only,
171 CookiePriority priority, 171 CookiePriority priority,
172 const SetCookiesCallback& callback); 172 const SetCookiesCallback& callback);
173 173
174
175 // Returns all the cookies, for use in management UI, etc. This does not mark 174 // Returns all the cookies, for use in management UI, etc. This does not mark
176 // the cookies as having been accessed. 175 // the cookies as having been accessed.
177 // The returned cookies are ordered by longest path, then by earliest 176 // The returned cookies are ordered by longest path, then by earliest
178 // creation date. 177 // creation date.
179 void GetAllCookiesAsync(const GetCookieListCallback& callback); 178 void GetAllCookiesAsync(const GetCookieListCallback& callback);
180 179
181 // Returns all the cookies, for use in management UI, etc. Filters results 180 // Returns all the cookies, for use in management UI, etc. Filters results
182 // using given url scheme, host / domain and path and options. This does not 181 // using given url scheme, host / domain and path and options. This does not
183 // mark the cookies as having been accessed. 182 // mark the cookies as having been accessed.
184 // The returned cookies are ordered by longest path, then earliest 183 // The returned cookies are ordered by longest path, then earliest
185 // creation date. 184 // creation date.
186 void GetAllCookiesForURLWithOptionsAsync( 185 void GetAllCookiesForURLWithOptionsAsync(
187 const GURL& url, 186 const GURL& url,
188 const CookieOptions& options, 187 const CookieOptions& options,
189 const GetCookieListCallback& callback); 188 const GetCookieListCallback& callback);
190 189
191 // Deletes all of the cookies. 190 // Deletes all of the cookies.
192 void DeleteAllAsync(const DeleteCallback& callback); 191 void DeleteAllAsync(const DeleteCallback& callback);
193 192
194 // Deletes all cookies that match the host of the given URL 193 // Deletes all cookies that match the host of the given URL
195 // regardless of path. This includes all http_only and secure cookies, 194 // regardless of path. This includes all http_only and secure cookies,
196 // but does not include any domain cookies that may apply to this host. 195 // but does not include any domain cookies that may apply to this host.
197 // Returns the number of cookies deleted. 196 // Returns the number of cookies deleted.
198 void DeleteAllForHostAsync(const GURL& url, 197 void DeleteAllForHostAsync(const GURL& url, const DeleteCallback& callback);
199 const DeleteCallback& callback);
200 198
201 // Deletes one specific cookie. 199 // Deletes one specific cookie.
202 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, 200 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie,
203 const DeleteCookieCallback& callback); 201 const DeleteCookieCallback& callback);
204 202
205 // Checks whether for a given ETLD+1, there currently exist any cookies. 203 // Checks whether for a given ETLD+1, there currently exist any cookies.
206 void HasCookiesForETLDP1Async(const std::string& etldp1, 204 void HasCookiesForETLDP1Async(const std::string& etldp1,
207 const HasCookiesForETLDP1Callback& callback); 205 const HasCookiesForETLDP1Callback& callback);
208 206
209 // Resets the list of cookieable schemes to the supplied schemes. 207 // Resets the list of cookieable schemes to the supplied schemes.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 scoped_ptr<CookieChangedSubscription> AddCallbackForCookie( 316 scoped_ptr<CookieChangedSubscription> AddCallbackForCookie(
319 const GURL& url, 317 const GURL& url,
320 const std::string& name, 318 const std::string& name,
321 const CookieChangedCallback& callback) override; 319 const CookieChangedCallback& callback) override;
322 320
323 bool loaded(); 321 bool loaded();
324 322
325 private: 323 private:
326 // For queueing the cookie monster calls. 324 // For queueing the cookie monster calls.
327 class CookieMonsterTask; 325 class CookieMonsterTask;
328 template <typename Result> class DeleteTask; 326 template <typename Result>
327 class DeleteTask;
329 class DeleteAllCreatedBetweenTask; 328 class DeleteAllCreatedBetweenTask;
330 class DeleteAllCreatedBetweenForHostTask; 329 class DeleteAllCreatedBetweenForHostTask;
331 class DeleteAllForHostTask; 330 class DeleteAllForHostTask;
332 class DeleteAllTask; 331 class DeleteAllTask;
333 class DeleteCookieTask; 332 class DeleteCookieTask;
334 class DeleteCanonicalCookieTask; 333 class DeleteCanonicalCookieTask;
335 class GetAllCookiesForURLWithOptionsTask; 334 class GetAllCookiesForURLWithOptionsTask;
336 class GetAllCookiesTask; 335 class GetAllCookiesTask;
337 class GetCookiesWithOptionsTask; 336 class GetCookiesWithOptionsTask;
338 class SetCookieWithDetailsTask; 337 class SetCookieWithDetailsTask;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // was invoked and is used for reporting histogram_time_blocked_on_load_. 487 // was invoked and is used for reporting histogram_time_blocked_on_load_.
489 // See PersistentCookieStore::Load for details on the contents of cookies. 488 // See PersistentCookieStore::Load for details on the contents of cookies.
490 void OnLoaded(base::TimeTicks beginning_time, 489 void OnLoaded(base::TimeTicks beginning_time,
491 const std::vector<CanonicalCookie*>& cookies); 490 const std::vector<CanonicalCookie*>& cookies);
492 491
493 // Stores cookies loaded from the backing store and invokes the deferred 492 // Stores cookies loaded from the backing store and invokes the deferred
494 // task(s) pending loading of cookies associated with the domain key 493 // task(s) pending loading of cookies associated with the domain key
495 // (eTLD+1). Called when all cookies for the domain key(eTLD+1) have been 494 // (eTLD+1). Called when all cookies for the domain key(eTLD+1) have been
496 // loaded from DB. See PersistentCookieStore::Load for details on the contents 495 // loaded from DB. See PersistentCookieStore::Load for details on the contents
497 // of cookies. 496 // of cookies.
498 void OnKeyLoaded( 497 void OnKeyLoaded(const std::string& key,
499 const std::string& key, 498 const std::vector<CanonicalCookie*>& cookies);
500 const std::vector<CanonicalCookie*>& cookies);
501 499
502 // Stores the loaded cookies. 500 // Stores the loaded cookies.
503 void StoreLoadedCookies(const std::vector<CanonicalCookie*>& cookies); 501 void StoreLoadedCookies(const std::vector<CanonicalCookie*>& cookies);
504 502
505 // Invokes deferred calls. 503 // Invokes deferred calls.
506 void InvokeQueue(); 504 void InvokeQueue();
507 505
508 // Checks that |cookies_| matches our invariants, and tries to repair any 506 // Checks that |cookies_| matches our invariants, and tries to repair any
509 // inconsistencies. (In other words, it does not have duplicate cookies). 507 // inconsistencies. (In other words, it does not have duplicate cookies).
510 void EnsureCookiesMapIsValid(); 508 void EnsureCookiesMapIsValid();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 const base::Time& creation_time, 559 const base::Time& creation_time,
562 const CookieOptions& options); 560 const CookieOptions& options);
563 561
564 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, 562 void InternalUpdateCookieAccessTime(CanonicalCookie* cc,
565 const base::Time& current_time); 563 const base::Time& current_time);
566 564
567 // |deletion_cause| argument is used for collecting statistics and choosing 565 // |deletion_cause| argument is used for collecting statistics and choosing
568 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged 566 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged
569 // notifications. Guarantee: All iterators to cookies_ except to the 567 // notifications. Guarantee: All iterators to cookies_ except to the
570 // deleted entry remain vaild. 568 // deleted entry remain vaild.
571 void InternalDeleteCookie(CookieMap::iterator it, bool sync_to_store, 569 void InternalDeleteCookie(CookieMap::iterator it,
570 bool sync_to_store,
572 DeletionCause deletion_cause); 571 DeletionCause deletion_cause);
573 572
574 // If the number of cookies for CookieMap key |key|, or globally, are 573 // If the number of cookies for CookieMap key |key|, or globally, are
575 // over the preset maximums above, garbage collect, first for the host and 574 // over the preset maximums above, garbage collect, first for the host and
576 // then globally. See comments above garbage collection threshold 575 // then globally. See comments above garbage collection threshold
577 // constants for details. 576 // constants for details.
578 // 577 //
579 // Returns the number of cookies deleted (useful for debugging). 578 // Returns the number of cookies deleted (useful for debugging).
580 int GarbageCollect(const base::Time& current, const std::string& key); 579 int GarbageCollect(const base::Time& current, const std::string& key);
581 580
(...skipping 29 matching lines...) Expand all
611 // ugly and increment when we've seen the same time twice. 610 // ugly and increment when we've seen the same time twice.
612 base::Time CurrentTime(); 611 base::Time CurrentTime();
613 612
614 // Runs the task if, or defers the task until, the full cookie database is 613 // Runs the task if, or defers the task until, the full cookie database is
615 // loaded. 614 // loaded.
616 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item); 615 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item);
617 616
618 // Runs the task if, or defers the task until, the cookies for the given URL 617 // Runs the task if, or defers the task until, the cookies for the given URL
619 // are loaded. 618 // are loaded.
620 void DoCookieTaskForURL(const scoped_refptr<CookieMonsterTask>& task_item, 619 void DoCookieTaskForURL(const scoped_refptr<CookieMonsterTask>& task_item,
621 const GURL& url); 620 const GURL& url);
622 621
623 // Run all cookie changed callbacks that are monitoring |cookie|. 622 // Run all cookie changed callbacks that are monitoring |cookie|.
624 // |removed| is true if the cookie was deleted. 623 // |removed| is true if the cookie was deleted.
625 void RunCallbacks(const CanonicalCookie& cookie, bool removed); 624 void RunCallbacks(const CanonicalCookie& cookie, bool removed);
626 625
627 // Histogram variables; see CookieMonster::InitializeHistograms() in 626 // Histogram variables; see CookieMonster::InitializeHistograms() in
628 // cookie_monster.cc for details. 627 // cookie_monster.cc for details.
629 base::HistogramBase* histogram_expiration_duration_minutes_; 628 base::HistogramBase* histogram_expiration_duration_minutes_;
630 base::HistogramBase* histogram_between_access_interval_minutes_; 629 base::HistogramBase* histogram_between_access_interval_minutes_;
631 base::HistogramBase* histogram_evicted_last_access_minutes_; 630 base::HistogramBase* histogram_evicted_last_access_minutes_;
(...skipping 15 matching lines...) Expand all
647 // Indicates whether loading from the backend store is completed and 646 // Indicates whether loading from the backend store is completed and
648 // calls may be immediately processed. 647 // calls may be immediately processed.
649 bool loaded_; 648 bool loaded_;
650 649
651 // List of domain keys that have been loaded from the DB. 650 // List of domain keys that have been loaded from the DB.
652 std::set<std::string> keys_loaded_; 651 std::set<std::string> keys_loaded_;
653 652
654 // Map of domain keys to their associated task queues. These tasks are blocked 653 // Map of domain keys to their associated task queues. These tasks are blocked
655 // until all cookies for the associated domain key eTLD+1 are loaded from the 654 // until all cookies for the associated domain key eTLD+1 are loaded from the
656 // backend store. 655 // backend store.
657 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > > 656 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask>>>
658 tasks_pending_for_key_; 657 tasks_pending_for_key_;
659 658
660 // Queues tasks that are blocked until all cookies are loaded from the backend 659 // Queues tasks that are blocked until all cookies are loaded from the backend
661 // store. 660 // store.
662 std::queue<scoped_refptr<CookieMonsterTask> > tasks_pending_; 661 std::queue<scoped_refptr<CookieMonsterTask>> tasks_pending_;
663 662
664 scoped_refptr<PersistentCookieStore> store_; 663 scoped_refptr<PersistentCookieStore> store_;
665 664
666 base::Time last_time_seen_; 665 base::Time last_time_seen_;
667 666
668 // Minimum delay after updating a cookie's LastAccessDate before we will 667 // Minimum delay after updating a cookie's LastAccessDate before we will
669 // update it again. 668 // update it again.
670 const base::TimeDelta last_access_threshold_; 669 const base::TimeDelta last_access_threshold_;
671 670
672 // Approximate date of access time of least recently accessed cookie 671 // Approximate date of access time of least recently accessed cookie
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 virtual ~PersistentCookieStore() {} 786 virtual ~PersistentCookieStore() {}
788 787
789 private: 788 private:
790 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 789 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
791 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 790 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
792 }; 791 };
793 792
794 } // namespace net 793 } // namespace net
795 794
796 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 795 #endif // NET_COOKIES_COOKIE_MONSTER_H_
OLDNEW
« no previous file with comments | « net/cookies/canonical_cookie_unittest.cc ('k') | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698