OLD | NEW |
---|---|
(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 : 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(); | |
Joao da Silva
2014/10/30 09:48:01
DCHECK?
pneubeck (no reviews)
2014/11/05 14:53:37
this call always succeeds because of the detach in
| |
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 | |
OLD | NEW |