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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
22 #include "base/task_runner.h" | 22 #include "base/task_runner.h" |
23 #include "crypto/ec_private_key.h" | 23 #include "crypto/ec_private_key.h" |
24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
25 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 25 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
26 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
27 #include "net/cert/x509_util.h" | 27 #include "net/cert/x509_util.h" |
28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
29 | 29 |
30 #if defined(USE_NSS) | 30 #if defined(USE_NSS_CERTS) |
31 #include <private/pprthred.h> // PR_DetachThread | 31 #include <private/pprthred.h> // PR_DetachThread |
32 #endif | 32 #endif |
33 | 33 |
34 namespace net { | 34 namespace net { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 const int kValidityPeriodInDays = 365; | 38 const int kValidityPeriodInDays = 365; |
39 // When we check the system time, we add this many days to the end of the check | 39 // When we check the system time, we add this many days to the end of the check |
40 // so the result will still hold even after chrome has been running for a | 40 // so the result will still hold even after chrome has been running for a |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 base::Bind(&ChannelIDServiceWorker::Run, base::Owned(this))); | 239 base::Bind(&ChannelIDServiceWorker::Run, base::Owned(this))); |
240 } | 240 } |
241 | 241 |
242 private: | 242 private: |
243 void Run() { | 243 void Run() { |
244 // Runs on a worker thread. | 244 // Runs on a worker thread. |
245 int error = ERR_FAILED; | 245 int error = ERR_FAILED; |
246 scoped_ptr<ChannelIDStore::ChannelID> cert = | 246 scoped_ptr<ChannelIDStore::ChannelID> cert = |
247 GenerateChannelID(server_identifier_, serial_number_, &error); | 247 GenerateChannelID(server_identifier_, serial_number_, &error); |
248 DVLOG(1) << "GenerateCert " << server_identifier_ << " returned " << error; | 248 DVLOG(1) << "GenerateCert " << server_identifier_ << " returned " << error; |
249 #if defined(USE_NSS) | 249 #if defined(USE_NSS_CERTS) |
250 // Detach the thread from NSPR. | 250 // Detach the thread from NSPR. |
251 // Calling NSS functions attaches the thread to NSPR, which stores | 251 // Calling NSS functions attaches the thread to NSPR, which stores |
252 // the NSPR thread ID in thread-specific data. | 252 // the NSPR thread ID in thread-specific data. |
253 // The threads in our thread pool terminate after we have called | 253 // The threads in our thread pool terminate after we have called |
254 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | 254 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
255 // segfaults on shutdown when the threads' thread-specific data | 255 // segfaults on shutdown when the threads' thread-specific data |
256 // destructors run. | 256 // destructors run. |
257 PR_DetachThread(); | 257 PR_DetachThread(); |
258 #endif | 258 #endif |
259 origin_loop_->PostTask(FROM_HERE, | 259 origin_loop_->PostTask(FROM_HERE, |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 666 } |
667 | 667 |
668 return err; | 668 return err; |
669 } | 669 } |
670 | 670 |
671 int ChannelIDService::cert_count() { | 671 int ChannelIDService::cert_count() { |
672 return channel_id_store_->GetChannelIDCount(); | 672 return channel_id_store_->GetChannelIDCount(); |
673 } | 673 } |
674 | 674 |
675 } // namespace net | 675 } // namespace net |
OLD | NEW |