| OLD | NEW |
| 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> |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 { | 807 { |
| 808 base::AutoLock locked(lock_); | 808 base::AutoLock locked(lock_); |
| 809 pending_.push_back(po.release()); | 809 pending_.push_back(po.release()); |
| 810 num_pending = ++num_pending_; | 810 num_pending = ++num_pending_; |
| 811 } | 811 } |
| 812 | 812 |
| 813 if (num_pending == 1) { | 813 if (num_pending == 1) { |
| 814 // We've gotten our first entry for this batch, fire off the timer. | 814 // We've gotten our first entry for this batch, fire off the timer. |
| 815 BrowserThread::PostDelayedTask( | 815 BrowserThread::PostDelayedTask( |
| 816 BrowserThread::DB, FROM_HERE, | 816 BrowserThread::DB, FROM_HERE, |
| 817 base::Bind(&Backend::Commit, this), kCommitIntervalMs); | 817 base::Bind(&Backend::Commit, this), |
| 818 base::TimeDelta::FromMilliseconds(kCommitIntervalMs)); |
| 818 } else if (num_pending == kCommitAfterBatchSize) { | 819 } else if (num_pending == kCommitAfterBatchSize) { |
| 819 // We've reached a big enough batch, fire off a commit now. | 820 // We've reached a big enough batch, fire off a commit now. |
| 820 BrowserThread::PostTask( | 821 BrowserThread::PostTask( |
| 821 BrowserThread::DB, FROM_HERE, | 822 BrowserThread::DB, FROM_HERE, |
| 822 base::Bind(&Backend::Commit, this)); | 823 base::Bind(&Backend::Commit, this)); |
| 823 } | 824 } |
| 824 } | 825 } |
| 825 | 826 |
| 826 void SQLitePersistentCookieStore::Backend::Commit() { | 827 void SQLitePersistentCookieStore::Backend::Commit() { |
| 827 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 828 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 if (backend_.get()) | 1007 if (backend_.get()) |
| 1007 backend_->SetClearLocalStateOnExit(clear_local_state); | 1008 backend_->SetClearLocalStateOnExit(clear_local_state); |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { | 1011 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { |
| 1011 if (backend_.get()) | 1012 if (backend_.get()) |
| 1012 backend_->Flush(callback); | 1013 backend_->Flush(callback); |
| 1013 else if (!callback.is_null()) | 1014 else if (!callback.is_null()) |
| 1014 MessageLoop::current()->PostTask(FROM_HERE, callback); | 1015 MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 1015 } | 1016 } |
| OLD | NEW |