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_origin_bound_cert_store.h" | 5 #include "chrome/browser/net/sqlite_origin_bound_cert_store.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 { | 351 { |
352 base::AutoLock locked(lock_); | 352 base::AutoLock locked(lock_); |
353 pending_.push_back(po.release()); | 353 pending_.push_back(po.release()); |
354 num_pending = ++num_pending_; | 354 num_pending = ++num_pending_; |
355 } | 355 } |
356 | 356 |
357 if (num_pending == 1) { | 357 if (num_pending == 1) { |
358 // We've gotten our first entry for this batch, fire off the timer. | 358 // We've gotten our first entry for this batch, fire off the timer. |
359 BrowserThread::PostDelayedTask( | 359 BrowserThread::PostDelayedTask( |
360 BrowserThread::DB, FROM_HERE, | 360 BrowserThread::DB, FROM_HERE, |
361 base::Bind(&Backend::Commit, this), | 361 base::Bind(&Backend::Commit, this), kCommitIntervalMs); |
362 base::TimeDelta::FromMilliseconds(kCommitIntervalMs)); | |
363 } else if (num_pending == kCommitAfterBatchSize) { | 362 } else if (num_pending == kCommitAfterBatchSize) { |
364 // We've reached a big enough batch, fire off a commit now. | 363 // We've reached a big enough batch, fire off a commit now. |
365 BrowserThread::PostTask( | 364 BrowserThread::PostTask( |
366 BrowserThread::DB, FROM_HERE, | 365 BrowserThread::DB, FROM_HERE, |
367 base::Bind(&Backend::Commit, this)); | 366 base::Bind(&Backend::Commit, this)); |
368 } | 367 } |
369 } | 368 } |
370 | 369 |
371 void SQLiteOriginBoundCertStore::Backend::Commit() { | 370 void SQLiteOriginBoundCertStore::Backend::Commit() { |
372 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 if (backend_.get()) | 506 if (backend_.get()) |
508 backend_->SetClearLocalStateOnExit(clear_local_state); | 507 backend_->SetClearLocalStateOnExit(clear_local_state); |
509 } | 508 } |
510 | 509 |
511 void SQLiteOriginBoundCertStore::Flush(const base::Closure& completion_task) { | 510 void SQLiteOriginBoundCertStore::Flush(const base::Closure& completion_task) { |
512 if (backend_.get()) | 511 if (backend_.get()) |
513 backend_->Flush(completion_task); | 512 backend_->Flush(completion_task); |
514 else if (!completion_task.is_null()) | 513 else if (!completion_task.is_null()) |
515 MessageLoop::current()->PostTask(FROM_HERE, completion_task); | 514 MessageLoop::current()->PostTask(FROM_HERE, completion_task); |
516 } | 515 } |
OLD | NEW |