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 "chrome/browser/chromeos/net/client_cert_store_chromeos.h" | 5 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/threading/worker_pool.h" | 15 #include "base/task_scheduler/post_task.h" |
16 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" | 16 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" |
17 #include "crypto/nss_crypto_module_delegate.h" | 17 #include "crypto/nss_crypto_module_delegate.h" |
18 #include "net/ssl/ssl_cert_request_info.h" | 18 #include "net/ssl/ssl_cert_request_info.h" |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 class CertNotAllowedPredicate { | 24 class CertNotAllowedPredicate { |
25 public: | 25 public: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 const net::SSLCertRequestInfo* request, | 74 const net::SSLCertRequestInfo* request, |
75 net::CertificateList* selected_certs, | 75 net::CertificateList* selected_certs, |
76 const base::Closure& callback, | 76 const base::Closure& callback, |
77 const net::CertificateList& additional_certs) { | 77 const net::CertificateList& additional_certs) { |
78 std::unique_ptr<crypto::CryptoModuleBlockingPasswordDelegate> | 78 std::unique_ptr<crypto::CryptoModuleBlockingPasswordDelegate> |
79 password_delegate; | 79 password_delegate; |
80 if (!password_delegate_factory_.is_null()) { | 80 if (!password_delegate_factory_.is_null()) { |
81 password_delegate.reset( | 81 password_delegate.reset( |
82 password_delegate_factory_.Run(request->host_and_port)); | 82 password_delegate_factory_.Run(request->host_and_port)); |
83 } | 83 } |
84 if (base::WorkerPool::PostTaskAndReply( | 84 base::PostTaskWithTraitsAndReply( |
85 FROM_HERE, | 85 FROM_HERE, base::TaskTraits() |
86 base::Bind(&ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread, | 86 .WithPriority(base::TaskPriority::BACKGROUND) |
mattm
2016/11/29 21:48:46
This should probably be USER_BLOCKING, or at least
fdoray
2016/12/02 19:20:06
I removed the explicit priority. The task's priori
| |
87 base::Unretained(this), base::Passed(&password_delegate), | 87 .WithShutdownBehavior( |
88 request, additional_certs, selected_certs), | 88 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), |
mattm
2016/11/29 21:48:46
CONTINUE_ON_SHUTDOWN is fine.
fdoray
2016/12/02 19:20:06
Acknowledged.
| |
89 callback, true)) { | 89 base::Bind(&ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread, |
90 return; | 90 base::Unretained(this), base::Passed(&password_delegate), |
91 } | 91 request, additional_certs, selected_certs), |
92 // If the task could not be posted, behave as if there were no certificates | 92 callback); |
93 // which requires to clear |selected_certs|. | |
94 selected_certs->clear(); | |
95 callback.Run(); | |
96 } | 93 } |
97 | 94 |
98 void ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread( | 95 void ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread( |
99 std::unique_ptr<crypto::CryptoModuleBlockingPasswordDelegate> | 96 std::unique_ptr<crypto::CryptoModuleBlockingPasswordDelegate> |
100 password_delegate, | 97 password_delegate, |
101 const net::SSLCertRequestInfo* request, | 98 const net::SSLCertRequestInfo* request, |
102 const net::CertificateList& additional_certs, | 99 const net::CertificateList& additional_certs, |
103 net::CertificateList* selected_certs) { | 100 net::CertificateList* selected_certs) { |
104 net::CertificateList unfiltered_certs; | 101 net::CertificateList unfiltered_certs; |
105 net::ClientCertStoreNSS::GetPlatformCertsOnWorkerThread( | 102 net::ClientCertStoreNSS::GetPlatformCertsOnWorkerThread( |
106 std::move(password_delegate), &unfiltered_certs); | 103 std::move(password_delegate), &unfiltered_certs); |
107 | 104 |
108 unfiltered_certs.erase( | 105 unfiltered_certs.erase( |
109 std::remove_if(unfiltered_certs.begin(), unfiltered_certs.end(), | 106 std::remove_if(unfiltered_certs.begin(), unfiltered_certs.end(), |
110 CertNotAllowedPredicate(cert_filter_.get())), | 107 CertNotAllowedPredicate(cert_filter_.get())), |
111 unfiltered_certs.end()); | 108 unfiltered_certs.end()); |
112 | 109 |
113 unfiltered_certs.insert(unfiltered_certs.end(), additional_certs.begin(), | 110 unfiltered_certs.insert(unfiltered_certs.end(), additional_certs.begin(), |
114 additional_certs.end()); | 111 additional_certs.end()); |
115 | 112 |
116 net::ClientCertStoreNSS::FilterCertsOnWorkerThread(unfiltered_certs, *request, | 113 net::ClientCertStoreNSS::FilterCertsOnWorkerThread(unfiltered_certs, *request, |
117 selected_certs); | 114 selected_certs); |
118 } | 115 } |
119 | 116 |
120 } // namespace chromeos | 117 } // namespace chromeos |
OLD | NEW |