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 // 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 <stddef.h> | 10 #include <stddef.h> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 const std::string& name, | 157 const std::string& name, |
158 const std::string& value, | 158 const std::string& value, |
159 const std::string& domain, | 159 const std::string& domain, |
160 const std::string& path, | 160 const std::string& path, |
161 base::Time creation_time, | 161 base::Time creation_time, |
162 base::Time expiration_time, | 162 base::Time expiration_time, |
163 base::Time last_access_time, | 163 base::Time last_access_time, |
164 bool secure, | 164 bool secure, |
165 bool http_only, | 165 bool http_only, |
166 CookieSameSite same_site, | 166 CookieSameSite same_site, |
167 bool enforce_strict_secure, | |
168 CookiePriority priority, | 167 CookiePriority priority, |
169 const SetCookiesCallback& callback) override; | 168 const SetCookiesCallback& callback) override; |
170 void GetCookiesWithOptionsAsync(const GURL& url, | 169 void GetCookiesWithOptionsAsync(const GURL& url, |
171 const CookieOptions& options, | 170 const CookieOptions& options, |
172 const GetCookiesCallback& callback) override; | 171 const GetCookiesCallback& callback) override; |
173 void GetCookieListWithOptionsAsync( | 172 void GetCookieListWithOptionsAsync( |
174 const GURL& url, | 173 const GURL& url, |
175 const CookieOptions& options, | 174 const CookieOptions& options, |
176 const GetCookieListCallback& callback) override; | 175 const GetCookieListCallback& callback) override; |
177 void GetAllCookiesAsync(const GetCookieListCallback& callback) override; | 176 void GetAllCookiesAsync(const GetCookieListCallback& callback) override; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // For FindCookiesForKey. | 257 // For FindCookiesForKey. |
259 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ShortLivedSessionCookies); | 258 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ShortLivedSessionCookies); |
260 | 259 |
261 // For ComputeCookieDiff. | 260 // For ComputeCookieDiff. |
262 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ComputeCookieDiff); | 261 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ComputeCookieDiff); |
263 | 262 |
264 // For CookieSource histogram enum. | 263 // For CookieSource histogram enum. |
265 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, CookieSourceHistogram); | 264 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, CookieSourceHistogram); |
266 | 265 |
267 // For kSafeFromGlobalPurgeDays in CookieStore. | 266 // For kSafeFromGlobalPurgeDays in CookieStore. |
268 FRIEND_TEST_ALL_PREFIXES(CookieMonsterStrictSecureTest, EvictSecureCookies); | 267 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, EvictSecureCookies); |
269 | 268 |
270 // For CookieDeleteEquivalent histogram enum. | 269 // For CookieDeleteEquivalent histogram enum. |
271 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, | 270 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, |
272 CookieDeleteEquivalentHistogramTest); | 271 CookieDeleteEquivalentHistogramTest); |
273 FRIEND_TEST_ALL_PREFIXES(CookieMonsterStrictSecureTest, | |
274 CookieDeleteEquivalentHistogramTest); | |
275 | 272 |
276 // Internal reasons for deletion, used to populate informative histograms | 273 // Internal reasons for deletion, used to populate informative histograms |
277 // and to provide a public cause for onCookieChange notifications. | 274 // and to provide a public cause for onCookieChange notifications. |
278 // | 275 // |
279 // If you add or remove causes from this list, please be sure to also update | 276 // If you add or remove causes from this list, please be sure to also update |
280 // the CookieStore::ChangeCause mapping inside ChangeCauseMapping. | 277 // the CookieStore::ChangeCause mapping inside ChangeCauseMapping. |
281 // Moreover, these are used as array indexes, so avoid reordering to keep the | 278 // Moreover, these are used as array indexes, so avoid reordering to keep the |
282 // histogram buckets consistent. New items (if necessary) should be added | 279 // histogram buckets consistent. New items (if necessary) should be added |
283 // at the end of the list, just before DELETE_COOKIE_LAST_ENTRY. | 280 // at the end of the list, just before DELETE_COOKIE_LAST_ENTRY. |
284 enum DeletionCause { | 281 enum DeletionCause { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 const std::string& name, | 388 const std::string& name, |
392 const std::string& value, | 389 const std::string& value, |
393 const std::string& domain, | 390 const std::string& domain, |
394 const std::string& path, | 391 const std::string& path, |
395 base::Time creation_time, | 392 base::Time creation_time, |
396 base::Time expiration_time, | 393 base::Time expiration_time, |
397 base::Time last_access_time, | 394 base::Time last_access_time, |
398 bool secure, | 395 bool secure, |
399 bool http_only, | 396 bool http_only, |
400 CookieSameSite same_site, | 397 CookieSameSite same_site, |
401 bool enforce_strict_secure, | |
402 CookiePriority priority); | 398 CookiePriority priority); |
403 | 399 |
404 CookieList GetAllCookies(); | 400 CookieList GetAllCookies(); |
405 | 401 |
406 CookieList GetCookieListWithOptions(const GURL& url, | 402 CookieList GetCookieListWithOptions(const GURL& url, |
407 const CookieOptions& options); | 403 const CookieOptions& options); |
408 | 404 |
409 int DeleteAllCreatedBetween(const base::Time& delete_begin, | 405 int DeleteAllCreatedBetween(const base::Time& delete_begin, |
410 const base::Time& delete_end); | 406 const base::Time& delete_end); |
411 | 407 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 void FindCookiesForKey(const std::string& key, | 483 void FindCookiesForKey(const std::string& key, |
488 const GURL& url, | 484 const GURL& url, |
489 const CookieOptions& options, | 485 const CookieOptions& options, |
490 const base::Time& current, | 486 const base::Time& current, |
491 std::vector<CanonicalCookie*>* cookies); | 487 std::vector<CanonicalCookie*>* cookies); |
492 | 488 |
493 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). | 489 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). |
494 // |source_url| is the URL that is attempting to set the cookie. | 490 // |source_url| is the URL that is attempting to set the cookie. |
495 // If |skip_httponly| is true, httponly cookies will not be deleted. The | 491 // If |skip_httponly| is true, httponly cookies will not be deleted. The |
496 // return value will be true if |skip_httponly| skipped an httponly cookie or | 492 // return value will be true if |skip_httponly| skipped an httponly cookie or |
497 // |enforce_strict_secure| is true and the cookie to | 493 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key| |
498 // delete was Secure and the scheme of |ecc| is insecure. |key| is the key to | 494 // is the key to find the cookie in cookies_; see the comment before the |
499 // find the cookie in cookies_; see the comment before the CookieMap typedef | 495 // CookieMap typedef for details. |
500 // for details. | |
501 // NOTE: There should never be more than a single matching equivalent cookie. | 496 // NOTE: There should never be more than a single matching equivalent cookie. |
502 bool DeleteAnyEquivalentCookie(const std::string& key, | 497 bool DeleteAnyEquivalentCookie(const std::string& key, |
503 const CanonicalCookie& ecc, | 498 const CanonicalCookie& ecc, |
504 const GURL& source_url, | 499 const GURL& source_url, |
505 bool skip_httponly, | 500 bool skip_httponly, |
506 bool already_expired, | 501 bool already_expired); |
507 bool enforce_strict_secure); | |
508 | 502 |
509 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted | 503 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted |
510 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. | 504 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. |
511 CookieMap::iterator InternalInsertCookie(const std::string& key, | 505 CookieMap::iterator InternalInsertCookie(const std::string& key, |
512 std::unique_ptr<CanonicalCookie> cc, | 506 std::unique_ptr<CanonicalCookie> cc, |
513 const GURL& source_url, | 507 const GURL& source_url, |
514 bool sync_to_store); | 508 bool sync_to_store); |
515 | 509 |
516 // Helper function that sets cookies with more control. | 510 // Helper function that sets cookies with more control. |
517 // Not exposed as we don't want callers to have the ability | 511 // Not exposed as we don't want callers to have the ability |
(...skipping 23 matching lines...) Expand all Loading... |
541 void InternalDeleteCookie(CookieMap::iterator it, | 535 void InternalDeleteCookie(CookieMap::iterator it, |
542 bool sync_to_store, | 536 bool sync_to_store, |
543 DeletionCause deletion_cause); | 537 DeletionCause deletion_cause); |
544 | 538 |
545 // If the number of cookies for CookieMap key |key|, or globally, are | 539 // If the number of cookies for CookieMap key |key|, or globally, are |
546 // over the preset maximums above, garbage collect, first for the host and | 540 // over the preset maximums above, garbage collect, first for the host and |
547 // then globally. See comments above garbage collection threshold | 541 // then globally. See comments above garbage collection threshold |
548 // constants for details. | 542 // constants for details. |
549 // | 543 // |
550 // Returns the number of cookies deleted (useful for debugging). | 544 // Returns the number of cookies deleted (useful for debugging). |
551 size_t GarbageCollect(const base::Time& current, | 545 size_t GarbageCollect(const base::Time& current, const std::string& key); |
552 const std::string& key, | |
553 bool enforce_strict_secure); | |
554 | 546 |
555 // Helper for GarbageCollect(). Deletes up to |purge_goal| cookies with a | 547 // Helper for GarbageCollect(). Deletes up to |purge_goal| cookies with a |
556 // priority less than or equal to |priority| from |cookies|, while ensuring | 548 // priority less than or equal to |priority| from |cookies|, while ensuring |
557 // that at least the |to_protect| most-recent cookies are retained. | 549 // that at least the |to_protect| most-recent cookies are retained. |
558 // |protected_secure_cookies| specifies whether or not secure cookies should | 550 // |protected_secure_cookies| specifies whether or not secure cookies should |
559 // be protected from deletion. | 551 // be protected from deletion. |
560 // | 552 // |
561 // |cookies| must be sorted from least-recent to most-recent. | 553 // |cookies| must be sorted from least-recent to most-recent. |
562 // | 554 // |
563 // Returns the number of cookies deleted. | 555 // Returns the number of cookies deleted. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 virtual ~PersistentCookieStore() {} | 788 virtual ~PersistentCookieStore() {} |
797 | 789 |
798 private: | 790 private: |
799 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 791 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
800 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 792 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
801 }; | 793 }; |
802 | 794 |
803 } // namespace net | 795 } // namespace net |
804 | 796 |
805 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 797 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |