| 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 "content/child/webcrypto/webcrypto_impl.h" | 5 #include "content/child/webcrypto/webcrypto_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
| 17 #include "content/child/webcrypto/algorithm_dispatch.h" |
| 17 #include "content/child/webcrypto/crypto_data.h" | 18 #include "content/child/webcrypto/crypto_data.h" |
| 18 #include "content/child/webcrypto/shared_crypto.h" | |
| 19 #include "content/child/webcrypto/status.h" | 19 #include "content/child/webcrypto/status.h" |
| 20 #include "content/child/webcrypto/structured_clone.h" |
| 20 #include "content/child/webcrypto/webcrypto_util.h" | 21 #include "content/child/webcrypto/webcrypto_util.h" |
| 21 #include "content/child/worker_thread_task_runner.h" | 22 #include "content/child/worker_thread_task_runner.h" |
| 22 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 23 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
| 23 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 using webcrypto::Status; | 28 using webcrypto::Status; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 578 } |
| 578 | 579 |
| 579 } // namespace | 580 } // namespace |
| 580 | 581 |
| 581 WebCryptoImpl::WebCryptoImpl() { | 582 WebCryptoImpl::WebCryptoImpl() { |
| 582 } | 583 } |
| 583 | 584 |
| 584 WebCryptoImpl::~WebCryptoImpl() { | 585 WebCryptoImpl::~WebCryptoImpl() { |
| 585 } | 586 } |
| 586 | 587 |
| 587 void WebCryptoImpl::EnsureInit() { | |
| 588 webcrypto::Init(); | |
| 589 } | |
| 590 | |
| 591 void WebCryptoImpl::encrypt(const blink::WebCryptoAlgorithm& algorithm, | 588 void WebCryptoImpl::encrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 592 const blink::WebCryptoKey& key, | 589 const blink::WebCryptoKey& key, |
| 593 const unsigned char* data, | 590 const unsigned char* data, |
| 594 unsigned int data_size, | 591 unsigned int data_size, |
| 595 blink::WebCryptoResult result) { | 592 blink::WebCryptoResult result) { |
| 596 DCHECK(!algorithm.isNull()); | 593 DCHECK(!algorithm.isNull()); |
| 597 | 594 |
| 598 scoped_ptr<EncryptState> state( | 595 scoped_ptr<EncryptState> state( |
| 599 new EncryptState(algorithm, key, data, data_size, result)); | 596 new EncryptState(algorithm, key, data, data_size, result)); |
| 600 if (!CryptoThreadPool::PostTask(FROM_HERE, | 597 if (!CryptoThreadPool::PostTask(FROM_HERE, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 &key); | 763 &key); |
| 767 } | 764 } |
| 768 | 765 |
| 769 bool WebCryptoImpl::serializeKeyForClone( | 766 bool WebCryptoImpl::serializeKeyForClone( |
| 770 const blink::WebCryptoKey& key, | 767 const blink::WebCryptoKey& key, |
| 771 blink::WebVector<unsigned char>& key_data) { | 768 blink::WebVector<unsigned char>& key_data) { |
| 772 return webcrypto::SerializeKeyForClone(key, &key_data); | 769 return webcrypto::SerializeKeyForClone(key, &key_data); |
| 773 } | 770 } |
| 774 | 771 |
| 775 } // namespace content | 772 } // namespace content |
| OLD | NEW |