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 <utility> | 9 #include <utility> |
10 | 10 |
| 11 #include "base/atomic_sequence_num.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/location.h" | 16 #include "base/location.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
20 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
32 | 33 |
33 #if !defined(USE_OPENSSL) | 34 #if !defined(USE_OPENSSL) |
34 #include <private/pprthred.h> // PR_DetachThread | 35 #include <private/pprthred.h> // PR_DetachThread |
35 #endif | 36 #endif |
36 | 37 |
37 namespace net { | 38 namespace net { |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
| 42 base::StaticAtomicSequenceNumber g_next_id; |
| 43 |
41 // Used by the GetDomainBoundCertResult histogram to record the final | 44 // Used by the GetDomainBoundCertResult histogram to record the final |
42 // outcome of each GetChannelID or GetOrCreateChannelID call. | 45 // outcome of each GetChannelID or GetOrCreateChannelID call. |
43 // Do not re-use values. | 46 // Do not re-use values. |
44 enum GetChannelIDResult { | 47 enum GetChannelIDResult { |
45 // Synchronously found and returned an existing domain bound cert. | 48 // Synchronously found and returned an existing domain bound cert. |
46 SYNC_SUCCESS = 0, | 49 SYNC_SUCCESS = 0, |
47 // Retrieved or generated and returned a domain bound cert asynchronously. | 50 // Retrieved or generated and returned a domain bound cert asynchronously. |
48 ASYNC_SUCCESS = 1, | 51 ASYNC_SUCCESS = 1, |
49 // Retrieval/generation request was cancelled before the cert generation | 52 // Retrieval/generation request was cancelled before the cert generation |
50 // completed. | 53 // completed. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // resources created for the request), so we can't touch any of our | 284 // resources created for the request), so we can't touch any of our |
282 // members afterwards. Reset callback_ first. | 285 // members afterwards. Reset callback_ first. |
283 base::ResetAndReturn(&callback_).Run(error); | 286 base::ResetAndReturn(&callback_).Run(error); |
284 } | 287 } |
285 | 288 |
286 ChannelIDService::ChannelIDService( | 289 ChannelIDService::ChannelIDService( |
287 ChannelIDStore* channel_id_store, | 290 ChannelIDStore* channel_id_store, |
288 const scoped_refptr<base::TaskRunner>& task_runner) | 291 const scoped_refptr<base::TaskRunner>& task_runner) |
289 : channel_id_store_(channel_id_store), | 292 : channel_id_store_(channel_id_store), |
290 task_runner_(task_runner), | 293 task_runner_(task_runner), |
| 294 id_(g_next_id.GetNext()), |
291 requests_(0), | 295 requests_(0), |
292 key_store_hits_(0), | 296 key_store_hits_(0), |
293 inflight_joins_(0), | 297 inflight_joins_(0), |
294 workers_created_(0), | 298 workers_created_(0), |
295 weak_ptr_factory_(this) { | 299 weak_ptr_factory_(this) {} |
296 } | |
297 | 300 |
298 ChannelIDService::~ChannelIDService() { | 301 ChannelIDService::~ChannelIDService() { |
299 STLDeleteValues(&inflight_); | 302 STLDeleteValues(&inflight_); |
300 } | 303 } |
301 | 304 |
302 // static | 305 // static |
303 std::string ChannelIDService::GetDomainForHost(const std::string& host) { | 306 std::string ChannelIDService::GetDomainForHost(const std::string& host) { |
304 std::string domain = | 307 std::string domain = |
305 registry_controlled_domains::GetDomainAndRegistry( | 308 registry_controlled_domains::GetDomainAndRegistry( |
306 host, registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 309 host, registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 } | 534 } |
532 | 535 |
533 return err; | 536 return err; |
534 } | 537 } |
535 | 538 |
536 int ChannelIDService::channel_id_count() { | 539 int ChannelIDService::channel_id_count() { |
537 return channel_id_store_->GetChannelIDCount(); | 540 return channel_id_store_->GetChannelIDCount(); |
538 } | 541 } |
539 | 542 |
540 } // namespace net | 543 } // namespace net |
OLD | NEW |