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

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

Issue 7833042: Finalize a CL originally by departed intern ycxiao@ that detaches the loading of cookies from the... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 9 #pragma once
10 10
11 #include <map> 11 #include <map>
12 #include <queue>
12 #include <string> 13 #include <string>
13 #include <utility> 14 #include <utility>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/basictypes.h" 17 #include "base/basictypes.h"
17 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
20 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
21 #include "base/task.h" 22 #include "base/task.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 Delegate* delegate, 132 Delegate* delegate,
132 int last_access_threshold_milliseconds); 133 int last_access_threshold_milliseconds);
133 134
134 // Parses the string with the cookie time (very forgivingly). 135 // Parses the string with the cookie time (very forgivingly).
135 static base::Time ParseCookieTime(const std::string& time_string); 136 static base::Time ParseCookieTime(const std::string& time_string);
136 137
137 // Returns true if a domain string represents a host-only cookie, 138 // Returns true if a domain string represents a host-only cookie,
138 // i.e. it doesn't begin with a leading '.' character. 139 // i.e. it doesn't begin with a leading '.' character.
139 static bool DomainIsHostOnly(const std::string& domain_string); 140 static bool DomainIsHostOnly(const std::string& domain_string);
140 141
142 // Helper function that adds all cookies from |list| into this instance.
143 bool InitializeFrom(const CookieList& list);
144
145 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback;
146 typedef base::Callback<void(int num_deleted)> DeleteCallback;
147 typedef base::Callback<void(bool)> DeleteCookieCallback;
148
141 // Sets a cookie given explicit user-provided cookie attributes. The cookie 149 // Sets a cookie given explicit user-provided cookie attributes. The cookie
142 // name, value, domain, etc. are each provided as separate strings. This 150 // name, value, domain, etc. are each provided as separate strings. This
143 // function expects each attribute to be well-formed. It will check for 151 // function expects each attribute to be well-formed. It will check for
144 // disallowed characters (e.g. the ';' character is disallowed within the 152 // disallowed characters (e.g. the ';' character is disallowed within the
145 // cookie value attribute) and will return false without setting the cookie 153 // cookie value attribute) and will return false without setting the cookie
146 // if such characters are found. 154 // if such characters are found.
147 bool SetCookieWithDetails(const GURL& url,
148 const std::string& name,
149 const std::string& value,
150 const std::string& domain,
151 const std::string& path,
152 const base::Time& expiration_time,
153 bool secure, bool http_only);
154 void SetCookieWithDetailsAsync(const GURL& url, 155 void SetCookieWithDetailsAsync(const GURL& url,
155 const std::string& name, 156 const std::string& name,
156 const std::string& value, 157 const std::string& value,
157 const std::string& domain, 158 const std::string& domain,
158 const std::string& path, 159 const std::string& path,
159 const base::Time& expiration_time, 160 const base::Time& expiration_time,
160 bool secure, bool http_only, 161 bool secure, bool http_only,
161 const SetCookiesCallback& callback); 162 const SetCookiesCallback& callback);
162 163
163 164
164 // Helper function that adds all cookies from |cookie_monster| into this
165 // instance.
166 bool InitializeFrom(const CookieList& list);
167
168 // Returns all the cookies, for use in management UI, etc. This does not mark 165 // Returns all the cookies, for use in management UI, etc. This does not mark
169 // the cookies as having been accessed. 166 // the cookies as having been accessed.
170 // The returned cookies are ordered by longest path, then by earliest 167 // The returned cookies are ordered by longest path, then by earliest
171 // creation date. 168 // creation date.
172 CookieList GetAllCookies();
173 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback;
174 void GetAllCookiesAsync(const GetCookieListCallback& callback); 169 void GetAllCookiesAsync(const GetCookieListCallback& callback);
175 170
176 // Returns all the cookies, for use in management UI, etc. Filters results 171 // Returns all the cookies, for use in management UI, etc. Filters results
177 // using given url scheme, host / domain and path and options. This does not 172 // using given url scheme, host / domain and path and options. This does not
178 // mark the cookies as having been accessed. 173 // mark the cookies as having been accessed.
179 // The returned cookies are ordered by longest path, then earliest 174 // The returned cookies are ordered by longest path, then earliest
180 // creation date. 175 // creation date.
181 CookieList GetAllCookiesForURLWithOptions(const GURL& url,
182 const CookieOptions& options);
183 void GetAllCookiesForURLWithOptionsAsync( 176 void GetAllCookiesForURLWithOptionsAsync(
184 const GURL& url, 177 const GURL& url,
185 const CookieOptions& options, 178 const CookieOptions& options,
186 const GetCookieListCallback& callback); 179 const GetCookieListCallback& callback);
187 180
188 // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP 181 // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP
189 // only cookies. 182 // only cookies.
190 CookieList GetAllCookiesForURL(const GURL& url);
191 void GetAllCookiesForURLAsync(const GURL& url, 183 void GetAllCookiesForURLAsync(const GURL& url,
192 const GetCookieListCallback& callback); 184 const GetCookieListCallback& callback);
193 185
194 // Deletes all of the cookies. 186 // Deletes all of the cookies.
195 int DeleteAll(bool sync_to_store); 187 void DeleteAllAsync(const DeleteCallback& callback);
188
196 // Deletes all of the cookies that have a creation_date greater than or equal 189 // Deletes all of the cookies that have a creation_date greater than or equal
197 // to |delete_begin| and less than |delete_end| 190 // to |delete_begin| and less than |delete_end|
198 // Returns the number of cookies that have been deleted. 191 // Returns the number of cookies that have been deleted.
199 int DeleteAllCreatedBetween(const base::Time& delete_begin,
200 const base::Time& delete_end,
201 bool sync_to_store);
202 typedef base::Callback<void(int num_deleted)> DeleteCallback;
203 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, 192 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
204 const base::Time& delete_end, 193 const base::Time& delete_end,
205 bool sync_to_store,
206 const DeleteCallback& callback); 194 const DeleteCallback& callback);
207 195
208 // Deletes all cookies that match the host of the given URL 196 // Deletes all cookies that match the host of the given URL
209 // regardless of path. This includes all http_only and secure cookies, 197 // regardless of path. This includes all http_only and secure cookies,
210 // but does not include any domain cookies that may apply to this host. 198 // but does not include any domain cookies that may apply to this host.
211 // Returns the number of cookies deleted. 199 // Returns the number of cookies deleted.
212 int DeleteAllForHost(const GURL& url);
213
214 void DeleteAllForHostAsync(const GURL& url, 200 void DeleteAllForHostAsync(const GURL& url,
215 const DeleteCallback& callback); 201 const DeleteCallback& callback);
216 202
217 // Deletes one specific cookie. 203 // Deletes one specific cookie.
218 bool DeleteCanonicalCookie(const CanonicalCookie& cookie);
219
220 typedef SetCookiesCallback DeleteCookieCallback;
221
222 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, 204 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie,
223 const DeleteCookieCallback& callback); 205 const DeleteCookieCallback& callback);
224 206
225 // Override the default list of schemes that are allowed to be set in 207 // Override the default list of schemes that are allowed to be set in
226 // this cookie store. Calling his overrides the value of 208 // this cookie store. Calling his overrides the value of
227 // "enable_file_scheme_". 209 // "enable_file_scheme_".
228 // If this this method is called, it must be called before first use of 210 // If this this method is called, it must be called before first use of
229 // the instance (i.e. as part of the instance initialization process). 211 // the instance (i.e. as part of the instance initialization process).
230 void SetCookieableSchemes(const char* schemes[], size_t num_schemes); 212 void SetCookieableSchemes(const char* schemes[], size_t num_schemes);
231 213
(...skipping 21 matching lines...) Expand all
253 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE. 235 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE.
254 // It may be posted to the current thread, or it may run on the thread that 236 // It may be posted to the current thread, or it may run on the thread that
255 // actually does the flushing. Your Task should generally post a notification 237 // actually does the flushing. Your Task should generally post a notification
256 // to the thread you actually want to be notified on. 238 // to the thread you actually want to be notified on.
257 void FlushStore(Task* completion_task); 239 void FlushStore(Task* completion_task);
258 240
259 // CookieStore implementation. 241 // CookieStore implementation.
260 242
261 // Sets the cookies specified by |cookie_list| returned from |url| 243 // Sets the cookies specified by |cookie_list| returned from |url|
262 // with options |options| in effect. 244 // with options |options| in effect.
263 virtual bool SetCookieWithOptions(const GURL& url, 245 virtual void SetCookieWithOptionsAsync(
264 const std::string& cookie_line, 246 const GURL& url,
265 const CookieOptions& options); 247 const std::string& cookie_line,
266 248 const CookieOptions& options,
267 virtual void SetCookieWithOptionsAsync(const GURL& url, 249 const SetCookiesCallback& callback) OVERRIDE;
268 const std::string& cookie_line,
269 const CookieOptions& options,
270 const SetCookiesCallback& callback);
271 250
272 // Gets all cookies that apply to |url| given |options|. 251 // Gets all cookies that apply to |url| given |options|.
273 // The returned cookies are ordered by longest path, then earliest 252 // The returned cookies are ordered by longest path, then earliest
274 // creation date. 253 // creation date.
275 virtual std::string GetCookiesWithOptions(const GURL& url,
276 const CookieOptions& options);
277
278 virtual void GetCookiesWithOptionsAsync( 254 virtual void GetCookiesWithOptionsAsync(
279 const GURL& url, 255 const GURL& url,
280 const CookieOptions& options, 256 const CookieOptions& options,
281 const GetCookiesCallback& callback); 257 const GetCookiesCallback& callback) OVERRIDE;
282 258
283 virtual void GetCookiesWithInfo(const GURL& url, 259 virtual void GetCookiesWithInfoAsync(
284 const CookieOptions& options, 260 const GURL& url,
285 std::string* cookie_line, 261 const CookieOptions& options,
286 std::vector<CookieInfo>* cookie_infos); 262 const GetCookieInfoCallback& callback) OVERRIDE;
287
288 virtual void GetCookiesWithInfoAsync(const GURL& url,
289 const CookieOptions& options,
290 const GetCookieInfoCallback& callback);
291 263
292 // Deletes all cookies with that might apply to |url| that has |cookie_name|. 264 // Deletes all cookies with that might apply to |url| that has |cookie_name|.
293 virtual void DeleteCookie(const GURL& url, const std::string& cookie_name);
294 virtual void DeleteCookieAsync( 265 virtual void DeleteCookieAsync(
295 const GURL& url, const std::string& cookie_name, 266 const GURL& url, const std::string& cookie_name,
296 const base::Closure& callback); 267 const base::Closure& callback) OVERRIDE;
297 268
298 virtual CookieMonster* GetCookieMonster(); 269 virtual CookieMonster* GetCookieMonster() OVERRIDE;
299 270
300 // Debugging method to perform various validation checks on the map. 271 // Debugging method to perform various validation checks on the map.
301 // Currently just checking that there are no null CanonicalCookie pointers 272 // Currently just checking that there are no null CanonicalCookie pointers
302 // in the map. 273 // in the map.
303 // Argument |arg| is to allow retaining of arbitrary data if the CHECKs 274 // Argument |arg| is to allow retaining of arbitrary data if the CHECKs
304 // in the function trip. TODO(rdsmith):Remove hack. 275 // in the function trip. TODO(rdsmith):Remove hack.
305 void ValidateMap(int arg); 276 void ValidateMap(int arg);
306 277
307 // The default list of schemes the cookie monster can handle. 278 // The default list of schemes the cookie monster can handle.
308 static const char* kDefaultCookieableSchemes[]; 279 static const char* kDefaultCookieableSchemes[];
309 static const int kDefaultCookieableSchemesCount; 280 static const int kDefaultCookieableSchemesCount;
310 281
311 private: 282 private:
283 // For queueing the cookie monster calls.
284 class CookieMonsterTask;
285 class DeleteAllCreatedBetweenTask;
286 class DeleteAllForHostTask;
287 class DeleteAllTask;
288 class DeleteCookieTask;
289 class DeleteCanonicalCookieTask;
290 class GetAllCookiesForURLWithOptionsTask;
291 class GetAllCookiesTask;
292 class GetCookiesWithOptionsTask;
293 class GetCookiesWithInfoTask;
294 class SetCookieWithDetailsTask;
295 class SetCookieWithOptionsTask;
296
312 // Testing support. 297 // Testing support.
313 // For SetCookieWithCreationTime. 298 // For SetCookieWithCreationTime.
314 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, 299 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest,
315 TestCookieDeleteAllCreatedBetweenTimestamps); 300 TestCookieDeleteAllCreatedBetweenTimestamps);
316 301
317 // For gargage collection constants. 302 // For gargage collection constants.
318 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); 303 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection);
319 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection); 304 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection);
320 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); 305 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers);
321 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGCTimes); 306 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGCTimes);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 375
391 // Default value for key and expiry scheme scheme. 376 // Default value for key and expiry scheme scheme.
392 static const ExpiryAndKeyScheme expiry_and_key_default_ = 377 static const ExpiryAndKeyScheme expiry_and_key_default_ =
393 EKS_KEEP_RECENT_AND_PURGE_ETLDP1; 378 EKS_KEEP_RECENT_AND_PURGE_ETLDP1;
394 379
395 // Record statistics every kRecordStatisticsIntervalSeconds of uptime. 380 // Record statistics every kRecordStatisticsIntervalSeconds of uptime.
396 static const int kRecordStatisticsIntervalSeconds = 10 * 60; 381 static const int kRecordStatisticsIntervalSeconds = 10 * 60;
397 382
398 virtual ~CookieMonster(); 383 virtual ~CookieMonster();
399 384
385 // The following are synchronous calls to which the asynchronous methods
386 // delegate either immediately (if the store is loaded) or through a deferred
387 // task (if the store is not yet loaded).
388 bool SetCookieWithDetails(const GURL& url,
389 const std::string& name,
390 const std::string& value,
391 const std::string& domain,
392 const std::string& path,
393 const base::Time& expiration_time,
394 bool secure, bool http_only);
395
396 CookieList GetAllCookies();
397
398 CookieList GetAllCookiesForURLWithOptions(const GURL& url,
399 const CookieOptions& options);
400
401 CookieList GetAllCookiesForURL(const GURL& url);
402
403 int DeleteAll(bool sync_to_store);
404
405 int DeleteAllCreatedBetween(const base::Time& delete_begin,
406 const base::Time& delete_end);
407
408 int DeleteAllForHost(const GURL& url);
409
410 bool DeleteCanonicalCookie(const CanonicalCookie& cookie);
411
412 bool SetCookieWithOptions(const GURL& url,
413 const std::string& cookie_line,
414 const CookieOptions& options);
415
416 std::string GetCookiesWithOptions(const GURL& url,
417 const CookieOptions& options);
418
419 void GetCookiesWithInfo(const GURL& url,
420 const CookieOptions& options,
421 std::string* cookie_line,
422 std::vector<CookieInfo>* cookie_infos);
423
424 void DeleteCookie(const GURL& url, const std::string& cookie_name);
425
400 bool SetCookieWithCreationTime(const GURL& url, 426 bool SetCookieWithCreationTime(const GURL& url,
401 const std::string& cookie_line, 427 const std::string& cookie_line,
402 const base::Time& creation_time); 428 const base::Time& creation_time);
403 429
404 // Called by all non-static functions to ensure that the cookies store has 430 // Called by all non-static functions to ensure that the cookies store has
405 // been initialized. This is not done during creating so it doesn't block 431 // been initialized. This is not done during creating so it doesn't block
406 // the window showing. 432 // the window showing.
407 // Note: this method should always be called with lock_ held. 433 // Note: this method should always be called with lock_ held.
408 void InitIfNecessary() { 434 void InitIfNecessary() {
409 if (!initialized_) { 435 if (!initialized_) {
410 if (store_) 436 if (store_) {
411 InitStore(); 437 InitStore();
438 } else {
439 loaded_ = true;
440 }
412 initialized_ = true; 441 initialized_ = true;
413 } 442 }
414 } 443 }
415 444
416 // Initializes the backing store and reads existing cookies from it. 445 // Initializes the backing store and reads existing cookies from it.
417 // Should only be called by InitIfNecessary(). 446 // Should only be called by InitIfNecessary().
418 void InitStore(); 447 void InitStore();
419 448
449 // Stores cookies loaded from the backing store and invokes any deferred
450 // calls.
451 void OnLoaded(const std::vector<CanonicalCookie*>& cookies);
452
453 // Stores the loaded cookies.
454 void StoreLoadedCookies(const std::vector<CanonicalCookie*>& cookies);
455
456 // Invokes deferred calls.
457 void InvokeQueue();
458
420 // Checks that |cookies_| matches our invariants, and tries to repair any 459 // Checks that |cookies_| matches our invariants, and tries to repair any
421 // inconsistencies. (In other words, it does not have duplicate cookies). 460 // inconsistencies. (In other words, it does not have duplicate cookies).
422 void EnsureCookiesMapIsValid(); 461 void EnsureCookiesMapIsValid();
423 462
424 // Checks for any duplicate cookies for CookieMap key |key| which lie between 463 // Checks for any duplicate cookies for CookieMap key |key| which lie between
425 // |begin| and |end|. If any are found, all but the most recent are deleted. 464 // |begin| and |end|. If any are found, all but the most recent are deleted.
426 // Returns the number of duplicate cookies that were deleted. 465 // Returns the number of duplicate cookies that were deleted.
427 int TrimDuplicateCookiesForKey(const std::string& key, 466 int TrimDuplicateCookiesForKey(const std::string& key,
428 CookieMap::iterator begin, 467 CookieMap::iterator begin,
429 CookieMap::iterator end); 468 CookieMap::iterator end);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 void RecordPeriodicStats(const base::Time& current_time); 558 void RecordPeriodicStats(const base::Time& current_time);
520 559
521 // Initialize the above variables; should only be called from 560 // Initialize the above variables; should only be called from
522 // the constructor. 561 // the constructor.
523 void InitializeHistograms(); 562 void InitializeHistograms();
524 563
525 // The resolution of our time isn't enough, so we do something 564 // The resolution of our time isn't enough, so we do something
526 // ugly and increment when we've seen the same time twice. 565 // ugly and increment when we've seen the same time twice.
527 base::Time CurrentTime(); 566 base::Time CurrentTime();
528 567
568 // Run the cookie request task if cookie loaded, otherwise added the task
569 // to task queue.
570 void DoCookieTask(const scoped_refptr<CookieMonsterTask>& task_item);
571
529 // Histogram variables; see CookieMonster::InitializeHistograms() in 572 // Histogram variables; see CookieMonster::InitializeHistograms() in
530 // cookie_monster.cc for details. 573 // cookie_monster.cc for details.
531 base::Histogram* histogram_expiration_duration_minutes_; 574 base::Histogram* histogram_expiration_duration_minutes_;
532 base::Histogram* histogram_between_access_interval_minutes_; 575 base::Histogram* histogram_between_access_interval_minutes_;
533 base::Histogram* histogram_evicted_last_access_minutes_; 576 base::Histogram* histogram_evicted_last_access_minutes_;
534 base::Histogram* histogram_count_; 577 base::Histogram* histogram_count_;
535 base::Histogram* histogram_domain_count_; 578 base::Histogram* histogram_domain_count_;
536 base::Histogram* histogram_etldp1_count_; 579 base::Histogram* histogram_etldp1_count_;
537 base::Histogram* histogram_domain_per_etldp1_count_; 580 base::Histogram* histogram_domain_per_etldp1_count_;
538 base::Histogram* histogram_number_duplicate_db_cookies_; 581 base::Histogram* histogram_number_duplicate_db_cookies_;
539 base::Histogram* histogram_cookie_deletion_cause_; 582 base::Histogram* histogram_cookie_deletion_cause_;
540 base::Histogram* histogram_time_get_; 583 base::Histogram* histogram_time_get_;
541 base::Histogram* histogram_time_mac_; 584 base::Histogram* histogram_time_mac_;
542 base::Histogram* histogram_time_load_; 585 base::Histogram* histogram_time_load_;
543 586
544 CookieMap cookies_; 587 CookieMap cookies_;
545 588
546 // Indicates whether the cookie store has been initialized. This happens 589 // Indicates whether the cookie store has been initialized. This happens
547 // lazily in InitStoreIfNecessary(). 590 // lazily in InitStoreIfNecessary().
548 bool initialized_; 591 bool initialized_;
549 592
593 // Indicates whether loading from the backend store is completed and
594 // calls may be immediately processed.
595 bool loaded_;
596
597 // Queues calls to CookieMonster until loading from the backend store is
598 // completed.
599 std::queue<scoped_refptr<CookieMonsterTask> > queue_;
600
550 // Indicates whether this cookie monster uses the new effective domain 601 // Indicates whether this cookie monster uses the new effective domain
551 // key scheme or not. 602 // key scheme or not.
552 ExpiryAndKeyScheme expiry_and_key_scheme_; 603 ExpiryAndKeyScheme expiry_and_key_scheme_;
553 604
554 scoped_refptr<PersistentCookieStore> store_; 605 scoped_refptr<PersistentCookieStore> store_;
555 606
556 base::Time last_time_seen_; 607 base::Time last_time_seen_;
557 608
558 // Minimum delay after updating a cookie's LastAccessDate before we will 609 // Minimum delay after updating a cookie's LastAccessDate before we will
559 // update it again. 610 // update it again.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 }; 905 };
855 906
856 typedef base::RefCountedThreadSafe<CookieMonster::PersistentCookieStore> 907 typedef base::RefCountedThreadSafe<CookieMonster::PersistentCookieStore>
857 RefcountedPersistentCookieStore; 908 RefcountedPersistentCookieStore;
858 909
859 class CookieMonster::PersistentCookieStore 910 class CookieMonster::PersistentCookieStore
860 : public RefcountedPersistentCookieStore { 911 : public RefcountedPersistentCookieStore {
861 public: 912 public:
862 virtual ~PersistentCookieStore() {} 913 virtual ~PersistentCookieStore() {}
863 914
915 typedef base::Callback<void(const std::vector<
916 CookieMonster::CanonicalCookie*>&)> LoadedCallback;
917
864 // Initializes the store and retrieves the existing cookies. This will be 918 // Initializes the store and retrieves the existing cookies. This will be
865 // called only once at startup. 919 // called only once at startup.
866 virtual bool Load(std::vector<CookieMonster::CanonicalCookie*>* cookies) = 0; 920 virtual bool Load(const LoadedCallback& loaded_callback) = 0;
867 921
868 virtual void AddCookie(const CanonicalCookie& cc) = 0; 922 virtual void AddCookie(const CanonicalCookie& cc) = 0;
869 virtual void UpdateCookieAccessTime(const CanonicalCookie& cc) = 0; 923 virtual void UpdateCookieAccessTime(const CanonicalCookie& cc) = 0;
870 virtual void DeleteCookie(const CanonicalCookie& cc) = 0; 924 virtual void DeleteCookie(const CanonicalCookie& cc) = 0;
871 925
872 // Sets the value of the user preference whether the persistent storage 926 // Sets the value of the user preference whether the persistent storage
873 // must be deleted upon destruction. 927 // must be deleted upon destruction.
874 virtual void SetClearLocalStateOnExit(bool clear_local_state) = 0; 928 virtual void SetClearLocalStateOnExit(bool clear_local_state) = 0;
875 929
876 // Flush the store and post the given Task when complete. 930 // Flush the store and post the given Task when complete.
877 virtual void Flush(Task* completion_task) = 0; 931 virtual void Flush(Task* completion_task) = 0;
878 932
879 protected: 933 protected:
880 PersistentCookieStore() {} 934 PersistentCookieStore() {}
881 935
882 private: 936 private:
883 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 937 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
884 }; 938 };
885 939
886 class CookieList : public std::vector<CookieMonster::CanonicalCookie> { 940 class CookieList : public std::vector<CookieMonster::CanonicalCookie> {
887 }; 941 };
888 942
889 } // namespace net 943 } // namespace net
890 944
891 #endif // NET_BASE_COOKIE_MONSTER_H_ 945 #endif // NET_BASE_COOKIE_MONSTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698