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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 connection->Read(base::Bind(&HidReceiveFunction::OnFinished, this)); | 281 connection->Read(base::Bind(&HidReceiveFunction::OnFinished, this)); |
282 } | 282 } |
283 | 283 |
284 void HidReceiveFunction::OnFinished(bool success, | 284 void HidReceiveFunction::OnFinished(bool success, |
285 scoped_refptr<net::IOBuffer> buffer, | 285 scoped_refptr<net::IOBuffer> buffer, |
286 size_t size) { | 286 size_t size) { |
287 if (success) { | 287 if (success) { |
288 DCHECK_GE(size, 1u); | 288 DCHECK_GE(size, 1u); |
289 int report_id = reinterpret_cast<uint8_t*>(buffer->data())[0]; | 289 int report_id = reinterpret_cast<uint8_t*>(buffer->data())[0]; |
290 | 290 |
291 Respond(TwoArguments(base::MakeUnique<base::FundamentalValue>(report_id), | 291 Respond(TwoArguments(base::MakeUnique<base::Value>(report_id), |
292 base::BinaryValue::CreateWithCopiedBuffer( | 292 base::BinaryValue::CreateWithCopiedBuffer( |
293 buffer->data() + 1, size - 1))); | 293 buffer->data() + 1, size - 1))); |
294 } else { | 294 } else { |
295 Respond(Error(kErrorTransfer)); | 295 Respond(Error(kErrorTransfer)); |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 HidSendFunction::HidSendFunction() {} | 299 HidSendFunction::HidSendFunction() {} |
300 | 300 |
301 HidSendFunction::~HidSendFunction() {} | 301 HidSendFunction::~HidSendFunction() {} |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 void HidSendFeatureReportFunction::OnFinished(bool success) { | 379 void HidSendFeatureReportFunction::OnFinished(bool success) { |
380 if (success) { | 380 if (success) { |
381 Respond(NoArguments()); | 381 Respond(NoArguments()); |
382 } else { | 382 } else { |
383 Respond(Error(kErrorTransfer)); | 383 Respond(Error(kErrorTransfer)); |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 } // namespace extensions | 387 } // namespace extensions |
OLD | NEW |