| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate_; | 48 std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 ThreadedSSLPrivateKey::ThreadedSSLPrivateKey( | 51 ThreadedSSLPrivateKey::ThreadedSSLPrivateKey( |
| 52 std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate, | 52 std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate, |
| 53 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 53 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 54 : core_(new Core(std::move(delegate))), | 54 : core_(new Core(std::move(delegate))), |
| 55 task_runner_(std::move(task_runner)), | 55 task_runner_(std::move(task_runner)), |
| 56 weak_factory_(this) {} | 56 weak_factory_(this) {} |
| 57 | 57 |
| 58 SSLPrivateKey::Type ThreadedSSLPrivateKey::GetType() { | |
| 59 return core_->delegate()->GetType(); | |
| 60 } | |
| 61 | |
| 62 std::vector<SSLPrivateKey::Hash> ThreadedSSLPrivateKey::GetDigestPreferences() { | 58 std::vector<SSLPrivateKey::Hash> ThreadedSSLPrivateKey::GetDigestPreferences() { |
| 63 return core_->delegate()->GetDigestPreferences(); | 59 return core_->delegate()->GetDigestPreferences(); |
| 64 } | 60 } |
| 65 | 61 |
| 66 size_t ThreadedSSLPrivateKey::GetMaxSignatureLengthInBytes() { | |
| 67 return core_->delegate()->GetMaxSignatureLengthInBytes(); | |
| 68 } | |
| 69 | |
| 70 void ThreadedSSLPrivateKey::SignDigest( | 62 void ThreadedSSLPrivateKey::SignDigest( |
| 71 SSLPrivateKey::Hash hash, | 63 SSLPrivateKey::Hash hash, |
| 72 const base::StringPiece& input, | 64 const base::StringPiece& input, |
| 73 const SSLPrivateKey::SignCallback& callback) { | 65 const SSLPrivateKey::SignCallback& callback) { |
| 74 std::vector<uint8_t>* signature = new std::vector<uint8_t>; | 66 std::vector<uint8_t>* signature = new std::vector<uint8_t>; |
| 75 base::PostTaskAndReplyWithResult( | 67 base::PostTaskAndReplyWithResult( |
| 76 task_runner_.get(), FROM_HERE, | 68 task_runner_.get(), FROM_HERE, |
| 77 base::Bind(&ThreadedSSLPrivateKey::Core::SignDigest, core_, hash, | 69 base::Bind(&ThreadedSSLPrivateKey::Core::SignDigest, core_, hash, |
| 78 input.as_string(), base::Unretained(signature)), | 70 input.as_string(), base::Unretained(signature)), |
| 79 base::Bind(&DoCallback, weak_factory_.GetWeakPtr(), callback, | 71 base::Bind(&DoCallback, weak_factory_.GetWeakPtr(), callback, |
| 80 base::Owned(signature))); | 72 base::Owned(signature))); |
| 81 } | 73 } |
| 82 | 74 |
| 83 ThreadedSSLPrivateKey::~ThreadedSSLPrivateKey() {} | 75 ThreadedSSLPrivateKey::~ThreadedSSLPrivateKey() {} |
| 84 | 76 |
| 85 } // namespace net | 77 } // namespace net |
| OLD | NEW |