| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/threaded_ssl_private_key.h" | 5 #include "net/ssl/threaded_ssl_private_key.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 void DoCallback(const base::WeakPtr<ThreadedSSLPrivateKey>& key, | 20 void DoCallback(const base::WeakPtr<ThreadedSSLPrivateKey>& key, |
| 21 const ThreadedSSLPrivateKey::SignCallback& callback, | 21 const ThreadedSSLPrivateKey::SignCallback& callback, |
| 22 std::vector<uint8_t>* signature, | 22 std::vector<uint8_t>* signature, |
| 23 Error error) { | 23 Error error) { |
| 24 if (!key) | 24 if (!key) |
| 25 return; | 25 return; |
| 26 callback.Run(error, *signature); | 26 callback.Run(error, *signature); |
| 27 } | 27 } |
| 28 } | 28 |
| 29 } // anonymous namespace |
| 29 | 30 |
| 30 class ThreadedSSLPrivateKey::Core | 31 class ThreadedSSLPrivateKey::Core |
| 31 : public base::RefCountedThreadSafe<ThreadedSSLPrivateKey::Core> { | 32 : public base::RefCountedThreadSafe<ThreadedSSLPrivateKey::Core> { |
| 32 public: | 33 public: |
| 33 Core(std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate) | 34 Core(std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate) |
| 34 : delegate_(std::move(delegate)) {} | 35 : delegate_(std::move(delegate)) {} |
| 35 | 36 |
| 36 ThreadedSSLPrivateKey::Delegate* delegate() { return delegate_.get(); } | 37 ThreadedSSLPrivateKey::Delegate* delegate() { return delegate_.get(); } |
| 37 | 38 |
| 38 Error SignDigest(SSLPrivateKey::Hash hash, | 39 Error SignDigest(SSLPrivateKey::Hash hash, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 68 task_runner_.get(), FROM_HERE, | 69 task_runner_.get(), FROM_HERE, |
| 69 base::Bind(&ThreadedSSLPrivateKey::Core::SignDigest, core_, hash, | 70 base::Bind(&ThreadedSSLPrivateKey::Core::SignDigest, core_, hash, |
| 70 input.as_string(), base::Unretained(signature)), | 71 input.as_string(), base::Unretained(signature)), |
| 71 base::Bind(&DoCallback, weak_factory_.GetWeakPtr(), callback, | 72 base::Bind(&DoCallback, weak_factory_.GetWeakPtr(), callback, |
| 72 base::Owned(signature))); | 73 base::Owned(signature))); |
| 73 } | 74 } |
| 74 | 75 |
| 75 ThreadedSSLPrivateKey::~ThreadedSSLPrivateKey() {} | 76 ThreadedSSLPrivateKey::~ThreadedSSLPrivateKey() {} |
| 76 | 77 |
| 77 } // namespace net | 78 } // namespace net |
| OLD | NEW |