diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 22:44:47 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 22:44:47 +0000 |
commit | 5a27c4e572667598b5c1d4b5cd6febdc719b2405 (patch) | |
tree | 74375c1e6c31d907a8534b0615efa885bd7e61d5 /chrome/common/net | |
parent | fc0ae8a66e5c1cd545c50e3cf2c23070bfab5501 (diff) | |
download | chromium_src-5a27c4e572667598b5c1d4b5cd6febdc719b2405.zip chromium_src-5a27c4e572667598b5c1d4b5cd6febdc719b2405.tar.gz chromium_src-5a27c4e572667598b5c1d4b5cd6febdc719b2405.tar.bz2 |
Actually preload the cookie database. The previous logic was inverted.
Review URL: http://codereview.chromium.org/9183
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net')
-rw-r--r-- | chrome/common/net/cookie_monster_sqlite.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/chrome/common/net/cookie_monster_sqlite.cc b/chrome/common/net/cookie_monster_sqlite.cc index 11bb002..0cb49ca 100644 --- a/chrome/common/net/cookie_monster_sqlite.cc +++ b/chrome/common/net/cookie_monster_sqlite.cc @@ -303,6 +303,19 @@ bool InitTable(sqlite3* db) { return true; } +void PrimeCache(sqlite3* db) { + // A statement must be open for the preload command to work. If the meta + // table can't be read, it probably means this is a new database and there + // is nothing to preload (so it's OK we do nothing). + SQLStatement dummy; + if (dummy.prepare(db, "SELECT * from meta") != SQLITE_OK) + return; + if (dummy.step() != SQLITE_ROW) + return; + + sqlite3Preload(db); +} + } // namespace bool SQLitePersistentCookieStore::Load( @@ -320,6 +333,8 @@ bool SQLitePersistentCookieStore::Load( return false; } + PrimeCache(db); + // Slurp all the cookies into the out-vector. SQLStatement smt; if (smt.prepare(db, @@ -330,17 +345,6 @@ bool SQLitePersistentCookieStore::Load( return false; } - // Step the statement and do the preload operation. Preload() requires that a - // statement be open on the database, so we oblige. We don't bother keeping - // this and reset the statement so we can read all the rows. - // - // The Preload call makes the read faster, since we will be reading most of - // the database, it's better to read it in one chunk than have a lot of seeks - // bringing it in organically. - if (smt.step() != SQLITE_ROW) - sqlite3Preload(db); - smt.reset(); - while (smt.step() == SQLITE_ROW) { std::string key = smt.column_string(1); scoped_ptr<net::CookieMonster::CanonicalCookie> cc( |