Chromium Code Reviews| 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 <deque> | 10 #include <deque> |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 void SetForceKeepSessionState(); | 227 void SetForceKeepSessionState(); |
| 228 | 228 |
| 229 // Flush the backing store (if any) to disk and post the given callback when | 229 // Flush the backing store (if any) to disk and post the given callback when |
| 230 // done. | 230 // done. |
| 231 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE. | 231 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE. |
| 232 // It may be posted to the current thread, or it may run on the thread that | 232 // It may be posted to the current thread, or it may run on the thread that |
| 233 // actually does the flushing. Your Task should generally post a notification | 233 // actually does the flushing. Your Task should generally post a notification |
| 234 // to the thread you actually want to be notified on. | 234 // to the thread you actually want to be notified on. |
| 235 void FlushStore(const base::Closure& callback); | 235 void FlushStore(const base::Closure& callback); |
| 236 | 236 |
| 237 // Replaces all the cookies by |list|. | |
| 238 // This method does not flush the backend, and does not update the creation | |
| 239 // time nor the last access time: if a cookie in |list| already exists in the | |
| 240 // cookie monster with a different time, the cookie is left untouched in the | |
| 241 // cookie monster. | |
|
droger
2015/03/12 15:50:29
I don't know if this behavior w.r.t. creation time
erikwright (departed)
2015/03/13 13:59:01
Presumably the rationale for not needing to update
droger
2015/03/13 15:10:47
Some context: on iOS when a WebView is attached to
| |
| 242 void SetAllCookiesAsync(const CookieList& list, | |
| 243 const SetCookiesCallback& callback); | |
| 244 | |
| 237 // CookieStore implementation. | 245 // CookieStore implementation. |
| 238 | 246 |
| 239 // Sets the cookies specified by |cookie_list| returned from |url| | 247 // Sets the cookies specified by |cookie_list| returned from |url| |
| 240 // with options |options| in effect. | 248 // with options |options| in effect. |
| 241 void SetCookieWithOptionsAsync(const GURL& url, | 249 void SetCookieWithOptionsAsync(const GURL& url, |
| 242 const std::string& cookie_line, | 250 const std::string& cookie_line, |
| 243 const CookieOptions& options, | 251 const CookieOptions& options, |
| 244 const SetCookiesCallback& callback) override; | 252 const SetCookiesCallback& callback) override; |
| 245 | 253 |
| 246 // Gets all cookies that apply to |url| given |options|. | 254 // Gets all cookies that apply to |url| given |options|. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 class DeleteTask; | 323 class DeleteTask; |
| 316 class DeleteAllCreatedBetweenTask; | 324 class DeleteAllCreatedBetweenTask; |
| 317 class DeleteAllCreatedBetweenForHostTask; | 325 class DeleteAllCreatedBetweenForHostTask; |
| 318 class DeleteAllForHostTask; | 326 class DeleteAllForHostTask; |
| 319 class DeleteAllTask; | 327 class DeleteAllTask; |
| 320 class DeleteCookieTask; | 328 class DeleteCookieTask; |
| 321 class DeleteCanonicalCookieTask; | 329 class DeleteCanonicalCookieTask; |
| 322 class GetAllCookiesForURLWithOptionsTask; | 330 class GetAllCookiesForURLWithOptionsTask; |
| 323 class GetAllCookiesTask; | 331 class GetAllCookiesTask; |
| 324 class GetCookiesWithOptionsTask; | 332 class GetCookiesWithOptionsTask; |
| 333 class SetAllCookiesTask; | |
| 325 class SetCookieWithDetailsTask; | 334 class SetCookieWithDetailsTask; |
| 326 class SetCookieWithOptionsTask; | 335 class SetCookieWithOptionsTask; |
| 327 class DeleteSessionCookiesTask; | 336 class DeleteSessionCookiesTask; |
| 328 class HasCookiesForETLDP1Task; | 337 class HasCookiesForETLDP1Task; |
| 329 | 338 |
| 330 // Testing support. | 339 // Testing support. |
| 331 // For SetCookieWithCreationTime. | 340 // For SetCookieWithCreationTime. |
| 332 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, | 341 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, |
| 333 TestCookieDeleteAllCreatedBetweenTimestamps); | 342 TestCookieDeleteAllCreatedBetweenTimestamps); |
| 334 // For SetCookieWithCreationTime. | 343 // For SetCookieWithCreationTime. |
| 335 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCookieMonsterTest, | 344 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCookieMonsterTest, |
| 336 ThreadCheckDeleteAllCreatedBetweenForHost); | 345 ThreadCheckDeleteAllCreatedBetweenForHost); |
| 337 | 346 |
| 338 // For gargage collection constants. | 347 // For gargage collection constants. |
| 339 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); | 348 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); |
| 340 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection); | 349 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection); |
| 341 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); | 350 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); |
| 342 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGCTimes); | 351 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGCTimes); |
| 343 | 352 |
| 344 // For validation of key values. | 353 // For validation of key values. |
| 345 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestDomainTree); | 354 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestDomainTree); |
| 346 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestImport); | 355 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestImport); |
| 347 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GetKey); | 356 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GetKey); |
| 348 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGetKey); | 357 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGetKey); |
| 349 | 358 |
| 350 // For FindCookiesForKey. | 359 // For FindCookiesForKey. |
| 351 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ShortLivedSessionCookies); | 360 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ShortLivedSessionCookies); |
| 352 | 361 |
| 362 // For ComputeCookieDiff. | |
| 363 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ComputeCookieDiff); | |
| 364 | |
| 353 // Internal reasons for deletion, used to populate informative histograms | 365 // Internal reasons for deletion, used to populate informative histograms |
| 354 // and to provide a public cause for onCookieChange notifications. | 366 // and to provide a public cause for onCookieChange notifications. |
| 355 // | 367 // |
| 356 // If you add or remove causes from this list, please be sure to also update | 368 // If you add or remove causes from this list, please be sure to also update |
| 357 // the CookieMonsterDelegate::ChangeCause mapping inside ChangeCauseMapping. | 369 // the CookieMonsterDelegate::ChangeCause mapping inside ChangeCauseMapping. |
| 358 // Moreover, these are used as array indexes, so avoid reordering to keep the | 370 // Moreover, these are used as array indexes, so avoid reordering to keep the |
| 359 // histogram buckets consistent. New items (if necessary) should be added | 371 // histogram buckets consistent. New items (if necessary) should be added |
| 360 // at the end of the list, just before DELETE_COOKIE_LAST_ENTRY. | 372 // at the end of the list, just before DELETE_COOKIE_LAST_ENTRY. |
| 361 enum DeletionCause { | 373 enum DeletionCause { |
| 362 DELETE_COOKIE_EXPLICIT = 0, | 374 DELETE_COOKIE_EXPLICIT = 0, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 const std::string& cookie_line, | 549 const std::string& cookie_line, |
| 538 const base::Time& creation_time, | 550 const base::Time& creation_time, |
| 539 const CookieOptions& options); | 551 const CookieOptions& options); |
| 540 | 552 |
| 541 // Helper function that sets a canonical cookie, deleting equivalents and | 553 // Helper function that sets a canonical cookie, deleting equivalents and |
| 542 // performing garbage collection. | 554 // performing garbage collection. |
| 543 bool SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc, | 555 bool SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc, |
| 544 const base::Time& creation_time, | 556 const base::Time& creation_time, |
| 545 const CookieOptions& options); | 557 const CookieOptions& options); |
| 546 | 558 |
| 559 // Helper function calling SetCanonicalCookie() for all cookies in |list|. | |
| 560 bool SetCanonicalCookies(const CookieList& list); | |
| 561 | |
| 547 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, | 562 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, |
| 548 const base::Time& current_time); | 563 const base::Time& current_time); |
| 549 | 564 |
| 550 // |deletion_cause| argument is used for collecting statistics and choosing | 565 // |deletion_cause| argument is used for collecting statistics and choosing |
| 551 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged | 566 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged |
| 552 // notifications. Guarantee: All iterators to cookies_ except to the | 567 // notifications. Guarantee: All iterators to cookies_ except to the |
| 553 // deleted entry remain vaild. | 568 // deleted entry remain vaild. |
| 554 void InternalDeleteCookie(CookieMap::iterator it, | 569 void InternalDeleteCookie(CookieMap::iterator it, |
| 555 bool sync_to_store, | 570 bool sync_to_store, |
| 556 DeletionCause deletion_cause); | 571 DeletionCause deletion_cause); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 | 616 |
| 602 // Runs the task if, or defers the task until, the full cookie database is | 617 // Runs the task if, or defers the task until, the full cookie database is |
| 603 // loaded. | 618 // loaded. |
| 604 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item); | 619 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item); |
| 605 | 620 |
| 606 // Runs the task if, or defers the task until, the cookies for the given URL | 621 // Runs the task if, or defers the task until, the cookies for the given URL |
| 607 // are loaded. | 622 // are loaded. |
| 608 void DoCookieTaskForURL(const scoped_refptr<CookieMonsterTask>& task_item, | 623 void DoCookieTaskForURL(const scoped_refptr<CookieMonsterTask>& task_item, |
| 609 const GURL& url); | 624 const GURL& url); |
| 610 | 625 |
| 626 // Computes the difference between |old_cookies| and |new_cookies|, and writes | |
| 627 // the result in |cookies_to_add| and |cookies_to_delete|. | |
| 628 // This function has the side effect of changing the order of |old_cookies| | |
| 629 // and |new_cookies|. |cookies_to_add| and |cookies_to_delete| must be empty, | |
| 630 // and none of the arguments can be null. | |
| 631 // Creation time and last access time are ignored (cookies differing only by | |
| 632 // their time are considered identical). | |
| 633 void ComputeCookieDiff(CookieList* old_cookies, | |
| 634 CookieList* new_cookies, | |
| 635 CookieList* cookies_to_add, | |
| 636 CookieList* cookies_to_delete); | |
| 637 | |
| 611 // Run all cookie changed callbacks that are monitoring |cookie|. | 638 // Run all cookie changed callbacks that are monitoring |cookie|. |
| 612 // |removed| is true if the cookie was deleted. | 639 // |removed| is true if the cookie was deleted. |
| 613 void RunCallbacks(const CanonicalCookie& cookie, bool removed); | 640 void RunCallbacks(const CanonicalCookie& cookie, bool removed); |
| 614 | 641 |
| 615 // Histogram variables; see CookieMonster::InitializeHistograms() in | 642 // Histogram variables; see CookieMonster::InitializeHistograms() in |
| 616 // cookie_monster.cc for details. | 643 // cookie_monster.cc for details. |
| 617 base::HistogramBase* histogram_expiration_duration_minutes_; | 644 base::HistogramBase* histogram_expiration_duration_minutes_; |
| 618 base::HistogramBase* histogram_between_access_interval_minutes_; | 645 base::HistogramBase* histogram_between_access_interval_minutes_; |
| 619 base::HistogramBase* histogram_evicted_last_access_minutes_; | 646 base::HistogramBase* histogram_evicted_last_access_minutes_; |
| 620 base::HistogramBase* histogram_count_; | 647 base::HistogramBase* histogram_count_; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 virtual ~PersistentCookieStore() {} | 799 virtual ~PersistentCookieStore() {} |
| 773 | 800 |
| 774 private: | 801 private: |
| 775 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 802 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
| 776 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 803 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
| 777 }; | 804 }; |
| 778 | 805 |
| 779 } // namespace net | 806 } // namespace net |
| 780 | 807 |
| 781 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 808 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
| OLD | NEW |