| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 connection->Read(base::Bind(&HidReceiveFunction::OnFinished, this)); | 261 connection->Read(base::Bind(&HidReceiveFunction::OnFinished, this)); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void HidReceiveFunction::OnFinished(bool success, | 264 void HidReceiveFunction::OnFinished(bool success, |
| 265 scoped_refptr<net::IOBuffer> buffer, | 265 scoped_refptr<net::IOBuffer> buffer, |
| 266 size_t size) { | 266 size_t size) { |
| 267 if (success) { | 267 if (success) { |
| 268 DCHECK_GE(size, 1u); | 268 DCHECK_GE(size, 1u); |
| 269 int report_id = reinterpret_cast<uint8_t*>(buffer->data())[0]; | 269 int report_id = reinterpret_cast<uint8_t*>(buffer->data())[0]; |
| 270 | 270 |
| 271 Respond(TwoArguments(base::MakeUnique<base::FundamentalValue>(report_id), | 271 Respond(TwoArguments(base::MakeUnique<base::Value>(report_id), |
| 272 base::BinaryValue::CreateWithCopiedBuffer( | 272 base::BinaryValue::CreateWithCopiedBuffer( |
| 273 buffer->data() + 1, size - 1))); | 273 buffer->data() + 1, size - 1))); |
| 274 } else { | 274 } else { |
| 275 Respond(Error(kErrorTransfer)); | 275 Respond(Error(kErrorTransfer)); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 HidSendFunction::HidSendFunction() {} | 279 HidSendFunction::HidSendFunction() {} |
| 280 | 280 |
| 281 HidSendFunction::~HidSendFunction() {} | 281 HidSendFunction::~HidSendFunction() {} |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 void HidSendFeatureReportFunction::OnFinished(bool success) { | 362 void HidSendFeatureReportFunction::OnFinished(bool success) { |
| 363 if (success) { | 363 if (success) { |
| 364 Respond(NoArguments()); | 364 Respond(NoArguments()); |
| 365 } else { | 365 } else { |
| 366 Respond(Error(kErrorTransfer)); | 366 Respond(Error(kErrorTransfer)); |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace extensions | 370 } // namespace extensions |
| OLD | NEW |