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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 const std::string& name, 163 const std::string& name,
164 const std::string& value, 164 const std::string& value,
165 const std::string& domain, 165 const std::string& domain,
166 const std::string& path, 166 const std::string& path,
167 const base::Time& expiration_time, 167 const base::Time& expiration_time,
168 bool secure, 168 bool secure,
169 bool http_only, 169 bool http_only,
170 CookiePriority priority, 170 CookiePriority priority,
171 const SetCookiesCallback& callback); 171 const SetCookiesCallback& callback);
172 172
173
174 // Returns all the cookies, for use in management UI, etc. This does not mark 173 // Returns all the cookies, for use in management UI, etc. This does not mark
175 // the cookies as having been accessed. 174 // the cookies as having been accessed.
176 // The returned cookies are ordered by longest path, then by earliest 175 // The returned cookies are ordered by longest path, then by earliest
177 // creation date. 176 // creation date.
178 void GetAllCookiesAsync(const GetCookieListCallback& callback); 177 void GetAllCookiesAsync(const GetCookieListCallback& callback);
179 178
180 // Returns all the cookies, for use in management UI, etc. Filters results 179 // Returns all the cookies, for use in management UI, etc. Filters results
181 // using given url scheme, host / domain and path and options. This does not 180 // using given url scheme, host / domain and path and options. This does not
182 // mark the cookies as having been accessed. 181 // mark the cookies as having been accessed.
183 // The returned cookies are ordered by longest path, then earliest 182 // The returned cookies are ordered by longest path, then earliest
184 // creation date. 183 // creation date.
185 void GetAllCookiesForURLWithOptionsAsync( 184 void GetAllCookiesForURLWithOptionsAsync(
186 const GURL& url, 185 const GURL& url,
187 const CookieOptions& options, 186 const CookieOptions& options,
188 const GetCookieListCallback& callback); 187 const GetCookieListCallback& callback);
189 188
190 // Deletes all of the cookies. 189 // Deletes all of the cookies.
191 void DeleteAllAsync(const DeleteCallback& callback); 190 void DeleteAllAsync(const DeleteCallback& callback);
192 191
193 // Deletes all cookies that match the host of the given URL 192 // Deletes all cookies that match the host of the given URL
194 // regardless of path. This includes all http_only and secure cookies, 193 // regardless of path. This includes all http_only and secure cookies,
195 // but does not include any domain cookies that may apply to this host. 194 // but does not include any domain cookies that may apply to this host.
196 // Returns the number of cookies deleted. 195 // Returns the number of cookies deleted.
197 void DeleteAllForHostAsync(const GURL& url, 196 void DeleteAllForHostAsync(const GURL& url, const DeleteCallback& callback);
198 const DeleteCallback& callback);
199 197
200 // Deletes one specific cookie. 198 // Deletes one specific cookie.
201 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, 199 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie,
202 const DeleteCookieCallback& callback); 200 const DeleteCookieCallback& callback);
203 201
204 // Checks whether for a given ETLD+1, there currently exist any cookies. 202 // Checks whether for a given ETLD+1, there currently exist any cookies.
205 void HasCookiesForETLDP1Async(const std::string& etldp1, 203 void HasCookiesForETLDP1Async(const std::string& etldp1,
206 const HasCookiesForETLDP1Callback& callback); 204 const HasCookiesForETLDP1Callback& callback);
207 205
208 // Resets the list of cookieable schemes to the supplied schemes. 206 // Resets the list of cookieable schemes to the supplied schemes.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 const CookieOptions& options, 250 const CookieOptions& options,
253 const GetCookiesCallback& callback) OVERRIDE; 251 const GetCookiesCallback& callback) OVERRIDE;
254 252
255 // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP 253 // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP
256 // only cookies. 254 // only cookies.
257 virtual void GetAllCookiesForURLAsync( 255 virtual void GetAllCookiesForURLAsync(
258 const GURL& url, 256 const GURL& url,
259 const GetCookieListCallback& callback) OVERRIDE; 257 const GetCookieListCallback& callback) OVERRIDE;
260 258
261 // Deletes all cookies with that might apply to |url| that has |cookie_name|. 259 // Deletes all cookies with that might apply to |url| that has |cookie_name|.
262 virtual void DeleteCookieAsync( 260 virtual void DeleteCookieAsync(const GURL& url,
263 const GURL& url, const std::string& cookie_name, 261 const std::string& cookie_name,
264 const base::Closure& callback) OVERRIDE; 262 const base::Closure& callback) OVERRIDE;
265 263
266 // Deletes all of the cookies that have a creation_date greater than or equal 264 // Deletes all of the cookies that have a creation_date greater than or equal
267 // to |delete_begin| and less than |delete_end|. 265 // to |delete_begin| and less than |delete_end|.
268 // Returns the number of cookies that have been deleted. 266 // Returns the number of cookies that have been deleted.
269 virtual void DeleteAllCreatedBetweenAsync( 267 virtual void DeleteAllCreatedBetweenAsync(
270 const base::Time& delete_begin, 268 const base::Time& delete_begin,
271 const base::Time& delete_end, 269 const base::Time& delete_end,
272 const DeleteCallback& callback) OVERRIDE; 270 const DeleteCallback& callback) OVERRIDE;
273 271
274 // Deletes all of the cookies that match the host of the given URL 272 // Deletes all of the cookies that match the host of the given URL
(...skipping 28 matching lines...) Expand all
303 // stored for. 301 // stored for.
304 bool IsCookieableScheme(const std::string& scheme); 302 bool IsCookieableScheme(const std::string& scheme);
305 303
306 // The default list of schemes the cookie monster can handle. 304 // The default list of schemes the cookie monster can handle.
307 static const char* kDefaultCookieableSchemes[]; 305 static const char* kDefaultCookieableSchemes[];
308 static const int kDefaultCookieableSchemesCount; 306 static const int kDefaultCookieableSchemesCount;
309 307
310 private: 308 private:
311 // For queueing the cookie monster calls. 309 // For queueing the cookie monster calls.
312 class CookieMonsterTask; 310 class CookieMonsterTask;
313 template <typename Result> class DeleteTask; 311 template <typename Result>
312 class DeleteTask;
314 class DeleteAllCreatedBetweenTask; 313 class DeleteAllCreatedBetweenTask;
315 class DeleteAllCreatedBetweenForHostTask; 314 class DeleteAllCreatedBetweenForHostTask;
316 class DeleteAllForHostTask; 315 class DeleteAllForHostTask;
317 class DeleteAllTask; 316 class DeleteAllTask;
318 class DeleteCookieTask; 317 class DeleteCookieTask;
319 class DeleteCanonicalCookieTask; 318 class DeleteCanonicalCookieTask;
320 class GetAllCookiesForURLWithOptionsTask; 319 class GetAllCookiesForURLWithOptionsTask;
321 class GetAllCookiesTask; 320 class GetAllCookiesTask;
322 class GetCookiesWithOptionsTask; 321 class GetCookiesWithOptionsTask;
323 class SetCookieWithDetailsTask; 322 class SetCookieWithDetailsTask;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE, 375 DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE,
377 376
378 // A common idiom is to remove a cookie by overwriting it with an 377 // A common idiom is to remove a cookie by overwriting it with an
379 // already-expired expiration date. This captures that case. 378 // already-expired expiration date. This captures that case.
380 DELETE_COOKIE_EXPIRED_OVERWRITE, 379 DELETE_COOKIE_EXPIRED_OVERWRITE,
381 380
382 // Cookies are not allowed to contain control characters in the name or 381 // Cookies are not allowed to contain control characters in the name or
383 // value. However, we used to allow them, so we are now evicting any such 382 // value. However, we used to allow them, so we are now evicting any such
384 // cookies as we load them. See http://crbug.com/238041. 383 // cookies as we load them. See http://crbug.com/238041.
385 DELETE_COOKIE_CONTROL_CHAR, 384 DELETE_COOKIE_CONTROL_CHAR,
386
387 DELETE_COOKIE_LAST_ENTRY 385 DELETE_COOKIE_LAST_ENTRY
388 }; 386 };
389 387
390 // The number of days since last access that cookies will not be subject 388 // The number of days since last access that cookies will not be subject
391 // to global garbage collection. 389 // to global garbage collection.
392 static const int kSafeFromGlobalPurgeDays; 390 static const int kSafeFromGlobalPurgeDays;
393 391
394 // Record statistics every kRecordStatisticsIntervalSeconds of uptime. 392 // Record statistics every kRecordStatisticsIntervalSeconds of uptime.
395 static const int kRecordStatisticsIntervalSeconds = 10 * 60; 393 static const int kRecordStatisticsIntervalSeconds = 10 * 60;
396 394
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // was invoked and is used for reporting histogram_time_blocked_on_load_. 467 // was invoked and is used for reporting histogram_time_blocked_on_load_.
470 // See PersistentCookieStore::Load for details on the contents of cookies. 468 // See PersistentCookieStore::Load for details on the contents of cookies.
471 void OnLoaded(base::TimeTicks beginning_time, 469 void OnLoaded(base::TimeTicks beginning_time,
472 const std::vector<CanonicalCookie*>& cookies); 470 const std::vector<CanonicalCookie*>& cookies);
473 471
474 // Stores cookies loaded from the backing store and invokes the deferred 472 // Stores cookies loaded from the backing store and invokes the deferred
475 // task(s) pending loading of cookies associated with the domain key 473 // task(s) pending loading of cookies associated with the domain key
476 // (eTLD+1). Called when all cookies for the domain key(eTLD+1) have been 474 // (eTLD+1). Called when all cookies for the domain key(eTLD+1) have been
477 // loaded from DB. See PersistentCookieStore::Load for details on the contents 475 // loaded from DB. See PersistentCookieStore::Load for details on the contents
478 // of cookies. 476 // of cookies.
479 void OnKeyLoaded( 477 void OnKeyLoaded(const std::string& key,
480 const std::string& key, 478 const std::vector<CanonicalCookie*>& cookies);
481 const std::vector<CanonicalCookie*>& cookies);
482 479
483 // Stores the loaded cookies. 480 // Stores the loaded cookies.
484 void StoreLoadedCookies(const std::vector<CanonicalCookie*>& cookies); 481 void StoreLoadedCookies(const std::vector<CanonicalCookie*>& cookies);
485 482
486 // Invokes deferred calls. 483 // Invokes deferred calls.
487 void InvokeQueue(); 484 void InvokeQueue();
488 485
489 // Checks that |cookies_| matches our invariants, and tries to repair any 486 // Checks that |cookies_| matches our invariants, and tries to repair any
490 // inconsistencies. (In other words, it does not have duplicate cookies). 487 // inconsistencies. (In other words, it does not have duplicate cookies).
491 void EnsureCookiesMapIsValid(); 488 void EnsureCookiesMapIsValid();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 const base::Time& creation_time, 539 const base::Time& creation_time,
543 const CookieOptions& options); 540 const CookieOptions& options);
544 541
545 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, 542 void InternalUpdateCookieAccessTime(CanonicalCookie* cc,
546 const base::Time& current_time); 543 const base::Time& current_time);
547 544
548 // |deletion_cause| argument is used for collecting statistics and choosing 545 // |deletion_cause| argument is used for collecting statistics and choosing
549 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged 546 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged
550 // notifications. Guarantee: All iterators to cookies_ except to the 547 // notifications. Guarantee: All iterators to cookies_ except to the
551 // deleted entry remain vaild. 548 // deleted entry remain vaild.
552 void InternalDeleteCookie(CookieMap::iterator it, bool sync_to_store, 549 void InternalDeleteCookie(CookieMap::iterator it,
550 bool sync_to_store,
553 DeletionCause deletion_cause); 551 DeletionCause deletion_cause);
554 552
555 // If the number of cookies for CookieMap key |key|, or globally, are 553 // If the number of cookies for CookieMap key |key|, or globally, are
556 // over the preset maximums above, garbage collect, first for the host and 554 // over the preset maximums above, garbage collect, first for the host and
557 // then globally. See comments above garbage collection threshold 555 // then globally. See comments above garbage collection threshold
558 // constants for details. 556 // constants for details.
559 // 557 //
560 // Returns the number of cookies deleted (useful for debugging). 558 // Returns the number of cookies deleted (useful for debugging).
561 int GarbageCollect(const base::Time& current, const std::string& key); 559 int GarbageCollect(const base::Time& current, const std::string& key);
562 560
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 // ugly and increment when we've seen the same time twice. 594 // ugly and increment when we've seen the same time twice.
597 base::Time CurrentTime(); 595 base::Time CurrentTime();
598 596
599 // Runs the task if, or defers the task until, the full cookie database is 597 // Runs the task if, or defers the task until, the full cookie database is
600 // loaded. 598 // loaded.
601 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item); 599 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item);
602 600
603 // Runs the task if, or defers the task until, the cookies for the given URL 601 // Runs the task if, or defers the task until, the cookies for the given URL
604 // are loaded. 602 // are loaded.
605 void DoCookieTaskForURL(const scoped_refptr<CookieMonsterTask>& task_item, 603 void DoCookieTaskForURL(const scoped_refptr<CookieMonsterTask>& task_item,
606 const GURL& url); 604 const GURL& url);
607 605
608 // Histogram variables; see CookieMonster::InitializeHistograms() in 606 // Histogram variables; see CookieMonster::InitializeHistograms() in
609 // cookie_monster.cc for details. 607 // cookie_monster.cc for details.
610 base::HistogramBase* histogram_expiration_duration_minutes_; 608 base::HistogramBase* histogram_expiration_duration_minutes_;
611 base::HistogramBase* histogram_between_access_interval_minutes_; 609 base::HistogramBase* histogram_between_access_interval_minutes_;
612 base::HistogramBase* histogram_evicted_last_access_minutes_; 610 base::HistogramBase* histogram_evicted_last_access_minutes_;
613 base::HistogramBase* histogram_count_; 611 base::HistogramBase* histogram_count_;
614 base::HistogramBase* histogram_domain_count_; 612 base::HistogramBase* histogram_domain_count_;
615 base::HistogramBase* histogram_etldp1_count_; 613 base::HistogramBase* histogram_etldp1_count_;
616 base::HistogramBase* histogram_domain_per_etldp1_count_; 614 base::HistogramBase* histogram_domain_per_etldp1_count_;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // added, and |cause| will be set to CHANGE_COOKIE_EXPLICIT. 711 // added, and |cause| will be set to CHANGE_COOKIE_EXPLICIT.
714 // 712 //
715 // As a special case, note that updating a cookie's properties is implemented 713 // As a special case, note that updating a cookie's properties is implemented
716 // as a two step process: the cookie to be updated is first removed entirely, 714 // as a two step process: the cookie to be updated is first removed entirely,
717 // generating a notification with cause CHANGE_COOKIE_OVERWRITE. Afterwards, 715 // generating a notification with cause CHANGE_COOKIE_OVERWRITE. Afterwards,
718 // a new cookie is written with the updated values, generating a notification 716 // a new cookie is written with the updated values, generating a notification
719 // with cause CHANGE_COOKIE_EXPLICIT. 717 // with cause CHANGE_COOKIE_EXPLICIT.
720 virtual void OnCookieChanged(const CanonicalCookie& cookie, 718 virtual void OnCookieChanged(const CanonicalCookie& cookie,
721 bool removed, 719 bool removed,
722 ChangeCause cause) = 0; 720 ChangeCause cause) = 0;
721
723 protected: 722 protected:
724 friend class base::RefCountedThreadSafe<CookieMonsterDelegate>; 723 friend class base::RefCountedThreadSafe<CookieMonsterDelegate>;
725 virtual ~CookieMonsterDelegate() {} 724 virtual ~CookieMonsterDelegate() {}
726 }; 725 };
727 726
728 typedef base::RefCountedThreadSafe<CookieMonster::PersistentCookieStore> 727 typedef base::RefCountedThreadSafe<CookieMonster::PersistentCookieStore>
729 RefcountedPersistentCookieStore; 728 RefcountedPersistentCookieStore;
730 729
731 class NET_EXPORT CookieMonster::PersistentCookieStore 730 class NET_EXPORT CookieMonster::PersistentCookieStore
732 : public RefcountedPersistentCookieStore { 731 : public RefcountedPersistentCookieStore {
(...skipping 29 matching lines...) Expand all
762 virtual ~PersistentCookieStore() {} 761 virtual ~PersistentCookieStore() {}
763 762
764 private: 763 private:
765 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 764 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
766 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 765 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
767 }; 766 };
768 767
769 } // namespace net 768 } // namespace net
770 769
771 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 770 #endif // NET_COOKIES_COOKIE_MONSTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698