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 "components/webcrypto/webcrypto_impl.h" | 5 #include "components/webcrypto/webcrypto_impl.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // | 70 // |
71 // * blink::WebCryptoResult is not threadsafe and should only be operated on | 71 // * blink::WebCryptoResult is not threadsafe and should only be operated on |
72 // the target Blink thread. HOWEVER, it is safe to delete it from any thread. | 72 // the target Blink thread. HOWEVER, it is safe to delete it from any thread. |
73 // This can happen if by the time the operation has completed in the crypto | 73 // This can happen if by the time the operation has completed in the crypto |
74 // worker pool, the Blink worker thread that initiated the request is gone. | 74 // worker pool, the Blink worker thread that initiated the request is gone. |
75 // Posting back to the origin thread will fail, and the WebCryptoResult will | 75 // Posting back to the origin thread will fail, and the WebCryptoResult will |
76 // be deleted while running in the crypto worker pool. | 76 // be deleted while running in the crypto worker pool. |
77 class CryptoThreadPool { | 77 class CryptoThreadPool { |
78 public: | 78 public: |
79 CryptoThreadPool() | 79 CryptoThreadPool() |
80 : worker_pool_(new base::SequencedWorkerPool(1, "WebCrypto")), | 80 : worker_pool_( |
| 81 new base::SequencedWorkerPool(1, |
| 82 "WebCrypto", |
| 83 base::TaskPriority::USER_BLOCKING)), |
81 task_runner_(worker_pool_->GetSequencedTaskRunnerWithShutdownBehavior( | 84 task_runner_(worker_pool_->GetSequencedTaskRunnerWithShutdownBehavior( |
82 worker_pool_->GetSequenceToken(), | 85 worker_pool_->GetSequenceToken(), |
83 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)) {} | 86 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)) {} |
84 | 87 |
85 static bool PostTask(const tracked_objects::Location& from_here, | 88 static bool PostTask(const tracked_objects::Location& from_here, |
86 const base::Closure& task); | 89 const base::Closure& task); |
87 | 90 |
88 private: | 91 private: |
89 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 92 scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
90 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 93 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 webcrypto::CryptoData(key_data, key_data_size), &key); | 789 webcrypto::CryptoData(key_data, key_data_size), &key); |
787 } | 790 } |
788 | 791 |
789 bool WebCryptoImpl::serializeKeyForClone( | 792 bool WebCryptoImpl::serializeKeyForClone( |
790 const blink::WebCryptoKey& key, | 793 const blink::WebCryptoKey& key, |
791 blink::WebVector<unsigned char>& key_data) { | 794 blink::WebVector<unsigned char>& key_data) { |
792 return webcrypto::SerializeKeyForClone(key, &key_data); | 795 return webcrypto::SerializeKeyForClone(key, &key_data); |
793 } | 796 } |
794 | 797 |
795 } // namespace webcrypto | 798 } // namespace webcrypto |
OLD | NEW |