| Index: components/cert_database/core/cert_database_service_io_part.cc
|
| diff --git a/components/cert_database/core/cert_database_service_io_part.cc b/components/cert_database/core/cert_database_service_io_part.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1f70f66267e0fc61b515ac6c07ce37a6d00b851a
|
| --- /dev/null
|
| +++ b/components/cert_database/core/cert_database_service_io_part.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/cert_database/public/cert_database_service_io_part.h"
|
| +
|
| +#include "base/callback.h"
|
| +#include "net/cert/nss_cert_database.h"
|
| +
|
| +namespace cert_database {
|
| +
|
| +CertDatabaseServiceIOPart::CertDatabaseServiceIOPart()
|
| + : initialized_(false), weak_ptr_factory_(this) {
|
| +}
|
| +
|
| +CertDatabaseServiceIOPart::~CertDatabaseServiceIOPart() {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| +}
|
| +
|
| +void CertDatabaseServiceIOPart::Init() {
|
| + // Init determines the thread to attach to.
|
| + thread_checker_.DetachFromThread();
|
| + thread_checker_.CalledOnValidThread();
|
| + initialized_ = true;
|
| +}
|
| +
|
| +net::NSSCertDatabase* CertDatabaseServiceIOPart::GetNSSCertDatabase(
|
| + const base::Callback<void(net::NSSCertDatabase*)>& callback) {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + if (nss_cert_database_)
|
| + return nss_cert_database_.get();
|
| +
|
| + get_cert_db_callbacks_.push_back(callback);
|
| + return NULL;
|
| +}
|
| +
|
| +base::WeakPtr<CertDatabaseServiceIOPart>
|
| +CertDatabaseServiceIOPart::GetWeakPtr() {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + return weak_ptr_factory_.GetWeakPtr();
|
| +}
|
| +
|
| +bool CertDatabaseServiceIOPart::IsInitialized() {
|
| + return initialized_;
|
| +}
|
| +
|
| +void CertDatabaseServiceIOPart::SetNSSCertDatabase(
|
| + scoped_ptr<net::NSSCertDatabase> db) {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + nss_cert_database_ = db.Pass();
|
| + for (GetCertDBCallbacks::iterator i = get_cert_db_callbacks_.begin();
|
| + i != get_cert_db_callbacks_.end();
|
| + ++i) {
|
| + i->Run(nss_cert_database_.get());
|
| + }
|
| + get_cert_db_callbacks_.clear();
|
| +}
|
| +
|
| +} // namespace cert_database
|
|
|