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

Side by Side Diff: chrome/browser/net/sqlite_persistent_cookie_store.cc

Issue 7864008: Split initial load of cookies by domains (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 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 5 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
6 6
erikwright (departed) 2011/09/17 02:22:10 Add "#include <list>" back in. Also include <map>,
guohui 2011/09/20 18:34:46 Done.
7 #include <list>
8
9 #include "base/basictypes.h" 7 #include "base/basictypes.h"
10 #include "base/bind.h" 8 #include "base/bind.h"
11 #include "base/file_path.h" 9 #include "base/file_path.h"
12 #include "base/file_util.h" 10 #include "base/file_util.h"
13 #include "base/logging.h" 11 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
17 #include "base/string_util.h" 15 #include "base/string_util.h"
18 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
19 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
20 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 18 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
21 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
22 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "net/base/registry_controlled_domain.h"
23 #include "sql/meta_table.h" 22 #include "sql/meta_table.h"
24 #include "sql/statement.h" 23 #include "sql/statement.h"
25 #include "sql/transaction.h" 24 #include "sql/transaction.h"
26 25
27 using base::Time; 26 using base::Time;
28 27
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 Could you include a comment at the top of this fil
guohui 2011/09/20 18:34:46 Done.
29 // This class is designed to be shared between any calling threads and the 28 // This class is designed to be shared between any calling threads and the
30 // database thread. It batches operations and commits them on a timer. 29 // database thread. It batches operations and commits them on a timer.
31 // This class expects to be Load()'ed once on any thread. Loading occurs 30 // This class expects to be Load()'ed once on any thread. Loading occurs
32 // asynchronously on the DB thread and the caller will be notified on the IO 31 // asynchronously on the DB thread and the caller will be notified on the IO
33 // thread. Subsequent to loading, mutations may be queued by any thread using 32 // thread. Subsequent to loading, mutations may be queued by any thread using
34 // AddCookie, UpdateCookieAccessTime, and DeleteCookie. These are flushed to 33 // AddCookie, UpdateCookieAccessTime, and DeleteCookie. These are flushed to
35 // disk on the DB thread every 30 seconds, 512 operations, or call to Flush(), 34 // disk on the DB thread every 30 seconds, 512 operations, or call to Flush(),
36 // whichever occurs first. 35 // whichever occurs first.
37 class SQLitePersistentCookieStore::Backend 36 class SQLitePersistentCookieStore::Backend
38 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { 37 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> {
39 public: 38 public:
40 explicit Backend(const FilePath& path) 39 explicit Backend(const FilePath& path)
41 : path_(path), 40 : path_(path),
42 db_(NULL), 41 db_(NULL),
43 num_pending_(0), 42 num_pending_(0),
44 clear_local_state_on_exit_(false) { 43 clear_local_state_on_exit_(false) {
45 } 44 }
46 45
47 // Creates or load the SQLite database. 46 // Creates or load the SQLite database.
48 bool Load(const LoadedCallback& loaded_callback); 47 void Load(const LoadedCallback& loaded_callback);
48
49 // Load cookies for the domain key (eTLD+1).
50 void LoadCookiesForKey(const std::string& domain,
51 const LoadedCallback& loaded_callback);
49 52
50 // Batch a cookie addition. 53 // Batch a cookie addition.
51 void AddCookie(const net::CookieMonster::CanonicalCookie& cc); 54 void AddCookie(const net::CookieMonster::CanonicalCookie& cc);
52 55
53 // Batch a cookie access time update. 56 // Batch a cookie access time update.
54 void UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cc); 57 void UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cc);
55 58
56 // Batch a cookie deletion. 59 // Batch a cookie deletion.
57 void DeleteCookie(const net::CookieMonster::CanonicalCookie& cc); 60 void DeleteCookie(const net::CookieMonster::CanonicalCookie& cc);
58 61
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const net::CookieMonster::CanonicalCookie& cc() const { return cc_; } 96 const net::CookieMonster::CanonicalCookie& cc() const { return cc_; }
94 97
95 private: 98 private:
96 OperationType op_; 99 OperationType op_;
97 net::CookieMonster::CanonicalCookie cc_; 100 net::CookieMonster::CanonicalCookie cc_;
98 }; 101 };
99 102
100 private: 103 private:
101 // Creates or load the SQLite database on DB thread. 104 // Creates or load the SQLite database on DB thread.
102 void LoadAndNotifyOnDBThread(const LoadedCallback& loaded_callback); 105 void LoadAndNotifyOnDBThread(const LoadedCallback& loaded_callback);
103 // Notify the CookieMonster when loading complete. 106
107 // Load cookies for the domain key (eTLD+1) on DB thread.
108 void LoadKeyAndNotifyOnDBThread(const std::string& domains,
109 const LoadedCallback& loaded_callback);
110
111 // Notify the CookieMonster when loading complete for a specific domain key
112 // or for all domain keys. It triggers the callback and passes it all cookies
113 // that have been loaded from DB since last IO notification.
104 void NotifyOnIOThread( 114 void NotifyOnIOThread(
105 const LoadedCallback& loaded_callback, 115 const LoadedCallback& loaded_callback,
106 bool load_success, 116 bool load_success);
107 const std::vector<net::CookieMonster::CanonicalCookie*>& cookies);
108 // Initialize the data base. 117 // Initialize the data base.
118
109 bool InitializeDatabase(); 119 bool InitializeDatabase();
110 // Load cookies to the data base, and read cookies. 120
111 bool LoadInternal(std::vector<net::CookieMonster::CanonicalCookie*>* cookies); 121 // Chain load cookies from DB by domain key.
122 void ChainLoadCookies(const LoadedCallback& loaded_callback);
123
124 // Load all cookies for a set of domains/hosts
125 bool LoadCookiesForDomains(const std::set<std::string>& key);
112 126
113 // Batch a cookie operation (add or delete) 127 // Batch a cookie operation (add or delete)
114 void BatchOperation(PendingOperation::OperationType op, 128 void BatchOperation(PendingOperation::OperationType op,
115 const net::CookieMonster::CanonicalCookie& cc); 129 const net::CookieMonster::CanonicalCookie& cc);
116 // Commit our pending operations to the database. 130 // Commit our pending operations to the database.
117 void Commit(); 131 void Commit();
118 // Close() executed on the background thread. 132 // Close() executed on the background thread.
119 void InternalBackgroundClose(); 133 void InternalBackgroundClose();
120 134
121 FilePath path_; 135 FilePath path_;
122 scoped_ptr<sql::Connection> db_; 136 scoped_ptr<sql::Connection> db_;
123 sql::MetaTable meta_table_; 137 sql::MetaTable meta_table_;
124 138
125 typedef std::list<PendingOperation*> PendingOperationsList; 139 typedef std::list<PendingOperation*> PendingOperationsList;
126 PendingOperationsList pending_; 140 PendingOperationsList pending_;
127 PendingOperationsList::size_type num_pending_; 141 PendingOperationsList::size_type num_pending_;
128 // True if the persistent store should be deleted upon destruction. 142 // True if the persistent store should be deleted upon destruction.
129 bool clear_local_state_on_exit_; 143 bool clear_local_state_on_exit_;
130 // Guard |pending_|, |num_pending_| and |clear_local_state_on_exit_|. 144 // Guard |pending_|, |num_pending_| and |clear_local_state_on_exit_|.
131 base::Lock lock_; 145 base::Lock lock_;
132 146
147 // Temporary buffer for cookies loaded from DB.
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 I'd like a bit more detail on this comment, someth
guohui 2011/09/20 18:34:46 Done.
148 std::vector<net::CookieMonster::CanonicalCookie*> cookies_;
149
150 // Map of domain keys(eTLD+1) to domains/hosts that are to be loaded from DB.
151 std::map<std::string, std::set<std::string>> keys_to_load_;
152
153 // Indicates if DB has been initialized.
154 bool initialized_;
155
133 DISALLOW_COPY_AND_ASSIGN(Backend); 156 DISALLOW_COPY_AND_ASSIGN(Backend);
134 }; 157 };
135 158
136 // Version number of the database. In version 4, we migrated the time epoch. 159 // Version number of the database. In version 4, we migrated the time epoch.
137 // If you open the DB with an older version on Mac or Linux, the times will 160 // If you open the DB with an older version on Mac or Linux, the times will
138 // look wonky, but the file will likely be usable. On Windows version 3 and 4 161 // look wonky, but the file will likely be usable. On Windows version 3 and 4
139 // are the same. 162 // are the same.
140 // 163 //
141 // Version 3 updated the database to include the last access time, so we can 164 // Version 3 updated the database to include the last access time, so we can
142 // expire them in decreasing order of use when we've reached the maximum 165 // expire them in decreasing order of use when we've reached the maximum
(...skipping 17 matching lines...) Expand all
160 "secure INTEGER NOT NULL," 183 "secure INTEGER NOT NULL,"
161 "httponly INTEGER NOT NULL," 184 "httponly INTEGER NOT NULL,"
162 "last_access_utc INTEGER NOT NULL)")) 185 "last_access_utc INTEGER NOT NULL)"))
163 return false; 186 return false;
164 } 187 }
165 188
166 // Try to create the index every time. Older versions did not have this index, 189 // Try to create the index every time. Older versions did not have this index,
167 // so we want those people to get it. Ignore errors, since it may exist. 190 // so we want those people to get it. Ignore errors, since it may exist.
168 db->Execute("CREATE INDEX IF NOT EXISTS cookie_times ON cookies" 191 db->Execute("CREATE INDEX IF NOT EXISTS cookie_times ON cookies"
169 " (creation_utc)"); 192 " (creation_utc)");
193
194 db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)");
195
170 return true; 196 return true;
171 } 197 }
172 198
173 } // namespace 199 } // namespace
174 200
175 bool SQLitePersistentCookieStore::Backend::Load( 201 void SQLitePersistentCookieStore::Backend::Load(
176 const LoadedCallback& loaded_callback) { 202 const LoadedCallback& loaded_callback) {
177 // This function should be called only once per instance. 203 // This function should be called only once per instance.
178 DCHECK(!db_.get()); 204 DCHECK(!db_.get());
179 BrowserThread::PostTask( 205 BrowserThread::PostTask(
180 BrowserThread::DB, FROM_HERE, 206 BrowserThread::DB, FROM_HERE,
181 base::Bind(&Backend::LoadAndNotifyOnDBThread, base::Unretained(this), 207 base::Bind(&Backend::LoadAndNotifyOnDBThread, this, loaded_callback));
182 loaded_callback)); 208 }
183 return true; 209
210 void SQLitePersistentCookieStore::Backend::LoadCookiesForKey(
211 const std::string& key,
212 const LoadedCallback& loaded_callback) {
213 BrowserThread::PostTask(
214 BrowserThread::DB, FROM_HERE,
215 base::Bind(&Backend::LoadKeyAndNotifyOnDBThread, this,
216 key,
217 loaded_callback));
184 } 218 }
185 219
186 void SQLitePersistentCookieStore::Backend::LoadAndNotifyOnDBThread( 220 void SQLitePersistentCookieStore::Backend::LoadAndNotifyOnDBThread(
187 const LoadedCallback& loaded_callback) { 221 const LoadedCallback& loaded_callback) {
188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
189 std::vector<net::CookieMonster::CanonicalCookie*> cookies;
190 223
191 bool load_success = LoadInternal(&cookies); 224 if (!InitializeDatabase()) {
225 BrowserThread::PostTask(
226 BrowserThread::IO, FROM_HERE,
227 base::Bind(&SQLitePersistentCookieStore::Backend::NotifyOnIOThread,
228 this, loaded_callback, false));
229 } else {
230 ChainLoadCookies(loaded_callback);
231 }
232 }
192 233
193 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( 234 void SQLitePersistentCookieStore::Backend::LoadKeyAndNotifyOnDBThread(
194 &SQLitePersistentCookieStore::Backend::NotifyOnIOThread, 235 const std::string& key,
195 base::Unretained(this), loaded_callback, load_success, cookies)); 236 const LoadedCallback& loaded_callback) {
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
238
239 bool success = false;
240 if (InitializeDatabase()) {
241 std::map<std::string, std::set<std::string> >::iterator
242 it = keys_to_load_.find(key);
243 if (it != keys_to_load_.end()) {
244 success = LoadCookiesForDomains(it->second);
245 keys_to_load_.erase(it);
246 } else {
247 success = true;
248 }
249 }
250
251 BrowserThread::PostTask(
252 BrowserThread::IO, FROM_HERE,
253 base::Bind(&SQLitePersistentCookieStore::Backend::NotifyOnIOThread,
254 this, loaded_callback, success));
196 } 255 }
197 256
198 void SQLitePersistentCookieStore::Backend::NotifyOnIOThread( 257 void SQLitePersistentCookieStore::Backend::NotifyOnIOThread(
199 const LoadedCallback& loaded_callback, 258 const LoadedCallback& loaded_callback,
200 bool load_success, 259 bool load_success) {
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 We appear to be completely ignoring failure. That
guohui 2011/09/20 18:34:46 A crbug 97224 is filed for this issue. On 2011/09
201 const std::vector<net::CookieMonster::CanonicalCookie*>& cookies) {
202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
261
262 std::vector<net::CookieMonster::CanonicalCookie*> cookies;
263 {
264 base::AutoLock locked(lock_);
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 Expand the comment on lock_ in the header file to
guohui 2011/09/20 18:34:46 Done.
265 cookies = cookies_;
266 cookies_.clear();
267 }
268
203 loaded_callback.Run(cookies); 269 loaded_callback.Run(cookies);
204 } 270 }
205 271
206 bool SQLitePersistentCookieStore::Backend::InitializeDatabase() { 272 bool SQLitePersistentCookieStore::Backend::InitializeDatabase() {
273 if (initialized_) {
274 return true;
275 }
276
207 const FilePath dir = path_.DirName(); 277 const FilePath dir = path_.DirName();
208 if (!file_util::PathExists(dir) && !file_util::CreateDirectory(dir)) { 278 if (!file_util::PathExists(dir) && !file_util::CreateDirectory(dir)) {
209 return false; 279 return false;
210 } 280 }
211 281
212 db_.reset(new sql::Connection); 282 db_.reset(new sql::Connection);
213 if (!db_->Open(path_)) { 283 if (!db_->Open(path_)) {
214 NOTREACHED() << "Unable to open cookie DB."; 284 NOTREACHED() << "Unable to open cookie DB.";
215 db_.reset(); 285 db_.reset();
216 return false; 286 return false;
217 } 287 }
218 288
219 db_->set_error_delegate(GetErrorHandlerForCookieDb()); 289 db_->set_error_delegate(GetErrorHandlerForCookieDb());
220 290
221 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) { 291 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) {
222 NOTREACHED() << "Unable to open cookie DB."; 292 NOTREACHED() << "Unable to open cookie DB.";
223 db_.reset(); 293 db_.reset();
224 return false; 294 return false;
225 } 295 }
226 296
227 db_->Preload(); 297 db_->Preload();
228 return true;
229 }
230 298
231 bool SQLitePersistentCookieStore::Backend::LoadInternal( 299 // Retrieve all the domains
232 std::vector<net::CookieMonster::CanonicalCookie*>* cookies) { 300 sql::Statement smt(db_->GetUniqueStatement(
233 if (!InitializeDatabase()) { 301 "SELECT DISTINCT host_key FROM cookies"));
234 return false;
235 }
236 302
237 // Slurp all the cookies into the out-vector.
238 sql::Statement smt(db_->GetUniqueStatement(
239 "SELECT creation_utc, host_key, name, value, path, expires_utc, secure, "
240 "httponly, last_access_utc FROM cookies"));
241 if (!smt) { 303 if (!smt) {
242 NOTREACHED() << "select statement prep failed"; 304 NOTREACHED() << "select statement prep failed";
243 db_.reset(); 305 db_.reset();
244 return false; 306 return false;
245 } 307 }
246 308
309 // Build a map of domain keys (eTLD+1) to domains.
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 I believe the code is correct, but I kept getting
guohui 2011/09/20 18:34:46 Done.
247 while (smt.Step()) { 310 while (smt.Step()) {
248 scoped_ptr<net::CookieMonster::CanonicalCookie> cc( 311 std::string domain = smt.ColumnString(0);
249 new net::CookieMonster::CanonicalCookie( 312 std::string key =
250 // The "source" URL is not used with persisted cookies. 313 net::RegistryControlledDomainService::GetDomainAndRegistry(domain);
251 GURL(), // Source 314
252 smt.ColumnString(2), // name 315 std::map<std::string, std::set<std::string> >::iterator it =
253 smt.ColumnString(3), // value 316 keys_to_load_.find(key);
254 smt.ColumnString(1), // domain 317 if (it == keys_to_load_.end()) {
255 smt.ColumnString(4), // path 318 std::set<std::string> domains;
256 std::string(), // TODO(abarth): Persist mac_key 319 domains.insert(domain);
257 std::string(), // TODO(abarth): Persist mac_algorithm 320 keys_to_load_.insert(
258 Time::FromInternalValue(smt.ColumnInt64(0)), // creation_utc 321 std::pair<std::string, std::set<std::string> >(key, domains));
259 Time::FromInternalValue(smt.ColumnInt64(5)), // expires_utc 322 } else {
260 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc 323 it->second.insert(domain);
261 smt.ColumnInt(6) != 0, // secure 324 }
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 nit, suggestion: I'd find this code slightly easie
grt (UTC plus 2) 2011/09/19 02:20:40 owing to the awesomeness of STL containers, you ca
guohui 2011/09/20 18:34:46 Thanks for the nice STL tip. Your code is indeed m
262 smt.ColumnInt(7) != 0, // httponly 325 }
263 true)); // has_expires 326
264 DLOG_IF(WARNING, 327 initialized_ = true;
265 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; 328 return true;
266 cookies->push_back(cc.release()); 329 }
330
331 void SQLitePersistentCookieStore::Backend::ChainLoadCookies(
332 const LoadedCallback& loaded_callback) {
333 bool load_success = true;
334
335 if (keys_to_load_.size() > 0) {
336 // Load cookies for the first domain key.
337 std::map<std::string, std::set<std::string> >::iterator
338 it = keys_to_load_.begin();
339 load_success = LoadCookiesForDomains(it->second);
340 keys_to_load_.erase(it);
341 }
342
343 // If load is successful and there are more domain keys to be loaded,
344 // then post a DB task to continue chain-load;
345 // Otherwise notify on IO thread.
346 if (load_success && keys_to_load_.size() > 0) {
347 BrowserThread::PostTask(
348 BrowserThread::DB, FROM_HERE,
349 base::Bind(&Backend::ChainLoadCookies, this, loaded_callback));
350 } else {
351 BrowserThread::PostTask(
352 BrowserThread::IO, FROM_HERE,
353 base::Bind(&SQLitePersistentCookieStore::Backend::NotifyOnIOThread,
354 this, loaded_callback, load_success));
355 }
356 }
357
358 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains(
359 const std::set<std::string>& domains) {
360 base::AutoLock locked(lock_);
Randy Smith (Not in Mondays) 2011/09/19 00:58:57 What is this protecting? I twitch at holding a lo
guohui 2011/09/20 18:34:46 Done.
361
362 sql::Statement smt(db_->GetCachedStatement(SQL_FROM_HERE,
363 "SELECT creation_utc, host_key, name, value, path, expires_utc, secure, "
364 "httponly, last_access_utc FROM cookies WHERE host_key = ?"));
365 if (!smt) {
366 NOTREACHED() << "select statement prep failed";
367 db_.reset();
368 return false;
369 }
370
371 std::set<std::string>::const_iterator it = domains.begin();
372 for (; it != domains.end(); ++it) {
373 smt.BindString(0, *it);
374 while (smt.Step()) {
375 scoped_ptr<net::CookieMonster::CanonicalCookie> cc(
376 new net::CookieMonster::CanonicalCookie(
377 // The "source" URL is not used with persisted cookies.
378 GURL(), // Source
379 smt.ColumnString(2), // name
380 smt.ColumnString(3), // value
381 smt.ColumnString(1), // domain
382 smt.ColumnString(4), // path
383 std::string(), // TODO(abarth): Persist mac_key
384 std::string(), // TODO(abarth): Persist mac_algorithm
385 Time::FromInternalValue(smt.ColumnInt64(0)), // creation_utc
386 Time::FromInternalValue(smt.ColumnInt64(5)), // expires_utc
387 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc
388 smt.ColumnInt(6) != 0, // secure
389 smt.ColumnInt(7) != 0, // httponly
390 true)); // has_expires
391 DLOG_IF(WARNING,
392 cc->CreationDate() > Time::Now()) << L"CreationDate too recent";
393 cookies_.push_back(cc.release());
394 }
395 smt.Reset();
267 } 396 }
268 397
269 return true; 398 return true;
270 } 399 }
271 400
272 bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() { 401 bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() {
273 // Version check. 402 // Version check.
274 if (!meta_table_.Init( 403 if (!meta_table_.Init(
275 db_.get(), kCurrentVersionNumber, kCompatibleVersionNumber)) { 404 db_.get(), kCurrentVersionNumber, kCompatibleVersionNumber)) {
276 return false; 405 return false;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 656
528 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { 657 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
529 if (backend_.get()) { 658 if (backend_.get()) {
530 backend_->Close(); 659 backend_->Close();
531 // Release our reference, it will probably still have a reference if the 660 // Release our reference, it will probably still have a reference if the
532 // background thread has not run Close() yet. 661 // background thread has not run Close() yet.
533 backend_ = NULL; 662 backend_ = NULL;
534 } 663 }
535 } 664 }
536 665
537 bool SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) { 666 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) {
538 return backend_->Load(loaded_callback); 667 backend_->Load(loaded_callback);
668 }
669
670 void SQLitePersistentCookieStore::LoadCookiesForKey(
671 const std::string& key,
672 const LoadedCallback& loaded_callback) {
673 backend_->LoadCookiesForKey(key, loaded_callback);
539 } 674 }
540 675
541 void SQLitePersistentCookieStore::AddCookie( 676 void SQLitePersistentCookieStore::AddCookie(
542 const net::CookieMonster::CanonicalCookie& cc) { 677 const net::CookieMonster::CanonicalCookie& cc) {
543 if (backend_.get()) 678 if (backend_.get())
544 backend_->AddCookie(cc); 679 backend_->AddCookie(cc);
545 } 680 }
546 681
547 void SQLitePersistentCookieStore::UpdateCookieAccessTime( 682 void SQLitePersistentCookieStore::UpdateCookieAccessTime(
548 const net::CookieMonster::CanonicalCookie& cc) { 683 const net::CookieMonster::CanonicalCookie& cc) {
(...skipping 12 matching lines...) Expand all
561 if (backend_.get()) 696 if (backend_.get())
562 backend_->SetClearLocalStateOnExit(clear_local_state); 697 backend_->SetClearLocalStateOnExit(clear_local_state);
563 } 698 }
564 699
565 void SQLitePersistentCookieStore::Flush(Task* completion_task) { 700 void SQLitePersistentCookieStore::Flush(Task* completion_task) {
566 if (backend_.get()) 701 if (backend_.get())
567 backend_->Flush(completion_task); 702 backend_->Flush(completion_task);
568 else if (completion_task) 703 else if (completion_task)
569 MessageLoop::current()->PostTask(FROM_HERE, completion_task); 704 MessageLoop::current()->PostTask(FROM_HERE, completion_task);
570 } 705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698