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

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

Issue 99100: Update cookie expiry policy to attempt to avoid deleting "in-use" cookies. S... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/net/cookie_monster_sqlite.cc ('k') | net/base/cookie_monster.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void InternalDeleteCookie(CookieMap::iterator it, bool sync_to_store); 178 void InternalDeleteCookie(CookieMap::iterator it, bool sync_to_store);
179 179
180 // If the number of cookies for host |key|, or globally, are over preset 180 // If the number of cookies for host |key|, or globally, are over preset
181 // maximums, garbage collects, first for the host and then globally, as 181 // maximums, garbage collects, first for the host and then globally, as
182 // described by GarbageCollectRange(). The limits can be found as constants 182 // described by GarbageCollectRange(). The limits can be found as constants
183 // at the top of the function body. 183 // at the top of the function body.
184 // 184 //
185 // Returns the number of cookies deleted (useful for debugging). 185 // Returns the number of cookies deleted (useful for debugging).
186 int GarbageCollect(const base::Time& current, const std::string& key); 186 int GarbageCollect(const base::Time& current, const std::string& key);
187 187
188 // Deletes all expired cookies in |itpair|; 188 // Deletes all expired cookies in |itpair|; then, if the number of remaining
189 // then, if the number of remaining cookies is greater than |num_max|, 189 // cookies is greater than |max_cookies|, collects the least recently accessed
190 // collects the least recently accessed cookies until 190 // cookies until that many cookies remain. If |purge_age| is non-zero, only
191 // (|num_max| - |num_purge|) cookies remain. 191 // cookies accessed longer ago than |purge_age| are collected.
192 // 192 //
193 // Returns the number of cookies deleted. 193 // Returns the number of cookies deleted.
194 int GarbageCollectRange(const base::Time& current, 194 int GarbageCollectRange(const base::Time& current,
195 const CookieMapItPair& itpair, 195 const CookieMapItPair& itpair,
196 size_t num_max, 196 size_t max_cookies,
197 size_t num_purge); 197 const base::TimeDelta& purge_age);
198 198
199 // Helper for GarbageCollectRange(); can be called directly as well. Deletes 199 // Helper for GarbageCollectRange(); can be called directly as well. Deletes
200 // all expired cookies in |itpair|. If |cookie_its| is non-NULL, it is 200 // all expired cookies in |itpair|. If |cookie_its| is non-NULL, it is
201 // populated with all the non-expired cookies from |itpair|. 201 // populated with all the non-expired cookies from |itpair|.
202 // 202 //
203 // Returns the number of cookies deleted. 203 // Returns the number of cookies deleted.
204 int GarbageCollectExpired(const base::Time& current, 204 int GarbageCollectExpired(const base::Time& current,
205 const CookieMapItPair& itpair, 205 const CookieMapItPair& itpair,
206 std::vector<CookieMap::iterator>* cookie_its); 206 std::vector<CookieMap::iterator>* cookie_its);
207 207
208 bool HasCookieableScheme(const GURL& url); 208 bool HasCookieableScheme(const GURL& url);
209 209
210 CookieMap cookies_; 210 CookieMap cookies_;
211 211
212 // The last-accessed time of the oldest (LRU) cookie in the DB.
213 base::Time least_recent_access_;
214
212 // Indicates whether the cookie store has been initialized. This happens 215 // Indicates whether the cookie store has been initialized. This happens
213 // lazily in InitStoreIfNecessary(). 216 // lazily in InitStoreIfNecessary().
214 bool initialized_; 217 bool initialized_;
215 218
216 PersistentCookieStore* store_; 219 PersistentCookieStore* store_;
217 220
218 // The resolution of our time isn't enough, so we do something 221 // The resolution of our time isn't enough, so we do something
219 // ugly and increment when we've seen the same time twice. 222 // ugly and increment when we've seen the same time twice.
220 base::Time CurrentTime(); 223 base::Time CurrentTime();
221 base::Time last_time_seen_; 224 base::Time last_time_seen_;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 bool secure_; 369 bool secure_;
367 bool httponly_; 370 bool httponly_;
368 }; 371 };
369 372
370 class CookieMonster::PersistentCookieStore { 373 class CookieMonster::PersistentCookieStore {
371 public: 374 public:
372 virtual ~PersistentCookieStore() { } 375 virtual ~PersistentCookieStore() { }
373 376
374 // Initializes the store and retrieves the existing cookies. This will be 377 // Initializes the store and retrieves the existing cookies. This will be
375 // called only once at startup. 378 // called only once at startup.
376 virtual bool Load(std::vector<CookieMonster::KeyedCanonicalCookie>*) = 0; 379 // The second argument will be set to the oldest last-accessed date seen.
380 virtual bool Load(std::vector<CookieMonster::KeyedCanonicalCookie>*,
381 base::Time*) = 0;
377 382
378 virtual void AddCookie(const std::string&, const CanonicalCookie&) = 0; 383 virtual void AddCookie(const std::string&, const CanonicalCookie&) = 0;
379 virtual void UpdateCookieAccessTime(const CanonicalCookie&) = 0; 384 virtual void UpdateCookieAccessTime(const CanonicalCookie&) = 0;
380 virtual void DeleteCookie(const CanonicalCookie&) = 0; 385 virtual void DeleteCookie(const CanonicalCookie&) = 0;
381 386
382 protected: 387 protected:
383 PersistentCookieStore() { } 388 PersistentCookieStore() { }
384 389
385 private: 390 private:
386 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 391 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
387 }; 392 };
388 393
389 } // namespace net 394 } // namespace net
390 395
391 #endif // NET_BASE_COOKIE_MONSTER_H_ 396 #endif // NET_BASE_COOKIE_MONSTER_H_
OLDNEW
« no previous file with comments | « chrome/common/net/cookie_monster_sqlite.cc ('k') | net/base/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698