Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: components/cert_database/cert_database_service_io_part.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flattened components/cert_database folders. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cert_database/cert_database_service_io_part.cc
diff --git a/components/cert_database/cert_database_service_io_part.cc b/components/cert_database/cert_database_service_io_part.cc
new file mode 100644
index 0000000000000000000000000000000000000000..64be8acfc9c9de7e4d7c7ff8f933a91a864bd1ee
--- /dev/null
+++ b/components/cert_database/cert_database_service_io_part.cc
@@ -0,0 +1,56 @@
+// 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/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 (GetCertDBCallback& get_cert_callback : get_cert_db_callbacks_)
+ get_cert_callback.Run(nss_cert_database_.get());
+ get_cert_db_callbacks_.clear();
+}
+
+} // namespace cert_database

Powered by Google App Engine
This is Rietveld 408576698