| 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" | |
| 19 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 20 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 21 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 22 #include "base/task_runner.h" | 21 #include "base/task_runner.h" |
| 22 #include "base/thread_task_runner_handle.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_OPENSSL) | 30 #if !defined(USE_OPENSSL) |
| 31 #include <private/pprthred.h> // PR_DetachThread | 31 #include <private/pprthred.h> // PR_DetachThread |
| 32 #endif | 32 #endif |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // ChannelIDServiceWorker runs on a worker thread and takes care of the | 212 // ChannelIDServiceWorker runs on a worker thread and takes care of the |
| 213 // blocking process of performing key generation. Will take care of deleting | 213 // blocking process of performing key generation. Will take care of deleting |
| 214 // itself once Start() is called. | 214 // itself once Start() is called. |
| 215 class ChannelIDServiceWorker { | 215 class ChannelIDServiceWorker { |
| 216 public: | 216 public: |
| 217 typedef base::Callback<void( | 217 typedef base::Callback<void( |
| 218 const std::string&, | 218 const std::string&, |
| 219 int, | 219 int, |
| 220 scoped_ptr<ChannelIDStore::ChannelID>)> WorkerDoneCallback; | 220 scoped_ptr<ChannelIDStore::ChannelID>)> WorkerDoneCallback; |
| 221 | 221 |
| 222 ChannelIDServiceWorker( | 222 ChannelIDServiceWorker(const std::string& server_identifier, |
| 223 const std::string& server_identifier, | 223 const WorkerDoneCallback& callback) |
| 224 const WorkerDoneCallback& callback) | |
| 225 : server_identifier_(server_identifier), | 224 : server_identifier_(server_identifier), |
| 226 serial_number_(base::RandInt(0, std::numeric_limits<int>::max())), | 225 serial_number_(base::RandInt(0, std::numeric_limits<int>::max())), |
| 227 origin_loop_(base::MessageLoopProxy::current()), | 226 origin_loop_(base::ThreadTaskRunnerHandle::Get()), |
| 228 callback_(callback) { | 227 callback_(callback) {} |
| 229 } | |
| 230 | 228 |
| 231 // Starts the worker on |task_runner|. If the worker fails to start, such as | 229 // Starts the worker on |task_runner|. If the worker fails to start, such as |
| 232 // if the task runner is shutting down, then it will take care of deleting | 230 // if the task runner is shutting down, then it will take care of deleting |
| 233 // itself. | 231 // itself. |
| 234 bool Start(const scoped_refptr<base::TaskRunner>& task_runner) { | 232 bool Start(const scoped_refptr<base::TaskRunner>& task_runner) { |
| 235 DCHECK(origin_loop_->RunsTasksOnCurrentThread()); | 233 DCHECK(origin_loop_->RunsTasksOnCurrentThread()); |
| 236 | 234 |
| 237 return task_runner->PostTask( | 235 return task_runner->PostTask( |
| 238 FROM_HERE, | 236 FROM_HERE, |
| 239 base::Bind(&ChannelIDServiceWorker::Run, base::Owned(this))); | 237 base::Bind(&ChannelIDServiceWorker::Run, base::Owned(this))); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 } | 664 } |
| 667 | 665 |
| 668 return err; | 666 return err; |
| 669 } | 667 } |
| 670 | 668 |
| 671 int ChannelIDService::cert_count() { | 669 int ChannelIDService::cert_count() { |
| 672 return channel_id_store_->GetChannelIDCount(); | 670 return channel_id_store_->GetChannelIDCount(); |
| 673 } | 671 } |
| 674 | 672 |
| 675 } // namespace net | 673 } // namespace net |
| OLD | NEW |