| OLD | NEW |
| 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_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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 { | 328 { |
| 329 base::AutoLock locked(lock_); | 329 base::AutoLock locked(lock_); |
| 330 pending_.push_back(po.release()); | 330 pending_.push_back(po.release()); |
| 331 num_pending = ++num_pending_; | 331 num_pending = ++num_pending_; |
| 332 } | 332 } |
| 333 | 333 |
| 334 if (num_pending == 1) { | 334 if (num_pending == 1) { |
| 335 // We've gotten our first entry for this batch, fire off the timer. | 335 // We've gotten our first entry for this batch, fire off the timer. |
| 336 BrowserThread::PostDelayedTask( | 336 BrowserThread::PostDelayedTask( |
| 337 BrowserThread::DB, FROM_HERE, | 337 BrowserThread::DB, FROM_HERE, |
| 338 NewRunnableMethod(this, &Backend::Commit), kCommitIntervalMs); | 338 base::Bind(&Backend::Commit, this), kCommitIntervalMs); |
| 339 } else if (num_pending == kCommitAfterBatchSize) { | 339 } else if (num_pending == kCommitAfterBatchSize) { |
| 340 // We've reached a big enough batch, fire off a commit now. | 340 // We've reached a big enough batch, fire off a commit now. |
| 341 BrowserThread::PostTask( | 341 BrowserThread::PostTask( |
| 342 BrowserThread::DB, FROM_HERE, | 342 BrowserThread::DB, FROM_HERE, |
| 343 NewRunnableMethod(this, &Backend::Commit)); | 343 base::Bind(&Backend::Commit, this)); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 void SQLiteOriginBoundCertStore::Backend::Commit() { | 347 void SQLiteOriginBoundCertStore::Backend::Commit() { |
| 348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 349 | 349 |
| 350 PendingOperationsList ops; | 350 PendingOperationsList ops; |
| 351 { | 351 { |
| 352 base::AutoLock locked(lock_); | 352 base::AutoLock locked(lock_); |
| 353 pending_.swap(ops); | 353 pending_.swap(ops); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 425 } |
| 426 | 426 |
| 427 // Fire off a close message to the background thread. We could still have a | 427 // Fire off a close message to the background thread. We could still have a |
| 428 // pending commit timer that will be holding a reference on us, but if/when | 428 // pending commit timer that will be holding a reference on us, but if/when |
| 429 // this fires we will already have been cleaned up and it will be ignored. | 429 // this fires we will already have been cleaned up and it will be ignored. |
| 430 void SQLiteOriginBoundCertStore::Backend::Close() { | 430 void SQLiteOriginBoundCertStore::Backend::Close() { |
| 431 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::DB)); | 431 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 432 // Must close the backend on the background thread. | 432 // Must close the backend on the background thread. |
| 433 BrowserThread::PostTask( | 433 BrowserThread::PostTask( |
| 434 BrowserThread::DB, FROM_HERE, | 434 BrowserThread::DB, FROM_HERE, |
| 435 NewRunnableMethod(this, &Backend::InternalBackgroundClose)); | 435 base::Bind(&Backend::InternalBackgroundClose, this)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void SQLiteOriginBoundCertStore::Backend::InternalBackgroundClose() { | 438 void SQLiteOriginBoundCertStore::Backend::InternalBackgroundClose() { |
| 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 440 // Commit any pending operations | 440 // Commit any pending operations |
| 441 Commit(); | 441 Commit(); |
| 442 | 442 |
| 443 db_.reset(); | 443 db_.reset(); |
| 444 | 444 |
| 445 if (clear_local_state_on_exit_) | 445 if (clear_local_state_on_exit_) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 if (backend_.get()) | 487 if (backend_.get()) |
| 488 backend_->SetClearLocalStateOnExit(clear_local_state); | 488 backend_->SetClearLocalStateOnExit(clear_local_state); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void SQLiteOriginBoundCertStore::Flush(const base::Closure& completion_task) { | 491 void SQLiteOriginBoundCertStore::Flush(const base::Closure& completion_task) { |
| 492 if (backend_.get()) | 492 if (backend_.get()) |
| 493 backend_->Flush(completion_task); | 493 backend_->Flush(completion_task); |
| 494 else if (!completion_task.is_null()) | 494 else if (!completion_task.is_null()) |
| 495 MessageLoop::current()->PostTask(FROM_HERE, completion_task); | 495 MessageLoop::current()->PostTask(FROM_HERE, completion_task); |
| 496 } | 496 } |
| OLD | NEW |