Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: components/webcrypto/webcrypto_impl.cc

Issue 1461703009: Switch //components from vector_as_array to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/webcrypto/crypto_data.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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/stl_util.h"
14 #include "base/task_runner.h" 13 #include "base/task_runner.h"
15 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
16 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/worker_pool.h" 16 #include "base/threading/worker_pool.h"
18 #include "components/webcrypto/algorithm_dispatch.h" 17 #include "components/webcrypto/algorithm_dispatch.h"
19 #include "components/webcrypto/crypto_data.h" 18 #include "components/webcrypto/crypto_data.h"
20 #include "components/webcrypto/generate_key_result.h" 19 #include "components/webcrypto/generate_key_result.h"
21 #include "components/webcrypto/status.h" 20 #include "components/webcrypto/status.h"
22 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 21 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
23 #include "third_party/WebKit/public/platform/WebString.h" 22 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const std::vector<uint8_t>& buffer, 110 const std::vector<uint8_t>& buffer,
112 blink::WebCryptoResult* result) { 111 blink::WebCryptoResult* result) {
113 if (status.IsError()) { 112 if (status.IsError()) {
114 CompleteWithError(status, result); 113 CompleteWithError(status, result);
115 } else { 114 } else {
116 if (buffer.size() > UINT_MAX) { 115 if (buffer.size() > UINT_MAX) {
117 // WebArrayBuffers have a smaller range than std::vector<>, so 116 // WebArrayBuffers have a smaller range than std::vector<>, so
118 // theoretically this could overflow. 117 // theoretically this could overflow.
119 CompleteWithError(Status::ErrorUnexpected(), result); 118 CompleteWithError(Status::ErrorUnexpected(), result);
120 } else { 119 } else {
121 result->completeWithBuffer(vector_as_array(&buffer), 120 result->completeWithBuffer(buffer.data(),
122 static_cast<unsigned int>(buffer.size())); 121 static_cast<unsigned int>(buffer.size()));
123 } 122 }
124 } 123 }
125 } 124 }
126 125
127 void CompleteWithKeyOrError(const Status& status, 126 void CompleteWithKeyOrError(const Status& status,
128 const blink::WebCryptoKey& key, 127 const blink::WebCryptoKey& key,
129 blink::WebCryptoResult* result) { 128 blink::WebCryptoResult* result) {
130 if (status.IsError()) { 129 if (status.IsError()) {
131 CompleteWithError(status, result); 130 CompleteWithError(status, result);
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 void DoExportKeyReply(scoped_ptr<ExportKeyState> state) { 459 void DoExportKeyReply(scoped_ptr<ExportKeyState> state) {
461 if (state->format != blink::WebCryptoKeyFormatJwk) { 460 if (state->format != blink::WebCryptoKeyFormatJwk) {
462 CompleteWithBufferOrError(state->status, state->buffer, &state->result); 461 CompleteWithBufferOrError(state->status, state->buffer, &state->result);
463 return; 462 return;
464 } 463 }
465 464
466 if (state->status.IsError()) { 465 if (state->status.IsError()) {
467 CompleteWithError(state->status, &state->result); 466 CompleteWithError(state->status, &state->result);
468 } else { 467 } else {
469 state->result.completeWithJson( 468 state->result.completeWithJson(
470 reinterpret_cast<const char*>(vector_as_array(&state->buffer)), 469 reinterpret_cast<const char*>(state->buffer.data()),
471 static_cast<unsigned int>(state->buffer.size())); 470 static_cast<unsigned int>(state->buffer.size()));
472 } 471 }
473 } 472 }
474 473
475 void DoExportKey(scoped_ptr<ExportKeyState> passed_state) { 474 void DoExportKey(scoped_ptr<ExportKeyState> passed_state) {
476 ExportKeyState* state = passed_state.get(); 475 ExportKeyState* state = passed_state.get();
477 if (state->cancelled()) 476 if (state->cancelled())
478 return; 477 return;
479 state->status = 478 state->status =
480 webcrypto::ExportKey(state->format, state->key, &state->buffer); 479 webcrypto::ExportKey(state->format, state->key, &state->buffer);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 webcrypto::CryptoData(key_data, key_data_size), &key); 781 webcrypto::CryptoData(key_data, key_data_size), &key);
783 } 782 }
784 783
785 bool WebCryptoImpl::serializeKeyForClone( 784 bool WebCryptoImpl::serializeKeyForClone(
786 const blink::WebCryptoKey& key, 785 const blink::WebCryptoKey& key,
787 blink::WebVector<unsigned char>& key_data) { 786 blink::WebVector<unsigned char>& key_data) {
788 return webcrypto::SerializeKeyForClone(key, &key_data); 787 return webcrypto::SerializeKeyForClone(key, &key_data);
789 } 788 }
790 789
791 } // namespace webcrypto 790 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/crypto_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698