OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cert/nss_cert_database_chromeos.h" | 5 #include "net/cert/nss_cert_database_chromeos.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/task_runner.h" | 17 #include "base/task_scheduler/post_task.h" |
18 #include "net/base/crypto_module.h" | 18 #include "net/base/crypto_module.h" |
19 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 NSSCertDatabaseChromeOS::NSSCertDatabaseChromeOS( | 23 NSSCertDatabaseChromeOS::NSSCertDatabaseChromeOS( |
24 crypto::ScopedPK11Slot public_slot, | 24 crypto::ScopedPK11Slot public_slot, |
25 crypto::ScopedPK11Slot private_slot) | 25 crypto::ScopedPK11Slot private_slot) |
26 : NSSCertDatabase(std::move(public_slot), std::move(private_slot)) { | 26 : NSSCertDatabase(std::move(public_slot), std::move(private_slot)) { |
27 // By default, don't use a system slot. Only if explicitly set by | 27 // By default, don't use a system slot. Only if explicitly set by |
(...skipping 14 matching lines...) Expand all Loading... |
42 void NSSCertDatabaseChromeOS::ListCertsSync(CertificateList* certs) { | 42 void NSSCertDatabaseChromeOS::ListCertsSync(CertificateList* certs) { |
43 ListCertsImpl(profile_filter_, certs); | 43 ListCertsImpl(profile_filter_, certs); |
44 } | 44 } |
45 | 45 |
46 void NSSCertDatabaseChromeOS::ListCerts( | 46 void NSSCertDatabaseChromeOS::ListCerts( |
47 const NSSCertDatabase::ListCertsCallback& callback) { | 47 const NSSCertDatabase::ListCertsCallback& callback) { |
48 std::unique_ptr<CertificateList> certs(new CertificateList()); | 48 std::unique_ptr<CertificateList> certs(new CertificateList()); |
49 | 49 |
50 // base::Pased will NULL out |certs|, so cache the underlying pointer here. | 50 // base::Pased will NULL out |certs|, so cache the underlying pointer here. |
51 CertificateList* raw_certs = certs.get(); | 51 CertificateList* raw_certs = certs.get(); |
52 GetSlowTaskRunner()->PostTaskAndReply( | 52 base::PostTaskWithTraitsAndReply( |
53 FROM_HERE, | 53 FROM_HERE, base::TaskTraits() |
54 base::Bind(&NSSCertDatabaseChromeOS::ListCertsImpl, | 54 .WithShutdownBehavior( |
55 profile_filter_, | 55 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
| 56 .MayBlock(), |
| 57 base::Bind(&NSSCertDatabaseChromeOS::ListCertsImpl, profile_filter_, |
56 base::Unretained(raw_certs)), | 58 base::Unretained(raw_certs)), |
57 base::Bind(callback, base::Passed(&certs))); | 59 base::Bind(callback, base::Passed(&certs))); |
58 } | 60 } |
59 | 61 |
60 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetSystemSlot() const { | 62 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetSystemSlot() const { |
61 if (system_slot_) | 63 if (system_slot_) |
62 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(system_slot_.get())); | 64 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(system_slot_.get())); |
63 return crypto::ScopedPK11Slot(); | 65 return crypto::ScopedPK11Slot(); |
64 } | 66 } |
65 | 67 |
(...skipping 23 matching lines...) Expand all Loading... |
89 certs->begin(), | 91 certs->begin(), |
90 certs->end(), | 92 certs->end(), |
91 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate( | 93 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate( |
92 profile_filter)), | 94 profile_filter)), |
93 certs->end()); | 95 certs->end()); |
94 DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size | 96 DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size |
95 << " certs"; | 97 << " certs"; |
96 } | 98 } |
97 | 99 |
98 } // namespace net | 100 } // namespace net |
OLD | NEW |