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

Side by Side Diff: extensions/browser/api/hid/hid_api.cc

Issue 850173002: Use std::vector<char> rather than std::string to represent a base::BinaryValue Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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 | « no previous file | tools/json_schema_compiler/cc_generator.py » ('j') | 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 "extensions/browser/api/hid/hid_api.h" 5 #include "extensions/browser/api/hid/hid_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "device/core/device_client.h" 10 #include "device/core/device_client.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 parameters_ = hid::Send::Params::Create(*args_); 246 parameters_ = hid::Send::Params::Create(*args_);
247 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); 247 EXTENSION_FUNCTION_VALIDATE(parameters_.get());
248 set_connection_id(parameters_->connection_id); 248 set_connection_id(parameters_->connection_id);
249 return true; 249 return true;
250 } 250 }
251 251
252 void HidSendFunction::StartWork(HidConnection* connection) { 252 void HidSendFunction::StartWork(HidConnection* connection) {
253 scoped_refptr<net::IOBufferWithSize> buffer( 253 scoped_refptr<net::IOBufferWithSize> buffer(
254 new net::IOBufferWithSize(parameters_->data.size() + 1)); 254 new net::IOBufferWithSize(parameters_->data.size() + 1));
255 buffer->data()[0] = static_cast<uint8_t>(parameters_->report_id); 255 buffer->data()[0] = static_cast<uint8_t>(parameters_->report_id);
256 memcpy( 256 memcpy(buffer->data() + 1, parameters_->data.data(),
257 buffer->data() + 1, parameters_->data.c_str(), parameters_->data.size()); 257 parameters_->data.size());
258 connection->Write(buffer, buffer->size(), 258 connection->Write(buffer, buffer->size(),
259 base::Bind(&HidSendFunction::OnFinished, this)); 259 base::Bind(&HidSendFunction::OnFinished, this));
260 } 260 }
261 261
262 void HidSendFunction::OnFinished(bool success) { 262 void HidSendFunction::OnFinished(bool success) {
263 if (success) { 263 if (success) {
264 Respond(NoArguments()); 264 Respond(NoArguments());
265 } else { 265 } else {
266 Respond(Error(kErrorTransfer)); 266 Respond(Error(kErrorTransfer));
267 } 267 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 void HidSendFeatureReportFunction::OnFinished(bool success) { 321 void HidSendFeatureReportFunction::OnFinished(bool success) {
322 if (success) { 322 if (success) {
323 Respond(NoArguments()); 323 Respond(NoArguments());
324 } else { 324 } else {
325 Respond(Error(kErrorTransfer)); 325 Respond(Error(kErrorTransfer));
326 } 326 }
327 } 327 }
328 328
329 } // namespace extensions 329 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/cc_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698