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

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

Issue 2882063002: Add a SetCanonicalCookie method for CookieMonster. (Closed)
Patch Set: Fix try jobs and do some cleanup. Created 3 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
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 <stddef.h> 10 #include <stddef.h>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 CookiePriority priority, 167 CookiePriority priority,
168 const SetCookiesCallback& callback) override; 168 const SetCookiesCallback& callback) override;
169 void SetCanonicalCookieAsync(const CanonicalCookie& cookie,
170 bool secure_source,
171 bool modify_http_only,
172 const SetCookiesCallback& callback) override;
169 void GetCookiesWithOptionsAsync(const GURL& url, 173 void GetCookiesWithOptionsAsync(const GURL& url,
170 const CookieOptions& options, 174 const CookieOptions& options,
171 const GetCookiesCallback& callback) override; 175 const GetCookiesCallback& callback) override;
172 void GetCookieListWithOptionsAsync( 176 void GetCookieListWithOptionsAsync(
173 const GURL& url, 177 const GURL& url,
174 const CookieOptions& options, 178 const CookieOptions& options,
175 const GetCookieListCallback& callback) override; 179 const GetCookieListCallback& callback) override;
176 void GetAllCookiesAsync(const GetCookieListCallback& callback) override; 180 void GetAllCookiesAsync(const GetCookieListCallback& callback) override;
177 void DeleteCookieAsync(const GURL& url, 181 void DeleteCookieAsync(const GURL& url,
178 const std::string& cookie_name, 182 const std::string& cookie_name,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 class DeleteAllCreatedBetweenWithPredicateTask; 229 class DeleteAllCreatedBetweenWithPredicateTask;
226 class DeleteCookieTask; 230 class DeleteCookieTask;
227 class DeleteCanonicalCookieTask; 231 class DeleteCanonicalCookieTask;
228 class GetCookieListForURLWithOptionsTask; 232 class GetCookieListForURLWithOptionsTask;
229 class GetAllCookiesTask; 233 class GetAllCookiesTask;
230 class GetCookiesWithOptionsTask; 234 class GetCookiesWithOptionsTask;
231 class GetCookieListWithOptionsTask; 235 class GetCookieListWithOptionsTask;
232 class SetAllCookiesTask; 236 class SetAllCookiesTask;
233 class SetCookieWithDetailsTask; 237 class SetCookieWithDetailsTask;
234 class SetCookieWithOptionsTask; 238 class SetCookieWithOptionsTask;
239 class SetCanonicalCookieTask;
235 class DeleteSessionCookiesTask; 240 class DeleteSessionCookiesTask;
236 241
237 // Testing support. 242 // Testing support.
238 // For SetCookieWithCreationTime. 243 // For SetCookieWithCreationTime.
239 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, 244 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest,
240 TestCookieDeleteAllCreatedBetweenTimestamps); 245 TestCookieDeleteAllCreatedBetweenTimestamps);
241 FRIEND_TEST_ALL_PREFIXES( 246 FRIEND_TEST_ALL_PREFIXES(
242 CookieMonsterTest, 247 CookieMonsterTest,
243 TestCookieDeleteAllCreatedBetweenTimestampsWithPredicate); 248 TestCookieDeleteAllCreatedBetweenTimestampsWithPredicate);
244 249
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 423
419 int DeleteAllCreatedBetween(const base::Time& delete_begin, 424 int DeleteAllCreatedBetween(const base::Time& delete_begin,
420 const base::Time& delete_end); 425 const base::Time& delete_end);
421 426
422 // Predicate will be called with the calling thread. 427 // Predicate will be called with the calling thread.
423 int DeleteAllCreatedBetweenWithPredicate( 428 int DeleteAllCreatedBetweenWithPredicate(
424 const base::Time& delete_begin, 429 const base::Time& delete_begin,
425 const base::Time& delete_end, 430 const base::Time& delete_end,
426 const base::Callback<bool(const CanonicalCookie&)>& predicate); 431 const base::Callback<bool(const CanonicalCookie&)>& predicate);
427 432
433 // Sets a canonical cookie, deletes equivalents and performs garbage
434 // collection. |source_secure| indicates if the cookie is being set
435 // from a secure source (e.g. a cryptographic scheme).
436 // |modify_http_only| indicates if this setting operation is allowed
437 // to affect http_only cookies.
438 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cookie,
439 bool secure_source,
440 bool can_modify_httponly);
441
428 bool SetCookieWithOptions(const GURL& url, 442 bool SetCookieWithOptions(const GURL& url,
429 const std::string& cookie_line, 443 const std::string& cookie_line,
430 const CookieOptions& options); 444 const CookieOptions& options);
431 445
432 std::string GetCookiesWithOptions(const GURL& url, 446 std::string GetCookiesWithOptions(const GURL& url,
433 const CookieOptions& options); 447 const CookieOptions& options);
434 448
435 void DeleteCookie(const GURL& url, const std::string& cookie_name); 449 void DeleteCookie(const GURL& url, const std::string& cookie_name);
436 450
437 int DeleteCanonicalCookie(const CanonicalCookie& cookie); 451 int DeleteCanonicalCookie(const CanonicalCookie& cookie);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 const CookieOptions& options, 508 const CookieOptions& options,
495 std::vector<CanonicalCookie*>* cookies); 509 std::vector<CanonicalCookie*>* cookies);
496 510
497 void FindCookiesForKey(const std::string& key, 511 void FindCookiesForKey(const std::string& key,
498 const GURL& url, 512 const GURL& url,
499 const CookieOptions& options, 513 const CookieOptions& options,
500 const base::Time& current, 514 const base::Time& current,
501 std::vector<CanonicalCookie*>* cookies); 515 std::vector<CanonicalCookie*>* cookies);
502 516
503 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). 517 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc).
504 // |source_url| is the URL that is attempting to set the cookie. 518 // |source_secure| indicates if the source may override existing secure
519 // cookies.
505 // If |skip_httponly| is true, httponly cookies will not be deleted. The 520 // If |skip_httponly| is true, httponly cookies will not be deleted. The
506 // return value will be true if |skip_httponly| skipped an httponly cookie or 521 // return value will be true if |skip_httponly| skipped an httponly cookie or
507 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key| 522 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key|
508 // is the key to find the cookie in cookies_; see the comment before the 523 // is the key to find the cookie in cookies_; see the comment before the
509 // CookieMap typedef for details. 524 // CookieMap typedef for details.
510 // NOTE: There should never be more than a single matching equivalent cookie. 525 // NOTE: There should never be more than a single matching equivalent cookie.
511 bool DeleteAnyEquivalentCookie(const std::string& key, 526 bool DeleteAnyEquivalentCookie(const std::string& key,
512 const CanonicalCookie& ecc, 527 const CanonicalCookie& ecc,
513 const GURL& source_url, 528 bool source_secure,
514 bool skip_httponly, 529 bool skip_httponly,
515 bool already_expired); 530 bool already_expired);
516 531
517 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted 532 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted
518 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. 533 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid.
534 // |secure_source| indicates if the setting of the canonical cookie is
535 // coming from a secure source (e.g. a cryptographically schemed URL).
519 CookieMap::iterator InternalInsertCookie(const std::string& key, 536 CookieMap::iterator InternalInsertCookie(const std::string& key,
520 std::unique_ptr<CanonicalCookie> cc, 537 std::unique_ptr<CanonicalCookie> cc,
521 const GURL& source_url, 538 bool source_secure,
522 bool sync_to_store); 539 bool sync_to_store);
523 540
524 // Helper function that sets cookies with more control. 541 // Helper function that sets cookies with more control.
525 // Not exposed as we don't want callers to have the ability 542 // Not exposed as we don't want callers to have the ability
526 // to specify (potentially duplicate) creation times. 543 // to specify (potentially duplicate) creation times.
527 bool SetCookieWithCreationTimeAndOptions(const GURL& url, 544 bool SetCookieWithCreationTimeAndOptions(const GURL& url,
528 const std::string& cookie_line, 545 const std::string& cookie_line,
529 const base::Time& creation_time, 546 const base::Time& creation_time,
530 const CookieOptions& options); 547 const CookieOptions& options);
531 548
532 // Helper function that sets a canonical cookie, deleting equivalents and 549 // Helper function calling SetCanonicalCookieInternal() for all
533 // performing garbage collection. 550 // cookies in |list|.
534 // |source_url| is the URL that's attempting to set the cookie. 551 bool SetCanonicalCookiesInternal(const CookieList& list);
535 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
536 const GURL& source_url,
537 const CookieOptions& options);
538
539 // Helper function calling SetCanonicalCookie() for all cookies in |list|.
540 bool SetCanonicalCookies(const CookieList& list);
541 552
542 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, 553 void InternalUpdateCookieAccessTime(CanonicalCookie* cc,
543 const base::Time& current_time); 554 const base::Time& current_time);
544 555
545 // |deletion_cause| argument is used for collecting statistics and choosing 556 // |deletion_cause| argument is used for collecting statistics and choosing
546 // the correct CookieStore::ChangeCause for OnCookieChanged 557 // the correct CookieStore::ChangeCause for OnCookieChanged
547 // notifications. Guarantee: All iterators to cookies_ except to the 558 // notifications. Guarantee: All iterators to cookies_ except to the
548 // deleted entry remain valid. 559 // deleted entry remain valid.
549 void InternalDeleteCookie(CookieMap::iterator it, 560 void InternalDeleteCookie(CookieMap::iterator it,
550 bool sync_to_store, 561 bool sync_to_store,
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 virtual ~PersistentCookieStore() {} 813 virtual ~PersistentCookieStore() {}
803 814
804 private: 815 private:
805 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 816 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
806 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 817 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
807 }; 818 };
808 819
809 } // namespace net 820 } // namespace net
810 821
811 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 822 #endif // NET_COOKIES_COOKIE_MONSTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698