| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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), |
| 291 requests_(0), | 294 requests_(0), |
| 292 key_store_hits_(0), | 295 key_store_hits_(0), |
| 293 inflight_joins_(0), | 296 inflight_joins_(0), |
| 294 workers_created_(0), | 297 workers_created_(0), |
| 295 weak_ptr_factory_(this) { | 298 weak_ptr_factory_(this) { |
| 299 id_ = g_next_id.GetNext(); |
| 296 } | 300 } |
| 297 | 301 |
| 298 ChannelIDService::~ChannelIDService() { | 302 ChannelIDService::~ChannelIDService() { |
| 299 STLDeleteValues(&inflight_); | 303 STLDeleteValues(&inflight_); |
| 300 } | 304 } |
| 301 | 305 |
| 302 // static | 306 // static |
| 303 std::string ChannelIDService::GetDomainForHost(const std::string& host) { | 307 std::string ChannelIDService::GetDomainForHost(const std::string& host) { |
| 304 std::string domain = | 308 std::string domain = |
| 305 registry_controlled_domains::GetDomainAndRegistry( | 309 registry_controlled_domains::GetDomainAndRegistry( |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 535 } |
| 532 | 536 |
| 533 return err; | 537 return err; |
| 534 } | 538 } |
| 535 | 539 |
| 536 int ChannelIDService::channel_id_count() { | 540 int ChannelIDService::channel_id_count() { |
| 537 return channel_id_store_->GetChannelIDCount(); | 541 return channel_id_store_->GetChannelIDCount(); |
| 538 } | 542 } |
| 539 | 543 |
| 540 } // namespace net | 544 } // namespace net |
| OLD | NEW |