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, before DELETE_COOKIE_LAST_ENTRY and the temporary | 280 // at the end of the list, before DELETE_COOKIE_LAST_ENTRY and the temporary |
284 // values added for debugging. | 281 // values added for debugging. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 const std::string& name, | 402 const std::string& name, |
406 const std::string& value, | 403 const std::string& value, |
407 const std::string& domain, | 404 const std::string& domain, |
408 const std::string& path, | 405 const std::string& path, |
409 base::Time creation_time, | 406 base::Time creation_time, |
410 base::Time expiration_time, | 407 base::Time expiration_time, |
411 base::Time last_access_time, | 408 base::Time last_access_time, |
412 bool secure, | 409 bool secure, |
413 bool http_only, | 410 bool http_only, |
414 CookieSameSite same_site, | 411 CookieSameSite same_site, |
415 bool enforce_strict_secure, | |
416 CookiePriority priority); | 412 CookiePriority priority); |
417 | 413 |
418 CookieList GetAllCookies(); | 414 CookieList GetAllCookies(); |
419 | 415 |
420 CookieList GetCookieListWithOptions(const GURL& url, | 416 CookieList GetCookieListWithOptions(const GURL& url, |
421 const CookieOptions& options); | 417 const CookieOptions& options); |
422 | 418 |
423 int DeleteAllCreatedBetween(const base::Time& delete_begin, | 419 int DeleteAllCreatedBetween(const base::Time& delete_begin, |
424 const base::Time& delete_end); | 420 const base::Time& delete_end); |
425 | 421 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 void FindCookiesForKey(const std::string& key, | 497 void FindCookiesForKey(const std::string& key, |
502 const GURL& url, | 498 const GURL& url, |
503 const CookieOptions& options, | 499 const CookieOptions& options, |
504 const base::Time& current, | 500 const base::Time& current, |
505 std::vector<CanonicalCookie*>* cookies); | 501 std::vector<CanonicalCookie*>* cookies); |
506 | 502 |
507 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). | 503 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). |
508 // |source_url| is the URL that is attempting to set the cookie. | 504 // |source_url| is the URL that is attempting to set the cookie. |
509 // If |skip_httponly| is true, httponly cookies will not be deleted. The | 505 // If |skip_httponly| is true, httponly cookies will not be deleted. The |
510 // return value will be true if |skip_httponly| skipped an httponly cookie or | 506 // return value will be true if |skip_httponly| skipped an httponly cookie or |
511 // |enforce_strict_secure| is true and the cookie to | 507 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key| |
512 // delete was Secure and the scheme of |ecc| is insecure. |key| is the key to | 508 // is the key to find the cookie in cookies_; see the comment before the |
513 // find the cookie in cookies_; see the comment before the CookieMap typedef | 509 // CookieMap typedef for details. |
514 // for details. | |
515 // NOTE: There should never be more than a single matching equivalent cookie. | 510 // NOTE: There should never be more than a single matching equivalent cookie. |
516 bool DeleteAnyEquivalentCookie(const std::string& key, | 511 bool DeleteAnyEquivalentCookie(const std::string& key, |
517 const CanonicalCookie& ecc, | 512 const CanonicalCookie& ecc, |
518 const GURL& source_url, | 513 const GURL& source_url, |
519 bool skip_httponly, | 514 bool skip_httponly, |
520 bool already_expired, | 515 bool already_expired); |
521 bool enforce_strict_secure); | |
522 | 516 |
523 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted | 517 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted |
524 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. | 518 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. |
525 CookieMap::iterator InternalInsertCookie(const std::string& key, | 519 CookieMap::iterator InternalInsertCookie(const std::string& key, |
526 std::unique_ptr<CanonicalCookie> cc, | 520 std::unique_ptr<CanonicalCookie> cc, |
527 const GURL& source_url, | 521 const GURL& source_url, |
528 bool sync_to_store); | 522 bool sync_to_store); |
529 | 523 |
530 // Helper function that sets cookies with more control. | 524 // Helper function that sets cookies with more control. |
531 // Not exposed as we don't want callers to have the ability | 525 // Not exposed as we don't want callers to have the ability |
(...skipping 23 matching lines...) Expand all Loading... |
555 void InternalDeleteCookie(CookieMap::iterator it, | 549 void InternalDeleteCookie(CookieMap::iterator it, |
556 bool sync_to_store, | 550 bool sync_to_store, |
557 DeletionCause deletion_cause); | 551 DeletionCause deletion_cause); |
558 | 552 |
559 // 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 |
560 // 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 |
561 // then globally. See comments above garbage collection threshold | 555 // then globally. See comments above garbage collection threshold |
562 // constants for details. | 556 // constants for details. |
563 // | 557 // |
564 // Returns the number of cookies deleted (useful for debugging). | 558 // Returns the number of cookies deleted (useful for debugging). |
565 size_t GarbageCollect(const base::Time& current, | 559 size_t GarbageCollect(const base::Time& current, const std::string& key); |
566 const std::string& key, | |
567 bool enforce_strict_secure); | |
568 | 560 |
569 // Helper for GarbageCollect(). Deletes up to |purge_goal| cookies with a | 561 // Helper for GarbageCollect(). Deletes up to |purge_goal| cookies with a |
570 // priority less than or equal to |priority| from |cookies|, while ensuring | 562 // priority less than or equal to |priority| from |cookies|, while ensuring |
571 // that at least the |to_protect| most-recent cookies are retained. | 563 // that at least the |to_protect| most-recent cookies are retained. |
572 // |protected_secure_cookies| specifies whether or not secure cookies should | 564 // |protected_secure_cookies| specifies whether or not secure cookies should |
573 // be protected from deletion. | 565 // be protected from deletion. |
574 // | 566 // |
575 // |cookies| must be sorted from least-recent to most-recent. | 567 // |cookies| must be sorted from least-recent to most-recent. |
576 // | 568 // |
577 // Returns the number of cookies deleted. | 569 // Returns the number of cookies deleted. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 virtual ~PersistentCookieStore() {} | 802 virtual ~PersistentCookieStore() {} |
811 | 803 |
812 private: | 804 private: |
813 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 805 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
814 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 806 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
815 }; | 807 }; |
816 | 808 |
817 } // namespace net | 809 } // namespace net |
818 | 810 |
819 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 811 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |