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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/cert_database/cert_database_service_io_part.h"
6
7 #include "base/callback.h"
8 #include "net/cert/nss_cert_database.h"
9
10 namespace cert_database {
11
12 CertDatabaseServiceIOPart::CertDatabaseServiceIOPart()
13 : initialized_(false), weak_ptr_factory_(this) {
14 }
15
16 CertDatabaseServiceIOPart::~CertDatabaseServiceIOPart() {
17 DCHECK(thread_checker_.CalledOnValidThread());
18 }
19
20 void CertDatabaseServiceIOPart::Init() {
21 // Init determines the thread to attach to.
22 thread_checker_.DetachFromThread();
23 thread_checker_.CalledOnValidThread();
24 initialized_ = true;
25 }
26
27 net::NSSCertDatabase* CertDatabaseServiceIOPart::GetNSSCertDatabase(
28 const base::Callback<void(net::NSSCertDatabase*)>& callback) {
29 DCHECK(thread_checker_.CalledOnValidThread());
30 if (nss_cert_database_)
31 return nss_cert_database_.get();
32
33 get_cert_db_callbacks_.push_back(callback);
34 return NULL;
35 }
36
37 base::WeakPtr<CertDatabaseServiceIOPart>
38 CertDatabaseServiceIOPart::GetWeakPtr() {
39 DCHECK(thread_checker_.CalledOnValidThread());
40 return weak_ptr_factory_.GetWeakPtr();
41 }
42
43 bool CertDatabaseServiceIOPart::IsInitialized() {
44 return initialized_;
45 }
46
47 void CertDatabaseServiceIOPart::SetNSSCertDatabase(
48 scoped_ptr<net::NSSCertDatabase> db) {
49 DCHECK(thread_checker_.CalledOnValidThread());
50 nss_cert_database_ = db.Pass();
51 for (GetCertDBCallback& get_cert_callback : get_cert_db_callbacks_)
52 get_cert_callback.Run(nss_cert_database_.get());
53 get_cert_db_callbacks_.clear();
54 }
55
56 } // namespace cert_database
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698