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

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

Issue 3070001: Fixes targeting the unique creation times invariant in the CookieMonster: (Closed)
Patch Set: Made creation times in perftest unique. Created 10 years, 4 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
« no previous file with comments | « no previous file | net/base/cookie_monster.cc » ('j') | net/base/cookie_monster.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_BASE_COOKIE_MONSTER_H_ 7 #ifndef NET_BASE_COOKIE_MONSTER_H_
8 #define NET_BASE_COOKIE_MONSTER_H_ 8 #define NET_BASE_COOKIE_MONSTER_H_
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/histogram.h" 16 #include "base/histogram.h"
17 #include "base/lock.h" 17 #include "base/lock.h"
18 #include "base/ref_counted.h" 18 #include "base/ref_counted.h"
19 #include "base/scoped_ptr.h" 19 #include "base/scoped_ptr.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "net/base/cookie_store.h" 21 #include "net/base/cookie_store.h"
22 #include "testing/gtest/include/gtest/gtest_prod.h"
22 23
23 class GURL; 24 class GURL;
24 25
25 namespace net { 26 namespace net {
26 27
27 // The cookie monster is the system for storing and retrieving cookies. It has 28 // The cookie monster is the system for storing and retrieving cookies. It has
28 // an in-memory list of all cookies, and synchronizes non-session cookies to an 29 // an in-memory list of all cookies, and synchronizes non-session cookies to an
29 // optional permanent storage that implements the PersistentCookieStore 30 // optional permanent storage that implements the PersistentCookieStore
30 // interface. 31 // interface.
31 // 32 //
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // cookie value attribute) and will return false without setting the cookie 100 // cookie value attribute) and will return false without setting the cookie
100 // if such characters are found. 101 // if such characters are found.
101 bool SetCookieWithDetails(const GURL& url, 102 bool SetCookieWithDetails(const GURL& url,
102 const std::string& name, 103 const std::string& name,
103 const std::string& value, 104 const std::string& value,
104 const std::string& domain, 105 const std::string& domain,
105 const std::string& path, 106 const std::string& path,
106 const base::Time& expiration_time, 107 const base::Time& expiration_time,
107 bool secure, bool http_only); 108 bool secure, bool http_only);
108 109
109 // Exposed for unit testing.
110 bool SetCookieWithCreationTimeAndOptions(const GURL& url,
111 const std::string& cookie_line,
112 const base::Time& creation_time,
113 const CookieOptions& options);
114 bool SetCookieWithCreationTime(const GURL& url,
115 const std::string& cookie_line,
116 const base::Time& creation_time) {
117 return SetCookieWithCreationTimeAndOptions(url, cookie_line, creation_time,
118 CookieOptions());
119 }
120
121 // Returns all the cookies, for use in management UI, etc. This does not mark 110 // Returns all the cookies, for use in management UI, etc. This does not mark
122 // the cookies as having been accessed. 111 // the cookies as having been accessed.
123 CookieList GetAllCookies(); 112 CookieList GetAllCookies();
124 113
125 // Returns all the cookies, for use in management UI, etc. Filters results 114 // Returns all the cookies, for use in management UI, etc. Filters results
126 // using given url scheme, host / domain and path. This does not mark the 115 // using given url scheme, host / domain and path. This does not mark the
127 // cookies as having been accessed. 116 // cookies as having been accessed.
128 CookieList GetAllCookiesForURL(const GURL& url); 117 CookieList GetAllCookiesForURL(const GURL& url);
129 118
130 // Delete all of the cookies. 119 // Delete all of the cookies.
(...skipping 28 matching lines...) Expand all
159 // There are some unknowns about how to correctly handle file:// cookies, 148 // There are some unknowns about how to correctly handle file:// cookies,
160 // and our implementation for this is not robust enough. This allows you 149 // and our implementation for this is not robust enough. This allows you
161 // to enable support, but it should only be used for testing. Bug 1157243. 150 // to enable support, but it should only be used for testing. Bug 1157243.
162 // Must be called before creating a CookieMonster instance. 151 // Must be called before creating a CookieMonster instance.
163 static void EnableFileScheme(); 152 static void EnableFileScheme();
164 static bool enable_file_scheme_; 153 static bool enable_file_scheme_;
165 154
166 private: 155 private:
167 ~CookieMonster(); 156 ~CookieMonster();
168 157
158 // Testing support.
159 friend class CookieMonsterTest;
160 FRIEND_TEST(CookieMonsterTest, TestCookieDeleteAllCreatedAfterTimestamp);
161 FRIEND_TEST(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps);
162 bool SetCookieWithCreationTime(const GURL& url,
163 const std::string& cookie_line,
164 const base::Time& creation_time);
165
169 // Called by all non-static functions to ensure that the cookies store has 166 // Called by all non-static functions to ensure that the cookies store has
170 // been initialized. This is not done during creating so it doesn't block 167 // been initialized. This is not done during creating so it doesn't block
171 // the window showing. 168 // the window showing.
172 // Note: this method should always be called with lock_ held. 169 // Note: this method should always be called with lock_ held.
173 void InitIfNecessary() { 170 void InitIfNecessary() {
174 if (!initialized_) { 171 if (!initialized_) {
175 if (store_) 172 if (store_)
176 InitStore(); 173 InitStore();
177 initialized_ = true; 174 initialized_ = true;
178 } 175 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // return value with be true if |skip_httponly| skipped an httponly cookie. 209 // return value with be true if |skip_httponly| skipped an httponly cookie.
213 // NOTE: There should never be more than a single matching equivalent cookie. 210 // NOTE: There should never be more than a single matching equivalent cookie.
214 bool DeleteAnyEquivalentCookie(const std::string& key, 211 bool DeleteAnyEquivalentCookie(const std::string& key,
215 const CanonicalCookie& ecc, 212 const CanonicalCookie& ecc,
216 bool skip_httponly); 213 bool skip_httponly);
217 214
218 void InternalInsertCookie(const std::string& key, 215 void InternalInsertCookie(const std::string& key,
219 CanonicalCookie* cc, 216 CanonicalCookie* cc,
220 bool sync_to_store); 217 bool sync_to_store);
221 218
219 // Helper function that sets cookies with more control.
220 // Not exposed as we don't want callers to have the ability
221 // to specify (potentially duplicate) creation times.
222 bool SetCookieWithCreationTimeAndOptions(const GURL& url,
223 const std::string& cookie_line,
224 const base::Time& creation_time,
225 const CookieOptions& options);
226
227
222 // Helper function that sets a canonical cookie, deleting equivalents and 228 // Helper function that sets a canonical cookie, deleting equivalents and
223 // performing garbage collection. 229 // performing garbage collection.
224 bool SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc, 230 bool SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc,
225 const base::Time& creation_time, 231 const base::Time& creation_time,
226 const CookieOptions& options); 232 const CookieOptions& options);
227 233
228 void InternalUpdateCookieAccessTime(CanonicalCookie* cc); 234 void InternalUpdateCookieAccessTime(CanonicalCookie* cc);
229 235
230 enum DeletionCause { 236 enum DeletionCause {
231 DELETE_COOKIE_EXPLICIT, 237 DELETE_COOKIE_EXPLICIT,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 protected: 548 protected:
543 PersistentCookieStore() { } 549 PersistentCookieStore() { }
544 550
545 private: 551 private:
546 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 552 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
547 }; 553 };
548 554
549 } // namespace net 555 } // namespace net
550 556
551 #endif // NET_BASE_COOKIE_MONSTER_H_ 557 #endif // NET_BASE_COOKIE_MONSTER_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/cookie_monster.cc » ('j') | net/base/cookie_monster.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698