| OLD | NEW |
| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 if (!EnsureDatabaseVersion(db) || !InitTable(db)) { | 330 if (!EnsureDatabaseVersion(db) || !InitTable(db)) { |
| 331 NOTREACHED() << "Unable to initialize cookie DB."; | 331 NOTREACHED() << "Unable to initialize cookie DB."; |
| 332 sqlite3_close(db); | 332 sqlite3_close(db); |
| 333 return false; | 333 return false; |
| 334 } | 334 } |
| 335 | 335 |
| 336 PrimeCache(db); | 336 PrimeCache(db); |
| 337 // Size cookies |
| 338 SQLStatement c_smt; |
| 339 if (c_smt.prepare(db, |
| 340 "SELECT count(*) FROM cookies") != SQLITE_OK) { |
| 341 NOTREACHED() << "select statement prep failed"; |
| 342 sqlite3_close(db); |
| 343 return false; |
| 344 } |
| 345 while (c_smt.step() == SQLITE_ROW) { |
| 346 cookies->reserve(c_smt.column_int(0)); |
| 347 } |
| 348 |
| 337 | 349 |
| 338 // Slurp all the cookies into the out-vector. | 350 // Slurp all the cookies into the out-vector. |
| 339 SQLStatement smt; | 351 SQLStatement smt; |
| 340 if (smt.prepare(db, | 352 if (smt.prepare(db, |
| 341 "SELECT creation_utc, host_key, name, value, path, expires_utc, secure, " | 353 "SELECT creation_utc, host_key, name, value, path, expires_utc, secure, " |
| 342 "httponly, last_access_utc FROM cookies") != SQLITE_OK) { | 354 "httponly, last_access_utc FROM cookies") != SQLITE_OK) { |
| 343 NOTREACHED() << "select statement prep failed"; | 355 NOTREACHED() << "select statement prep failed"; |
| 344 sqlite3_close(db); | 356 sqlite3_close(db); |
| 345 return false; | 357 return false; |
| 346 } | 358 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 const net::CookieMonster::CanonicalCookie& cc) { | 439 const net::CookieMonster::CanonicalCookie& cc) { |
| 428 if (backend_.get()) | 440 if (backend_.get()) |
| 429 backend_->UpdateCookieAccessTime(cc); | 441 backend_->UpdateCookieAccessTime(cc); |
| 430 } | 442 } |
| 431 | 443 |
| 432 void SQLitePersistentCookieStore::DeleteCookie( | 444 void SQLitePersistentCookieStore::DeleteCookie( |
| 433 const net::CookieMonster::CanonicalCookie& cc) { | 445 const net::CookieMonster::CanonicalCookie& cc) { |
| 434 if (backend_.get()) | 446 if (backend_.get()) |
| 435 backend_->DeleteCookie(cc); | 447 backend_->DeleteCookie(cc); |
| 436 } | 448 } |
| OLD | NEW |