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

Side by Side Diff: chrome/common/net/cookie_monster_sqlite.cc

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.h ('k') | net/base/cookie_monster.h » ('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 #include "chrome/common/net/cookie_monster_sqlite.h" 5 #include "chrome/common/net/cookie_monster_sqlite.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // so we want those people to get it. Ignore errors, since it may exist. 299 // so we want those people to get it. Ignore errors, since it may exist.
300 sqlite3_exec(db, "CREATE INDEX cookie_times ON cookies (creation_utc)", 300 sqlite3_exec(db, "CREATE INDEX cookie_times ON cookies (creation_utc)",
301 NULL, NULL, NULL); 301 NULL, NULL, NULL);
302 302
303 return true; 303 return true;
304 } 304 }
305 305
306 } // namespace 306 } // namespace
307 307
308 bool SQLitePersistentCookieStore::Load( 308 bool SQLitePersistentCookieStore::Load(
309 std::vector<net::CookieMonster::KeyedCanonicalCookie>* cookies) { 309 std::vector<net::CookieMonster::KeyedCanonicalCookie>* cookies,
310 base::Time* least_recent_access) {
310 DCHECK(!path_.empty()); 311 DCHECK(!path_.empty());
311 sqlite3* db; 312 sqlite3* db;
312 if (sqlite3_open(WideToUTF8(path_).c_str(), &db) != SQLITE_OK) { 313 if (sqlite3_open(WideToUTF8(path_).c_str(), &db) != SQLITE_OK) {
313 NOTREACHED() << "Unable to open cookie DB."; 314 NOTREACHED() << "Unable to open cookie DB.";
314 return false; 315 return false;
315 } 316 }
316 317
317 if (!EnsureDatabaseVersion(db) || !InitTable(db)) { 318 if (!EnsureDatabaseVersion(db) || !InitTable(db)) {
318 NOTREACHED() << "Unable to initialize cookie DB."; 319 NOTREACHED() << "Unable to initialize cookie DB.";
319 sqlite3_close(db); 320 sqlite3_close(db);
(...skipping 22 matching lines...) Expand all
342 smt.column_int(6) != 0, // secure 343 smt.column_int(6) != 0, // secure
343 smt.column_int(7) != 0, // httponly 344 smt.column_int(7) != 0, // httponly
344 Time::FromInternalValue(smt.column_int64(0)), // creation_utc 345 Time::FromInternalValue(smt.column_int64(0)), // creation_utc
345 Time::FromInternalValue(smt.column_int64(8)), // last_access_utc 346 Time::FromInternalValue(smt.column_int64(8)), // last_access_utc
346 true, // has_expires 347 true, // has_expires
347 Time::FromInternalValue(smt.column_int64(5)))); // expires_utc 348 Time::FromInternalValue(smt.column_int64(5)))); // expires_utc
348 // Memory allocation failed. 349 // Memory allocation failed.
349 if (!cc.get()) 350 if (!cc.get())
350 break; 351 break;
351 352
353 const base::Time last_access = cc->LastAccessDate();
354 if (least_recent_access->is_null() || (last_access < *least_recent_access))
355 *least_recent_access = last_access;
356
352 DLOG_IF(WARNING, 357 DLOG_IF(WARNING,
353 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; 358 cc->CreationDate() > Time::Now()) << L"CreationDate too recent";
354 cookies->push_back( 359 cookies->push_back(
355 net::CookieMonster::KeyedCanonicalCookie(smt.column_string(1), 360 net::CookieMonster::KeyedCanonicalCookie(smt.column_string(1),
356 cc.release())); 361 cc.release()));
357 } 362 }
358 363
359 // Create the backend, this will take ownership of the db pointer. 364 // Create the backend, this will take ownership of the db pointer.
360 backend_ = new Backend(db, background_loop_); 365 backend_ = new Backend(db, background_loop_);
361 366
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const net::CookieMonster::CanonicalCookie& cc) { 419 const net::CookieMonster::CanonicalCookie& cc) {
415 if (backend_.get()) 420 if (backend_.get())
416 backend_->UpdateCookieAccessTime(cc); 421 backend_->UpdateCookieAccessTime(cc);
417 } 422 }
418 423
419 void SQLitePersistentCookieStore::DeleteCookie( 424 void SQLitePersistentCookieStore::DeleteCookie(
420 const net::CookieMonster::CanonicalCookie& cc) { 425 const net::CookieMonster::CanonicalCookie& cc) {
421 if (backend_.get()) 426 if (backend_.get())
422 backend_->DeleteCookie(cc); 427 backend_->DeleteCookie(cc);
423 } 428 }
OLDNEW
« no previous file with comments | « chrome/common/net/cookie_monster_sqlite.h ('k') | net/base/cookie_monster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698