| 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 "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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |