| 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_server_bound_cert_store.h" | 5 #include "chrome/browser/net/sqlite_server_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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 void SQLiteServerBoundCertStore::Backend::SetClearLocalStateOnExit( | 472 void SQLiteServerBoundCertStore::Backend::SetClearLocalStateOnExit( |
| 473 bool clear_local_state) { | 473 bool clear_local_state) { |
| 474 base::AutoLock locked(lock_); | 474 base::AutoLock locked(lock_); |
| 475 clear_local_state_on_exit_ = clear_local_state; | 475 clear_local_state_on_exit_ = clear_local_state; |
| 476 } | 476 } |
| 477 | 477 |
| 478 SQLiteServerBoundCertStore::SQLiteServerBoundCertStore(const FilePath& path) | 478 SQLiteServerBoundCertStore::SQLiteServerBoundCertStore(const FilePath& path) |
| 479 : backend_(new Backend(path)) { | 479 : backend_(new Backend(path)) { |
| 480 } | 480 } |
| 481 | 481 |
| 482 SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() { | |
| 483 if (backend_.get()) { | |
| 484 backend_->Close(); | |
| 485 // Release our reference, it will probably still have a reference if the | |
| 486 // background thread has not run Close() yet. | |
| 487 backend_ = NULL; | |
| 488 } | |
| 489 } | |
| 490 | |
| 491 bool SQLiteServerBoundCertStore::Load( | 482 bool SQLiteServerBoundCertStore::Load( |
| 492 std::vector<net::DefaultServerBoundCertStore::ServerBoundCert*>* certs) { | 483 std::vector<net::DefaultServerBoundCertStore::ServerBoundCert*>* certs) { |
| 493 return backend_->Load(certs); | 484 return backend_->Load(certs); |
| 494 } | 485 } |
| 495 | 486 |
| 496 void SQLiteServerBoundCertStore::AddServerBoundCert( | 487 void SQLiteServerBoundCertStore::AddServerBoundCert( |
| 497 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { | 488 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| 498 if (backend_.get()) | 489 if (backend_.get()) |
| 499 backend_->AddServerBoundCert(cert); | 490 backend_->AddServerBoundCert(cert); |
| 500 } | 491 } |
| 501 | 492 |
| 502 void SQLiteServerBoundCertStore::DeleteServerBoundCert( | 493 void SQLiteServerBoundCertStore::DeleteServerBoundCert( |
| 503 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { | 494 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| 504 if (backend_.get()) | 495 if (backend_.get()) |
| 505 backend_->DeleteServerBoundCert(cert); | 496 backend_->DeleteServerBoundCert(cert); |
| 506 } | 497 } |
| 507 | 498 |
| 508 void SQLiteServerBoundCertStore::SetClearLocalStateOnExit( | 499 void SQLiteServerBoundCertStore::SetClearLocalStateOnExit( |
| 509 bool clear_local_state) { | 500 bool clear_local_state) { |
| 510 if (backend_.get()) | 501 if (backend_.get()) |
| 511 backend_->SetClearLocalStateOnExit(clear_local_state); | 502 backend_->SetClearLocalStateOnExit(clear_local_state); |
| 512 } | 503 } |
| 513 | 504 |
| 514 void SQLiteServerBoundCertStore::Flush(const base::Closure& completion_task) { | 505 void SQLiteServerBoundCertStore::Flush(const base::Closure& completion_task) { |
| 515 if (backend_.get()) | 506 if (backend_.get()) |
| 516 backend_->Flush(completion_task); | 507 backend_->Flush(completion_task); |
| 517 else if (!completion_task.is_null()) | 508 else if (!completion_task.is_null()) |
| 518 MessageLoop::current()->PostTask(FROM_HERE, completion_task); | 509 MessageLoop::current()->PostTask(FROM_HERE, completion_task); |
| 519 } | 510 } |
| 511 |
| 512 SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() { |
| 513 if (backend_.get()) { |
| 514 backend_->Close(); |
| 515 // Release our reference, it will probably still have a reference if the |
| 516 // background thread has not run Close() yet. |
| 517 backend_ = NULL; |
| 518 } |
| 519 } |
| OLD | NEW |