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

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

Issue 12342030: Revert 184868 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/location.h"
18 #include "base/logging.h" 17 #include "base/logging.h"
19 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
21 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
22 #include "base/sequenced_task_runner.h"
23 #include "base/string_util.h" 21 #include "base/string_util.h"
24 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "base/threading/thread.h"
25 #include "base/time.h" 24 #include "base/time.h"
26 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 25 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
27 #include "chrome/browser/net/clear_on_exit_policy.h" 26 #include "chrome/browser/net/clear_on_exit_policy.h"
27 #include "content/public/browser/browser_thread.h"
28 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
30 #include "net/cookies/canonical_cookie.h" 30 #include "net/cookies/canonical_cookie.h"
31 #include "sql/error_delegate_util.h" 31 #include "sql/error_delegate_util.h"
32 #include "sql/meta_table.h" 32 #include "sql/meta_table.h"
33 #include "sql/statement.h" 33 #include "sql/statement.h"
34 #include "sql/transaction.h" 34 #include "sql/transaction.h"
35 #include "third_party/sqlite/sqlite3.h" 35 #include "third_party/sqlite/sqlite3.h"
36 36
37 using base::Time; 37 using base::Time;
38 using content::BrowserThread;
38 39
39 // This class is designed to be shared between any client thread and the 40 // This class is designed to be shared between any calling threads and the
40 // background task runner. It batches operations and commits them on a timer. 41 // database thread. It batches operations and commits them on a timer.
41 // 42 //
42 // SQLitePersistentCookieStore::Load is called to load all cookies. It 43 // SQLitePersistentCookieStore::Load is called to load all cookies. It
43 // delegates to Backend::Load, which posts a Backend::LoadAndNotifyOnDBThread 44 // delegates to Backend::Load, which posts a Backend::LoadAndNotifyOnDBThread
44 // task to the background runner. This task calls Backend::ChainLoadCookies(), 45 // task to the DB thread. This task calls Backend::ChainLoadCookies(), which
45 // which repeatedly posts itself to the BG runner to load each eTLD+1's cookies 46 // repeatedly posts itself to the DB thread to load each eTLD+1's cookies in
46 // in separate tasks. When this is complete, Backend::CompleteLoadOnIOThread is 47 // separate tasks. When this is complete, Backend::CompleteLoadOnIOThread is
47 // posted to the client runner, which notifies the caller of 48 // posted to the IO thread, which notifies the caller of
48 // SQLitePersistentCookieStore::Load that the load is complete. 49 // SQLitePersistentCookieStore::Load that the load is complete.
49 // 50 //
50 // If a priority load request is invoked via SQLitePersistentCookieStore:: 51 // If a priority load request is invoked via SQLitePersistentCookieStore::
51 // LoadCookiesForKey, it is delegated to Backend::LoadCookiesForKey, which posts 52 // LoadCookiesForKey, it is delegated to Backend::LoadCookiesForKey, which posts
52 // Backend::LoadKeyAndNotifyOnDBThread to the BG runner. That routine loads just 53 // Backend::LoadKeyAndNotifyOnDBThread to the DB thread. That routine loads just
53 // that single domain key (eTLD+1)'s cookies, and posts a Backend:: 54 // that single domain key (eTLD+1)'s cookies, and posts a Backend::
54 // CompleteLoadForKeyOnIOThread to the client runner to notify the caller of 55 // CompleteLoadForKeyOnIOThread to the IO thread to notify the caller of
55 // SQLitePersistentCookieStore::LoadCookiesForKey that that load is complete. 56 // SQLitePersistentCookieStore::LoadCookiesForKey that that load is complete.
56 // 57 //
57 // Subsequent to loading, mutations may be queued by any thread using 58 // Subsequent to loading, mutations may be queued by any thread using
58 // AddCookie, UpdateCookieAccessTime, and DeleteCookie. These are flushed to 59 // AddCookie, UpdateCookieAccessTime, and DeleteCookie. These are flushed to
59 // disk on the BG runner every 30 seconds, 512 operations, or call to Flush(), 60 // disk on the DB thread every 30 seconds, 512 operations, or call to Flush(),
60 // whichever occurs first. 61 // whichever occurs first.
61 class SQLitePersistentCookieStore::Backend 62 class SQLitePersistentCookieStore::Backend
62 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { 63 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> {
63 public: 64 public:
64 Backend( 65 Backend(const base::FilePath& path,
65 const base::FilePath& path, 66 bool restore_old_session_cookies,
66 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, 67 ClearOnExitPolicy* clear_on_exit_policy)
67 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
68 bool restore_old_session_cookies,
69 ClearOnExitPolicy* clear_on_exit_policy)
70 : path_(path), 68 : path_(path),
71 db_(NULL), 69 db_(NULL),
72 num_pending_(0), 70 num_pending_(0),
73 force_keep_session_state_(false), 71 force_keep_session_state_(false),
74 initialized_(false), 72 initialized_(false),
75 corruption_detected_(false), 73 corruption_detected_(false),
76 restore_old_session_cookies_(restore_old_session_cookies), 74 restore_old_session_cookies_(restore_old_session_cookies),
77 clear_on_exit_policy_(clear_on_exit_policy), 75 clear_on_exit_policy_(clear_on_exit_policy),
78 num_cookies_read_(0), 76 num_cookies_read_(0),
79 client_task_runner_(client_task_runner),
80 background_task_runner_(background_task_runner),
81 num_priority_waiting_(0), 77 num_priority_waiting_(0),
82 total_priority_requests_(0) { 78 total_priority_requests_(0) {
83 } 79 }
84 80
85 // Creates or loads the SQLite database. 81 // Creates or loads the SQLite database.
86 void Load(const LoadedCallback& loaded_callback); 82 void Load(const LoadedCallback& loaded_callback);
87 83
88 // Loads cookies for the domain key (eTLD+1). 84 // Loads cookies for the domain key (eTLD+1).
89 void LoadCookiesForKey(const std::string& domain, 85 void LoadCookiesForKey(const std::string& domain,
90 const LoadedCallback& loaded_callback); 86 const LoadedCallback& loaded_callback);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 150
155 OperationType op() const { return op_; } 151 OperationType op() const { return op_; }
156 const net::CanonicalCookie& cc() const { return cc_; } 152 const net::CanonicalCookie& cc() const { return cc_; }
157 153
158 private: 154 private:
159 OperationType op_; 155 OperationType op_;
160 net::CanonicalCookie cc_; 156 net::CanonicalCookie cc_;
161 }; 157 };
162 158
163 private: 159 private:
164 // Creates or loads the SQLite database on background runner. 160 // Creates or loads the SQLite database on DB thread.
165 void LoadAndNotifyInBackground(const LoadedCallback& loaded_callback, 161 void LoadAndNotifyOnDBThread(const LoadedCallback& loaded_callback,
166 const base::Time& posted_at); 162 const base::Time& posted_at);
167 163
168 // Loads cookies for the domain key (eTLD+1) on background runner. 164 // Loads cookies for the domain key (eTLD+1) on DB thread.
169 void LoadKeyAndNotifyInBackground(const std::string& domains, 165 void LoadKeyAndNotifyOnDBThread(const std::string& domains,
170 const LoadedCallback& loaded_callback, 166 const LoadedCallback& loaded_callback,
171 const base::Time& posted_at); 167 const base::Time& posted_at);
172 168
173 // Notifies the CookieMonster when loading completes for a specific domain key 169 // Notifies the CookieMonster when loading completes for a specific domain key
174 // or for all domain keys. Triggers the callback and passes it all cookies 170 // or for all domain keys. Triggers the callback and passes it all cookies
175 // that have been loaded from DB since last IO notification. 171 // that have been loaded from DB since last IO notification.
176 void Notify(const LoadedCallback& loaded_callback, bool load_success); 172 void Notify(const LoadedCallback& loaded_callback, bool load_success);
177 173
178 // Sends notification when the entire store is loaded, and reports metrics 174 // Sends notification when the entire store is loaded, and reports metrics
179 // for the total time to load and aggregated results from any priority loads 175 // for the total time to load and aggregated results from any priority loads
180 // that occurred. 176 // that occurred.
181 void CompleteLoadInForeground(const LoadedCallback& loaded_callback, 177 void CompleteLoadOnIOThread(const LoadedCallback& loaded_callback,
182 bool load_success); 178 bool load_success);
183 179
184 // Sends notification when a single priority load completes. Updates priority 180 // Sends notification when a single priority load completes. Updates priority
185 // load metric data. The data is sent only after the final load completes. 181 // load metric data. The data is sent only after the final load completes.
186 void CompleteLoadForKeyInForeground(const LoadedCallback& loaded_callback, 182 void CompleteLoadForKeyOnIOThread(const LoadedCallback& loaded_callback,
187 bool load_success); 183 bool load_success);
188 184
189 // Sends all metrics, including posting a ReportMetricsInBackground task. 185 // Sends all metrics, including posting a ReportMetricsOnDBThread task.
190 // Called after all priority and regular loading is complete. 186 // Called after all priority and regular loading is complete.
191 void ReportMetrics(); 187 void ReportMetrics();
192 188
193 // Sends background-runner owned metrics (i.e., the combined duration of all 189 // Sends DB-thread owned metrics (i.e., the combined duration of all DB-thread
194 // BG-runner tasks). 190 // tasks).
195 void ReportMetricsInBackground(); 191 void ReportMetricsOnDBThread();
196 192
197 // Initialize the data base. 193 // Initialize the data base.
198 bool InitializeDatabase(); 194 bool InitializeDatabase();
199 195
200 // Loads cookies for the next domain key from the DB, then either reschedules 196 // Loads cookies for the next domain key from the DB, then either reschedules
201 // itself or schedules the provided callback to run on the client runner (if 197 // itself or schedules the provided callback to run on the IO thread (if all
202 // all domains are loaded). 198 // domains are loaded).
203 void ChainLoadCookies(const LoadedCallback& loaded_callback); 199 void ChainLoadCookies(const LoadedCallback& loaded_callback);
204 200
205 // Load all cookies for a set of domains/hosts 201 // Load all cookies for a set of domains/hosts
206 bool LoadCookiesForDomains(const std::set<std::string>& key); 202 bool LoadCookiesForDomains(const std::set<std::string>& key);
207 203
208 // Batch a cookie operation (add or delete) 204 // Batch a cookie operation (add or delete)
209 void BatchOperation(PendingOperation::OperationType op, 205 void BatchOperation(PendingOperation::OperationType op,
210 const net::CanonicalCookie& cc); 206 const net::CanonicalCookie& cc);
211 // Commit our pending operations to the database. 207 // Commit our pending operations to the database.
212 void Commit(); 208 void Commit();
213 // Close() executed on the background runner. 209 // Close() executed on the background thread.
214 void InternalBackgroundClose(); 210 void InternalBackgroundClose();
215 211
216 void DeleteSessionCookiesOnStartup(); 212 void DeleteSessionCookiesOnStartup();
217 213
218 void DeleteSessionCookiesOnShutdown(); 214 void DeleteSessionCookiesOnShutdown();
219 215
220 void KillDatabase(); 216 void KillDatabase();
221 void ScheduleKillDatabase(); 217 void ScheduleKillDatabase();
222 218
223 void PostBackgroundTask(const tracked_objects::Location& origin,
224 const base::Closure& task);
225 void PostClientTask(const tracked_objects::Location& origin,
226 const base::Closure& task);
227
228 base::FilePath path_; 219 base::FilePath path_;
229 scoped_ptr<sql::Connection> db_; 220 scoped_ptr<sql::Connection> db_;
230 sql::MetaTable meta_table_; 221 sql::MetaTable meta_table_;
231 222
232 typedef std::list<PendingOperation*> PendingOperationsList; 223 typedef std::list<PendingOperation*> PendingOperationsList;
233 PendingOperationsList pending_; 224 PendingOperationsList pending_;
234 PendingOperationsList::size_type num_pending_; 225 PendingOperationsList::size_type num_pending_;
235 // True if the persistent store should skip delete on exit rules. 226 // True if the persistent store should skip delete on exit rules.
236 bool force_keep_session_state_; 227 bool force_keep_session_state_;
237 // Guard |cookies_|, |pending_|, |num_pending_|, |force_keep_session_state_| 228 // Guard |cookies_|, |pending_|, |num_pending_|, |force_keep_session_state_|
238 base::Lock lock_; 229 base::Lock lock_;
239 230
240 // Temporary buffer for cookies loaded from DB. Accumulates cookies to reduce 231 // Temporary buffer for cookies loaded from DB. Accumulates cookies to reduce
241 // the number of messages sent to the client runner. Sent back in response to 232 // the number of messages sent to the IO thread. Sent back in response to
242 // individual load requests for domain keys or when all loading completes. 233 // individual load requests for domain keys or when all loading completes.
243 std::vector<net::CanonicalCookie*> cookies_; 234 std::vector<net::CanonicalCookie*> cookies_;
244 235
245 // Map of domain keys(eTLD+1) to domains/hosts that are to be loaded from DB. 236 // Map of domain keys(eTLD+1) to domains/hosts that are to be loaded from DB.
246 std::map<std::string, std::set<std::string> > keys_to_load_; 237 std::map<std::string, std::set<std::string> > keys_to_load_;
247 238
248 // Map of (domain keys(eTLD+1), is secure cookie) to number of cookies in the 239 // Map of (domain keys(eTLD+1), is secure cookie) to number of cookies in the
249 // database. 240 // database.
250 typedef std::pair<std::string, bool> CookieOrigin; 241 typedef std::pair<std::string, bool> CookieOrigin;
251 typedef std::map<CookieOrigin, int> CookiesPerOriginMap; 242 typedef std::map<CookieOrigin, int> CookiesPerOriginMap;
252 CookiesPerOriginMap cookies_per_origin_; 243 CookiesPerOriginMap cookies_per_origin_;
253 244
254 // Indicates if DB has been initialized. 245 // Indicates if DB has been initialized.
255 bool initialized_; 246 bool initialized_;
256 247
257 // Indicates if the kill-database callback has been scheduled. 248 // Indicates if the kill-database callback has been scheduled.
258 bool corruption_detected_; 249 bool corruption_detected_;
259 250
260 // If false, we should filter out session cookies when reading the DB. 251 // If false, we should filter out session cookies when reading the DB.
261 bool restore_old_session_cookies_; 252 bool restore_old_session_cookies_;
262 253
263 // Policy defining what data is deleted on shutdown. 254 // Policy defining what data is deleted on shutdown.
264 scoped_refptr<ClearOnExitPolicy> clear_on_exit_policy_; 255 scoped_refptr<ClearOnExitPolicy> clear_on_exit_policy_;
265 256
266 // The cumulative time spent loading the cookies on the background runner. 257 // The cumulative time spent loading the cookies on the DB thread. Incremented
267 // Incremented and reported from the background runner. 258 // and reported from the DB thread.
268 base::TimeDelta cookie_load_duration_; 259 base::TimeDelta cookie_load_duration_;
269 260
270 // The total number of cookies read. Incremented and reported on the 261 // The total number of cookies read. Incremented and reported on the DB
271 // background runner. 262 // thread.
272 int num_cookies_read_; 263 int num_cookies_read_;
273 264
274 scoped_refptr<base::SequencedTaskRunner> client_task_runner_;
275 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
276
277 // Guards the following metrics-related properties (only accessed when 265 // Guards the following metrics-related properties (only accessed when
278 // starting/completing priority loads or completing the total load). 266 // starting/completing priority loads or completing the total load).
279 base::Lock metrics_lock_; 267 base::Lock metrics_lock_;
280 int num_priority_waiting_; 268 int num_priority_waiting_;
281 // The total number of priority requests. 269 // The total number of priority requests.
282 int total_priority_requests_; 270 int total_priority_requests_;
283 // The time when |num_priority_waiting_| incremented to 1. 271 // The time when |num_priority_waiting_| incremented to 1.
284 base::Time current_priority_wait_start_; 272 base::Time current_priority_wait_start_;
285 // The cumulative duration of time when |num_priority_waiting_| was greater 273 // The cumulative duration of time when |num_priority_waiting_| was greater
286 // than 1. 274 // than 1.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 367
380 return true; 368 return true;
381 } 369 }
382 370
383 } // namespace 371 } // namespace
384 372
385 void SQLitePersistentCookieStore::Backend::Load( 373 void SQLitePersistentCookieStore::Backend::Load(
386 const LoadedCallback& loaded_callback) { 374 const LoadedCallback& loaded_callback) {
387 // This function should be called only once per instance. 375 // This function should be called only once per instance.
388 DCHECK(!db_.get()); 376 DCHECK(!db_.get());
389 PostBackgroundTask(FROM_HERE, base::Bind( 377 BrowserThread::PostTask(
390 &Backend::LoadAndNotifyInBackground, this, 378 BrowserThread::DB, FROM_HERE,
391 loaded_callback, base::Time::Now())); 379 base::Bind(&Backend::LoadAndNotifyOnDBThread, this, loaded_callback,
380 base::Time::Now()));
392 } 381 }
393 382
394 void SQLitePersistentCookieStore::Backend::LoadCookiesForKey( 383 void SQLitePersistentCookieStore::Backend::LoadCookiesForKey(
395 const std::string& key, 384 const std::string& key,
396 const LoadedCallback& loaded_callback) { 385 const LoadedCallback& loaded_callback) {
397 { 386 {
398 base::AutoLock locked(metrics_lock_); 387 base::AutoLock locked(metrics_lock_);
399 if (num_priority_waiting_ == 0) 388 if (num_priority_waiting_ == 0)
400 current_priority_wait_start_ = base::Time::Now(); 389 current_priority_wait_start_ = base::Time::Now();
401 num_priority_waiting_++; 390 num_priority_waiting_++;
402 total_priority_requests_++; 391 total_priority_requests_++;
403 } 392 }
404 393
405 PostBackgroundTask(FROM_HERE, base::Bind( 394 BrowserThread::PostTask(
406 &Backend::LoadKeyAndNotifyInBackground, 395 BrowserThread::DB, FROM_HERE,
407 this, key, loaded_callback, base::Time::Now())); 396 base::Bind(&Backend::LoadKeyAndNotifyOnDBThread, this,
397 key,
398 loaded_callback,
399 base::Time::Now()));
408 } 400 }
409 401
410 void SQLitePersistentCookieStore::Backend::LoadAndNotifyInBackground( 402 void SQLitePersistentCookieStore::Backend::LoadAndNotifyOnDBThread(
411 const LoadedCallback& loaded_callback, const base::Time& posted_at) { 403 const LoadedCallback& loaded_callback, const base::Time& posted_at) {
412 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
413 IncrementTimeDelta increment(&cookie_load_duration_); 405 IncrementTimeDelta increment(&cookie_load_duration_);
414 406
415 UMA_HISTOGRAM_CUSTOM_TIMES( 407 UMA_HISTOGRAM_CUSTOM_TIMES(
416 "Cookie.TimeLoadDBQueueWait", 408 "Cookie.TimeLoadDBQueueWait",
417 base::Time::Now() - posted_at, 409 base::Time::Now() - posted_at,
418 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 410 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
419 50); 411 50);
420 412
421 if (!InitializeDatabase()) { 413 if (!InitializeDatabase()) {
422 PostClientTask(FROM_HERE, base::Bind( 414 BrowserThread::PostTask(
423 &Backend::CompleteLoadInForeground, this, loaded_callback, false)); 415 BrowserThread::IO, FROM_HERE,
416 base::Bind(&SQLitePersistentCookieStore::Backend::CompleteLoadOnIOThread,
417 this, loaded_callback, false));
424 } else { 418 } else {
425 ChainLoadCookies(loaded_callback); 419 ChainLoadCookies(loaded_callback);
426 } 420 }
427 } 421 }
428 422
429 void SQLitePersistentCookieStore::Backend::LoadKeyAndNotifyInBackground( 423 void SQLitePersistentCookieStore::Backend::LoadKeyAndNotifyOnDBThread(
430 const std::string& key, 424 const std::string& key,
431 const LoadedCallback& loaded_callback, 425 const LoadedCallback& loaded_callback,
432 const base::Time& posted_at) { 426 const base::Time& posted_at) {
433 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
434 IncrementTimeDelta increment(&cookie_load_duration_); 428 IncrementTimeDelta increment(&cookie_load_duration_);
435 429
436 UMA_HISTOGRAM_CUSTOM_TIMES( 430 UMA_HISTOGRAM_CUSTOM_TIMES(
437 "Cookie.TimeKeyLoadDBQueueWait", 431 "Cookie.TimeKeyLoadDBQueueWait",
438 base::Time::Now() - posted_at, 432 base::Time::Now() - posted_at,
439 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 433 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
440 50); 434 50);
441 435
442 bool success = false; 436 bool success = false;
443 if (InitializeDatabase()) { 437 if (InitializeDatabase()) {
444 std::map<std::string, std::set<std::string> >::iterator 438 std::map<std::string, std::set<std::string> >::iterator
445 it = keys_to_load_.find(key); 439 it = keys_to_load_.find(key);
446 if (it != keys_to_load_.end()) { 440 if (it != keys_to_load_.end()) {
447 success = LoadCookiesForDomains(it->second); 441 success = LoadCookiesForDomains(it->second);
448 keys_to_load_.erase(it); 442 keys_to_load_.erase(it);
449 } else { 443 } else {
450 success = true; 444 success = true;
451 } 445 }
452 } 446 }
453 447
454 PostClientTask(FROM_HERE, base::Bind( 448 BrowserThread::PostTask(
455 &SQLitePersistentCookieStore::Backend::CompleteLoadForKeyInForeground, 449 BrowserThread::IO, FROM_HERE,
456 this, loaded_callback, success)); 450 base::Bind(
451 &SQLitePersistentCookieStore::Backend::CompleteLoadForKeyOnIOThread,
452 this, loaded_callback, success));
457 } 453 }
458 454
459 void SQLitePersistentCookieStore::Backend::CompleteLoadForKeyInForeground( 455 void SQLitePersistentCookieStore::Backend::CompleteLoadForKeyOnIOThread(
460 const LoadedCallback& loaded_callback, 456 const LoadedCallback& loaded_callback,
461 bool load_success) { 457 bool load_success) {
462 DCHECK(client_task_runner_->RunsTasksOnCurrentThread());
463
464 Notify(loaded_callback, load_success); 458 Notify(loaded_callback, load_success);
465 459
466 { 460 {
467 base::AutoLock locked(metrics_lock_); 461 base::AutoLock locked(metrics_lock_);
468 num_priority_waiting_--; 462 num_priority_waiting_--;
469 if (num_priority_waiting_ == 0) { 463 if (num_priority_waiting_ == 0) {
470 priority_wait_duration_ += 464 priority_wait_duration_ +=
471 base::Time::Now() - current_priority_wait_start_; 465 base::Time::Now() - current_priority_wait_start_;
472 } 466 }
473 } 467 }
474 468
475 } 469 }
476 470
477 void SQLitePersistentCookieStore::Backend::ReportMetricsInBackground() { 471 void SQLitePersistentCookieStore::Backend::ReportMetricsOnDBThread() {
478 UMA_HISTOGRAM_CUSTOM_TIMES( 472 UMA_HISTOGRAM_CUSTOM_TIMES(
479 "Cookie.TimeLoad", 473 "Cookie.TimeLoad",
480 cookie_load_duration_, 474 cookie_load_duration_,
481 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 475 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
482 50); 476 50);
483 } 477 }
484 478
485 void SQLitePersistentCookieStore::Backend::ReportMetrics() { 479 void SQLitePersistentCookieStore::Backend::ReportMetrics() {
486 PostBackgroundTask(FROM_HERE, base::Bind( 480 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, base::Bind(
487 &SQLitePersistentCookieStore::Backend::ReportMetricsInBackground, this)); 481 &SQLitePersistentCookieStore::Backend::ReportMetricsOnDBThread, this));
488 482
489 { 483 {
490 base::AutoLock locked(metrics_lock_); 484 base::AutoLock locked(metrics_lock_);
491 UMA_HISTOGRAM_CUSTOM_TIMES( 485 UMA_HISTOGRAM_CUSTOM_TIMES(
492 "Cookie.PriorityBlockingTime", 486 "Cookie.PriorityBlockingTime",
493 priority_wait_duration_, 487 priority_wait_duration_,
494 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 488 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
495 50); 489 50);
496 490
497 UMA_HISTOGRAM_COUNTS_100( 491 UMA_HISTOGRAM_COUNTS_100(
498 "Cookie.PriorityLoadCount", 492 "Cookie.PriorityLoadCount",
499 total_priority_requests_); 493 total_priority_requests_);
500 494
501 UMA_HISTOGRAM_COUNTS_10000( 495 UMA_HISTOGRAM_COUNTS_10000(
502 "Cookie.NumberOfLoadedCookies", 496 "Cookie.NumberOfLoadedCookies",
503 num_cookies_read_); 497 num_cookies_read_);
504 } 498 }
505 } 499 }
506 500
507 void SQLitePersistentCookieStore::Backend::CompleteLoadInForeground( 501 void SQLitePersistentCookieStore::Backend::CompleteLoadOnIOThread(
508 const LoadedCallback& loaded_callback, bool load_success) { 502 const LoadedCallback& loaded_callback, bool load_success) {
509 Notify(loaded_callback, load_success); 503 Notify(loaded_callback, load_success);
510 504
511 if (load_success) 505 if (load_success)
512 ReportMetrics(); 506 ReportMetrics();
513 } 507 }
514 508
515 void SQLitePersistentCookieStore::Backend::Notify( 509 void SQLitePersistentCookieStore::Backend::Notify(
516 const LoadedCallback& loaded_callback, 510 const LoadedCallback& loaded_callback,
517 bool load_success) { 511 bool load_success) {
518 DCHECK(client_task_runner_->RunsTasksOnCurrentThread()); 512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
519 513
520 std::vector<net::CanonicalCookie*> cookies; 514 std::vector<net::CanonicalCookie*> cookies;
521 { 515 {
522 base::AutoLock locked(lock_); 516 base::AutoLock locked(lock_);
523 cookies.swap(cookies_); 517 cookies.swap(cookies_);
524 } 518 }
525 519
526 loaded_callback.Run(cookies); 520 loaded_callback.Run(cookies);
527 } 521 }
528 522
529 bool SQLitePersistentCookieStore::Backend::InitializeDatabase() { 523 bool SQLitePersistentCookieStore::Backend::InitializeDatabase() {
530 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
531 525
532 if (initialized_ || corruption_detected_) { 526 if (initialized_ || corruption_detected_) {
533 // Return false if we were previously initialized but the DB has since been 527 // Return false if we were previously initialized but the DB has since been
534 // closed, or if corruption caused a database reset during initialization. 528 // closed, or if corruption caused a database reset during initialization.
535 return db_ != NULL; 529 return db_ != NULL;
536 } 530 }
537 531
538 base::Time start = base::Time::Now(); 532 base::Time start = base::Time::Now();
539 533
540 const base::FilePath dir = path_.DirName(); 534 const base::FilePath dir = path_.DirName();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 base::Time::Now() - start, 601 base::Time::Now() - start,
608 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), 602 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
609 50); 603 50);
610 604
611 initialized_ = true; 605 initialized_ = true;
612 return true; 606 return true;
613 } 607 }
614 608
615 void SQLitePersistentCookieStore::Backend::ChainLoadCookies( 609 void SQLitePersistentCookieStore::Backend::ChainLoadCookies(
616 const LoadedCallback& loaded_callback) { 610 const LoadedCallback& loaded_callback) {
617 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
618 IncrementTimeDelta increment(&cookie_load_duration_); 612 IncrementTimeDelta increment(&cookie_load_duration_);
619 613
620 bool load_success = true; 614 bool load_success = true;
621 615
622 if (!db_.get()) { 616 if (!db_.get()) {
623 // Close() has been called on this store. 617 // Close() has been called on this store.
624 load_success = false; 618 load_success = false;
625 } else if (keys_to_load_.size() > 0) { 619 } else if (keys_to_load_.size() > 0) {
626 // Load cookies for the first domain key. 620 // Load cookies for the first domain key.
627 std::map<std::string, std::set<std::string> >::iterator 621 std::map<std::string, std::set<std::string> >::iterator
628 it = keys_to_load_.begin(); 622 it = keys_to_load_.begin();
629 load_success = LoadCookiesForDomains(it->second); 623 load_success = LoadCookiesForDomains(it->second);
630 keys_to_load_.erase(it); 624 keys_to_load_.erase(it);
631 } 625 }
632 626
633 // If load is successful and there are more domain keys to be loaded, 627 // If load is successful and there are more domain keys to be loaded,
634 // then post a background task to continue chain-load; 628 // then post a DB task to continue chain-load;
635 // Otherwise notify on client runner. 629 // Otherwise notify on IO thread.
636 if (load_success && keys_to_load_.size() > 0) { 630 if (load_success && keys_to_load_.size() > 0) {
637 PostBackgroundTask(FROM_HERE, base::Bind( 631 BrowserThread::PostTask(
638 &Backend::ChainLoadCookies, this, loaded_callback)); 632 BrowserThread::DB, FROM_HERE,
633 base::Bind(&Backend::ChainLoadCookies, this, loaded_callback));
639 } else { 634 } else {
640 PostClientTask(FROM_HERE, base::Bind( 635 BrowserThread::PostTask(
641 &Backend::CompleteLoadInForeground, this, 636 BrowserThread::IO, FROM_HERE,
642 loaded_callback, load_success)); 637 base::Bind(&SQLitePersistentCookieStore::Backend::CompleteLoadOnIOThread,
638 this, loaded_callback, load_success));
643 if (load_success && !restore_old_session_cookies_) 639 if (load_success && !restore_old_session_cookies_)
644 DeleteSessionCookiesOnStartup(); 640 DeleteSessionCookiesOnStartup();
645 } 641 }
646 } 642 }
647 643
648 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( 644 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains(
649 const std::set<std::string>& domains) { 645 const std::set<std::string>& domains) {
650 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 646 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
651 647
652 sql::Statement smt; 648 sql::Statement smt;
653 if (restore_old_session_cookies_) { 649 if (restore_old_session_cookies_) {
654 smt.Assign(db_->GetCachedStatement( 650 smt.Assign(db_->GetCachedStatement(
655 SQL_FROM_HERE, 651 SQL_FROM_HERE,
656 "SELECT creation_utc, host_key, name, value, path, expires_utc, " 652 "SELECT creation_utc, host_key, name, value, path, expires_utc, "
657 "secure, httponly, last_access_utc, has_expires, persistent " 653 "secure, httponly, last_access_utc, has_expires, persistent "
658 "FROM cookies WHERE host_key = ?")); 654 "FROM cookies WHERE host_key = ?"));
659 } else { 655 } else {
660 smt.Assign(db_->GetCachedStatement( 656 smt.Assign(db_->GetCachedStatement(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 BatchOperation(PendingOperation::COOKIE_DELETE, cc); 823 BatchOperation(PendingOperation::COOKIE_DELETE, cc);
828 } 824 }
829 825
830 void SQLitePersistentCookieStore::Backend::BatchOperation( 826 void SQLitePersistentCookieStore::Backend::BatchOperation(
831 PendingOperation::OperationType op, 827 PendingOperation::OperationType op,
832 const net::CanonicalCookie& cc) { 828 const net::CanonicalCookie& cc) {
833 // Commit every 30 seconds. 829 // Commit every 30 seconds.
834 static const int kCommitIntervalMs = 30 * 1000; 830 static const int kCommitIntervalMs = 30 * 1000;
835 // Commit right away if we have more than 512 outstanding operations. 831 // Commit right away if we have more than 512 outstanding operations.
836 static const size_t kCommitAfterBatchSize = 512; 832 static const size_t kCommitAfterBatchSize = 512;
837 DCHECK(!background_task_runner_->RunsTasksOnCurrentThread()); 833 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::DB));
838 834
839 // We do a full copy of the cookie here, and hopefully just here. 835 // We do a full copy of the cookie here, and hopefully just here.
840 scoped_ptr<PendingOperation> po(new PendingOperation(op, cc)); 836 scoped_ptr<PendingOperation> po(new PendingOperation(op, cc));
841 837
842 PendingOperationsList::size_type num_pending; 838 PendingOperationsList::size_type num_pending;
843 { 839 {
844 base::AutoLock locked(lock_); 840 base::AutoLock locked(lock_);
845 pending_.push_back(po.release()); 841 pending_.push_back(po.release());
846 num_pending = ++num_pending_; 842 num_pending = ++num_pending_;
847 } 843 }
848 844
849 if (num_pending == 1) { 845 if (num_pending == 1) {
850 // We've gotten our first entry for this batch, fire off the timer. 846 // We've gotten our first entry for this batch, fire off the timer.
851 if (!background_task_runner_->PostDelayedTask( 847 BrowserThread::PostDelayedTask(
852 FROM_HERE, base::Bind(&Backend::Commit, this), 848 BrowserThread::DB, FROM_HERE,
853 base::TimeDelta::FromMilliseconds(kCommitIntervalMs))) { 849 base::Bind(&Backend::Commit, this),
854 NOTREACHED() << "background_task_runner_ is not running."; 850 base::TimeDelta::FromMilliseconds(kCommitIntervalMs));
855 }
856 } else if (num_pending == kCommitAfterBatchSize) { 851 } else if (num_pending == kCommitAfterBatchSize) {
857 // We've reached a big enough batch, fire off a commit now. 852 // We've reached a big enough batch, fire off a commit now.
858 PostBackgroundTask(FROM_HERE, base::Bind(&Backend::Commit, this)); 853 BrowserThread::PostTask(
854 BrowserThread::DB, FROM_HERE,
855 base::Bind(&Backend::Commit, this));
859 } 856 }
860 } 857 }
861 858
862 void SQLitePersistentCookieStore::Backend::Commit() { 859 void SQLitePersistentCookieStore::Backend::Commit() {
863 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 860 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
864 861
865 PendingOperationsList ops; 862 PendingOperationsList ops;
866 { 863 {
867 base::AutoLock locked(lock_); 864 base::AutoLock locked(lock_);
868 pending_.swap(ops); 865 pending_.swap(ops);
869 num_pending_ = 0; 866 num_pending_ = 0;
870 } 867 }
871 868
872 // Maybe an old timer fired or we are already Close()'ed. 869 // Maybe an old timer fired or we are already Close()'ed.
873 if (!db_.get() || ops.empty()) 870 if (!db_.get() || ops.empty())
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 break; 940 break;
944 } 941 }
945 } 942 }
946 bool succeeded = transaction.Commit(); 943 bool succeeded = transaction.Commit();
947 UMA_HISTOGRAM_ENUMERATION("Cookie.BackingStoreUpdateResults", 944 UMA_HISTOGRAM_ENUMERATION("Cookie.BackingStoreUpdateResults",
948 succeeded ? 0 : 1, 2); 945 succeeded ? 0 : 1, 2);
949 } 946 }
950 947
951 void SQLitePersistentCookieStore::Backend::Flush( 948 void SQLitePersistentCookieStore::Backend::Flush(
952 const base::Closure& callback) { 949 const base::Closure& callback) {
953 DCHECK(!background_task_runner_->RunsTasksOnCurrentThread()); 950 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::DB));
954 PostBackgroundTask(FROM_HERE, base::Bind(&Backend::Commit, this)); 951 BrowserThread::PostTask(
955 952 BrowserThread::DB, FROM_HERE, base::Bind(&Backend::Commit, this));
956 if (!callback.is_null()) { 953 if (!callback.is_null()) {
957 // We want the completion task to run immediately after Commit() returns. 954 // We want the completion task to run immediately after Commit() returns.
958 // Posting it from here means there is less chance of another task getting 955 // Posting it from here means there is less chance of another task getting
959 // onto the message queue first, than if we posted it from Commit() itself. 956 // onto the message queue first, than if we posted it from Commit() itself.
960 PostBackgroundTask(FROM_HERE, callback); 957 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, callback);
961 } 958 }
962 } 959 }
963 960
964 // Fire off a close message to the background runner. We could still have a 961 // Fire off a close message to the background thread. We could still have a
965 // pending commit timer or Load operations holding references on us, but if/when 962 // pending commit timer or Load operations holding references on us, but if/when
966 // this fires we will already have been cleaned up and it will be ignored. 963 // this fires we will already have been cleaned up and it will be ignored.
967 void SQLitePersistentCookieStore::Backend::Close() { 964 void SQLitePersistentCookieStore::Backend::Close() {
968 if (background_task_runner_->RunsTasksOnCurrentThread()) { 965 if (BrowserThread::CurrentlyOn(BrowserThread::DB)) {
969 InternalBackgroundClose(); 966 InternalBackgroundClose();
970 } else { 967 } else {
971 // Must close the backend on the background runner. 968 // Must close the backend on the background thread.
972 PostBackgroundTask(FROM_HERE, 969 BrowserThread::PostTask(
973 base::Bind(&Backend::InternalBackgroundClose, this)); 970 BrowserThread::DB, FROM_HERE,
971 base::Bind(&Backend::InternalBackgroundClose, this));
974 } 972 }
975 } 973 }
976 974
977 void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() { 975 void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() {
978 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 976 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
979 // Commit any pending operations 977 // Commit any pending operations
980 Commit(); 978 Commit();
981 979
982 if (!force_keep_session_state_ && clear_on_exit_policy_.get() && 980 if (!force_keep_session_state_ && clear_on_exit_policy_.get() &&
983 clear_on_exit_policy_->HasClearOnExitOrigins()) { 981 clear_on_exit_policy_->HasClearOnExitOrigins()) {
984 DeleteSessionCookiesOnShutdown(); 982 DeleteSessionCookiesOnShutdown();
985 } 983 }
986 984
987 meta_table_.Reset(); 985 meta_table_.Reset();
988 db_.reset(); 986 db_.reset();
989 } 987 }
990 988
991 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnShutdown() { 989 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnShutdown() {
992 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 990 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
993 991
994 if (!db_.get()) 992 if (!db_.get())
995 return; 993 return;
996 994
997 sql::Statement del_smt(db_->GetCachedStatement( 995 sql::Statement del_smt(db_->GetCachedStatement(
998 SQL_FROM_HERE, "DELETE FROM cookies WHERE host_key=? AND secure=?")); 996 SQL_FROM_HERE, "DELETE FROM cookies WHERE host_key=? AND secure=?"));
999 if (!del_smt.is_valid()) { 997 if (!del_smt.is_valid()) {
1000 LOG(WARNING) << "Unable to delete cookies on shutdown."; 998 LOG(WARNING) << "Unable to delete cookies on shutdown.";
1001 return; 999 return;
1002 } 1000 }
(...skipping 20 matching lines...) Expand all
1023 del_smt.BindInt(1, it->first.second); 1021 del_smt.BindInt(1, it->first.second);
1024 if (!del_smt.Run()) 1022 if (!del_smt.Run())
1025 NOTREACHED() << "Could not delete a cookie from the DB."; 1023 NOTREACHED() << "Could not delete a cookie from the DB.";
1026 } 1024 }
1027 1025
1028 if (!transaction.Commit()) 1026 if (!transaction.Commit())
1029 LOG(WARNING) << "Unable to delete cookies on shutdown."; 1027 LOG(WARNING) << "Unable to delete cookies on shutdown.";
1030 } 1028 }
1031 1029
1032 void SQLitePersistentCookieStore::Backend::ScheduleKillDatabase() { 1030 void SQLitePersistentCookieStore::Backend::ScheduleKillDatabase() {
1033 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 1031 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
1034 1032
1035 corruption_detected_ = true; 1033 corruption_detected_ = true;
1036 1034
1037 // Don't just do the close/delete here, as we are being called by |db| and 1035 // Don't just do the close/delete here, as we are being called by |db| and
1038 // that seems dangerous. 1036 // that seems dangerous.
1039 PostBackgroundTask(FROM_HERE, base::Bind(&Backend::KillDatabase, this)); 1037 MessageLoop::current()->PostTask(
1038 FROM_HERE, base::Bind(&Backend::KillDatabase, this));
1040 } 1039 }
1041 1040
1042 void SQLitePersistentCookieStore::Backend::KillDatabase() { 1041 void SQLitePersistentCookieStore::Backend::KillDatabase() {
1043 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 1042 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
1044 1043
1045 if (db_.get()) { 1044 if (db_.get()) {
1046 // This Backend will now be in-memory only. In a future run we will recreate 1045 // This Backend will now be in-memory only. In a future run we will recreate
1047 // the database. Hopefully things go better then! 1046 // the database. Hopefully things go better then!
1048 bool success = db_->RazeAndClose(); 1047 bool success = db_->RazeAndClose();
1049 UMA_HISTOGRAM_BOOLEAN("Cookie.KillDatabaseResult", success); 1048 UMA_HISTOGRAM_BOOLEAN("Cookie.KillDatabaseResult", success);
1050 meta_table_.Reset(); 1049 meta_table_.Reset();
1051 db_.reset(); 1050 db_.reset();
1052 } 1051 }
1053 } 1052 }
1054 1053
1055 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() { 1054 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() {
1056 base::AutoLock locked(lock_); 1055 base::AutoLock locked(lock_);
1057 force_keep_session_state_ = true; 1056 force_keep_session_state_ = true;
1058 } 1057 }
1059 1058
1060 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() { 1059 void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() {
1061 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 1060 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
1062 if (!db_->Execute("DELETE FROM cookies WHERE persistent == 0")) 1061 if (!db_->Execute("DELETE FROM cookies WHERE persistent == 0"))
1063 LOG(WARNING) << "Unable to delete session cookies."; 1062 LOG(WARNING) << "Unable to delete session cookies.";
1064 } 1063 }
1065 1064
1066 void SQLitePersistentCookieStore::Backend::PostBackgroundTask(
1067 const tracked_objects::Location& origin, const base::Closure& task) {
1068 if (!background_task_runner_->PostTask(origin, task)) {
1069 LOG(WARNING) << "Failed to post task from " << origin.ToString()
1070 << " to background_task_runner_.";
1071 }
1072 }
1073
1074 void SQLitePersistentCookieStore::Backend::PostClientTask(
1075 const tracked_objects::Location& origin, const base::Closure& task) {
1076 if (!client_task_runner_->PostTask(origin, task)) {
1077 LOG(WARNING) << "Failed to post task from " << origin.ToString()
1078 << " to client_task_runner_.";
1079 }
1080 }
1081
1082 SQLitePersistentCookieStore::SQLitePersistentCookieStore( 1065 SQLitePersistentCookieStore::SQLitePersistentCookieStore(
1083 const base::FilePath& path, 1066 const base::FilePath& path,
1084 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
1085 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
1086 bool restore_old_session_cookies, 1067 bool restore_old_session_cookies,
1087 ClearOnExitPolicy* clear_on_exit_policy) 1068 ClearOnExitPolicy* clear_on_exit_policy)
1088 : backend_(new Backend(path, 1069 : backend_(
1089 client_task_runner, 1070 new Backend(path, restore_old_session_cookies, clear_on_exit_policy)) {
1090 background_task_runner,
1091 restore_old_session_cookies,
1092 clear_on_exit_policy)) {
1093 } 1071 }
1094 1072
1095 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) { 1073 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) {
1096 backend_->Load(loaded_callback); 1074 backend_->Load(loaded_callback);
1097 } 1075 }
1098 1076
1099 void SQLitePersistentCookieStore::LoadCookiesForKey( 1077 void SQLitePersistentCookieStore::LoadCookiesForKey(
1100 const std::string& key, 1078 const std::string& key,
1101 const LoadedCallback& loaded_callback) { 1079 const LoadedCallback& loaded_callback) {
1102 backend_->LoadCookiesForKey(key, loaded_callback); 1080 backend_->LoadCookiesForKey(key, loaded_callback);
(...skipping 16 matching lines...) Expand all
1119 backend_->SetForceKeepSessionState(); 1097 backend_->SetForceKeepSessionState();
1120 } 1098 }
1121 1099
1122 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { 1100 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) {
1123 backend_->Flush(callback); 1101 backend_->Flush(callback);
1124 } 1102 }
1125 1103
1126 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { 1104 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
1127 backend_->Close(); 1105 backend_->Close();
1128 // We release our reference to the Backend, though it will probably still have 1106 // We release our reference to the Backend, though it will probably still have
1129 // a reference if the background runner has not run Close() yet. 1107 // a reference if the background thread has not run Close() yet.
1130 } 1108 }
OLDNEW
« no previous file with comments | « chrome/browser/net/sqlite_persistent_cookie_store.h ('k') | chrome/browser/net/sqlite_persistent_cookie_store_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698