OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ssl/channel_id_service.h" | 5 #include "net/ssl/channel_id_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
25 #include "base/task_runner.h" | 25 #include "base/task_runner.h" |
26 #include "base/thread_task_runner_handle.h" | 26 #include "base/thread_task_runner_handle.h" |
27 #include "crypto/ec_private_key.h" | 27 #include "crypto/ec_private_key.h" |
28 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
30 #include "net/cert/x509_certificate.h" | 30 #include "net/cert/x509_certificate.h" |
31 #include "net/cert/x509_util.h" | 31 #include "net/cert/x509_util.h" |
32 #include "url/gurl.h" | 32 #include "url/gurl.h" |
33 | 33 |
34 #if !defined(USE_OPENSSL) | |
35 #include <private/pprthred.h> // PR_DetachThread | |
36 #endif | |
37 | |
38 namespace net { | 34 namespace net { |
39 | 35 |
40 namespace { | 36 namespace { |
41 | 37 |
42 base::StaticAtomicSequenceNumber g_next_id; | 38 base::StaticAtomicSequenceNumber g_next_id; |
43 | 39 |
44 // Used by the GetDomainBoundCertResult histogram to record the final | 40 // Used by the GetDomainBoundCertResult histogram to record the final |
45 // outcome of each GetChannelID or GetOrCreateChannelID call. | 41 // outcome of each GetChannelID or GetOrCreateChannelID call. |
46 // Do not re-use values. | 42 // Do not re-use values. |
47 enum GetChannelIDResult { | 43 enum GetChannelIDResult { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 FROM_HERE, | 135 FROM_HERE, |
140 base::Bind(&ChannelIDServiceWorker::Run, base::Owned(this))); | 136 base::Bind(&ChannelIDServiceWorker::Run, base::Owned(this))); |
141 } | 137 } |
142 | 138 |
143 private: | 139 private: |
144 void Run() { | 140 void Run() { |
145 // Runs on a worker thread. | 141 // Runs on a worker thread. |
146 int error = ERR_FAILED; | 142 int error = ERR_FAILED; |
147 std::unique_ptr<ChannelIDStore::ChannelID> channel_id = | 143 std::unique_ptr<ChannelIDStore::ChannelID> channel_id = |
148 GenerateChannelID(server_identifier_, &error); | 144 GenerateChannelID(server_identifier_, &error); |
149 #if !defined(USE_OPENSSL) | |
150 // Detach the thread from NSPR. | |
151 // Calling NSS functions attaches the thread to NSPR, which stores | |
152 // the NSPR thread ID in thread-specific data. | |
153 // The threads in our thread pool terminate after we have called | |
154 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | |
155 // segfaults on shutdown when the threads' thread-specific data | |
156 // destructors run. | |
157 PR_DetachThread(); | |
158 #endif | |
159 origin_task_runner_->PostTask( | 145 origin_task_runner_->PostTask( |
160 FROM_HERE, base::Bind(callback_, server_identifier_, error, | 146 FROM_HERE, base::Bind(callback_, server_identifier_, error, |
161 base::Passed(&channel_id))); | 147 base::Passed(&channel_id))); |
162 } | 148 } |
163 | 149 |
164 const std::string server_identifier_; | 150 const std::string server_identifier_; |
165 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; | 151 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; |
166 WorkerDoneCallback callback_; | 152 WorkerDoneCallback callback_; |
167 | 153 |
168 DISALLOW_COPY_AND_ASSIGN(ChannelIDServiceWorker); | 154 DISALLOW_COPY_AND_ASSIGN(ChannelIDServiceWorker); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 521 } |
536 | 522 |
537 return err; | 523 return err; |
538 } | 524 } |
539 | 525 |
540 int ChannelIDService::channel_id_count() { | 526 int ChannelIDService::channel_id_count() { |
541 return channel_id_store_->GetChannelIDCount(); | 527 return channel_id_store_->GetChannelIDCount(); |
542 } | 528 } |
543 | 529 |
544 } // namespace net | 530 } // namespace net |
OLD | NEW |