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

Side by Side Diff: components/cert_database/core/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: Rebase, format. Created 6 years, 2 months 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/public/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 : 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 }
25
26 net::NSSCertDatabase* CertDatabaseServiceIOPart::GetNSSCertDatabase(
27 const base::Callback<void(net::NSSCertDatabase*)>& callback) {
28 DCHECK(thread_checker_.CalledOnValidThread());
29 if (nss_cert_database_)
30 return nss_cert_database_.get();
31
32 get_cert_db_callbacks_.push_back(callback);
33 return NULL;
34 }
35
36 base::WeakPtr<CertDatabaseServiceIOPart>
37 CertDatabaseServiceIOPart::GetWeakPtr() {
38 DCHECK(thread_checker_.CalledOnValidThread());
39 return weak_ptr_factory_.GetWeakPtr();
40 }
41
42 void CertDatabaseServiceIOPart::DidCreateNSSCertDatabase(
43 scoped_ptr<net::NSSCertDatabase> db) {
44 DCHECK(thread_checker_.CalledOnValidThread());
45 nss_cert_database_ = db.Pass();
46 for (GetCertDBCallbacks::iterator i = get_cert_db_callbacks_.begin();
47 i != get_cert_db_callbacks_.end();
48 ++i) {
49 i->Run(nss_cert_database_.get());
50 }
51 get_cert_db_callbacks_.clear();
52 }
53
54 } // namespace cert_database
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698