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), | 817 base::Bind(&Backend::Commit, this), kCommitIntervalMs); |
818 base::TimeDelta::FromMilliseconds(kCommitIntervalMs)); | |
819 } else if (num_pending == kCommitAfterBatchSize) { | 818 } else if (num_pending == kCommitAfterBatchSize) { |
820 // We've reached a big enough batch, fire off a commit now. | 819 // We've reached a big enough batch, fire off a commit now. |
821 BrowserThread::PostTask( | 820 BrowserThread::PostTask( |
822 BrowserThread::DB, FROM_HERE, | 821 BrowserThread::DB, FROM_HERE, |
823 base::Bind(&Backend::Commit, this)); | 822 base::Bind(&Backend::Commit, this)); |
824 } | 823 } |
825 } | 824 } |
826 | 825 |
827 void SQLitePersistentCookieStore::Backend::Commit() { | 826 void SQLitePersistentCookieStore::Backend::Commit() { |
828 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 827 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 if (backend_.get()) | 1006 if (backend_.get()) |
1008 backend_->SetClearLocalStateOnExit(clear_local_state); | 1007 backend_->SetClearLocalStateOnExit(clear_local_state); |
1009 } | 1008 } |
1010 | 1009 |
1011 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { | 1010 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { |
1012 if (backend_.get()) | 1011 if (backend_.get()) |
1013 backend_->Flush(callback); | 1012 backend_->Flush(callback); |
1014 else if (!callback.is_null()) | 1013 else if (!callback.is_null()) |
1015 MessageLoop::current()->PostTask(FROM_HERE, callback); | 1014 MessageLoop::current()->PostTask(FROM_HERE, callback); |
1016 } | 1015 } |
OLD | NEW |