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 "base/stl_util.h" | |
11 #include "device/core/device_client.h" | 10 #include "device/core/device_client.h" |
12 #include "device/hid/hid_connection.h" | 11 #include "device/hid/hid_connection.h" |
13 #include "device/hid/hid_device_filter.h" | 12 #include "device/hid/hid_device_filter.h" |
14 #include "device/hid/hid_device_info.h" | 13 #include "device/hid/hid_device_info.h" |
15 #include "device/hid/hid_service.h" | 14 #include "device/hid/hid_service.h" |
16 #include "extensions/browser/api/api_resource_manager.h" | 15 #include "extensions/browser/api/api_resource_manager.h" |
17 #include "extensions/browser/api/device_permissions_prompt.h" | 16 #include "extensions/browser/api/device_permissions_prompt.h" |
18 #include "extensions/browser/api/extensions_api_client.h" | 17 #include "extensions/browser/api/extensions_api_client.h" |
19 #include "extensions/common/api/hid.h" | 18 #include "extensions/common/api/hid.h" |
20 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 parameters_ = hid::SendFeatureReport::Params::Create(*args_); | 338 parameters_ = hid::SendFeatureReport::Params::Create(*args_); |
340 EXTENSION_FUNCTION_VALIDATE(parameters_); | 339 EXTENSION_FUNCTION_VALIDATE(parameters_); |
341 set_connection_id(parameters_->connection_id); | 340 set_connection_id(parameters_->connection_id); |
342 return true; | 341 return true; |
343 } | 342 } |
344 | 343 |
345 void HidSendFeatureReportFunction::StartWork(HidConnection* connection) { | 344 void HidSendFeatureReportFunction::StartWork(HidConnection* connection) { |
346 scoped_refptr<net::IOBufferWithSize> buffer( | 345 scoped_refptr<net::IOBufferWithSize> buffer( |
347 new net::IOBufferWithSize(parameters_->data.size() + 1)); | 346 new net::IOBufferWithSize(parameters_->data.size() + 1)); |
348 buffer->data()[0] = static_cast<uint8_t>(parameters_->report_id); | 347 buffer->data()[0] = static_cast<uint8_t>(parameters_->report_id); |
349 memcpy(buffer->data() + 1, vector_as_array(¶meters_->data), | 348 memcpy(buffer->data() + 1, parameters_->data.data(), |
350 parameters_->data.size()); | 349 parameters_->data.size()); |
351 connection->SendFeatureReport( | 350 connection->SendFeatureReport( |
352 buffer, buffer->size(), | 351 buffer, buffer->size(), |
353 base::Bind(&HidSendFeatureReportFunction::OnFinished, this)); | 352 base::Bind(&HidSendFeatureReportFunction::OnFinished, this)); |
354 } | 353 } |
355 | 354 |
356 void HidSendFeatureReportFunction::OnFinished(bool success) { | 355 void HidSendFeatureReportFunction::OnFinished(bool success) { |
357 if (success) { | 356 if (success) { |
358 Respond(NoArguments()); | 357 Respond(NoArguments()); |
359 } else { | 358 } else { |
360 Respond(Error(kErrorTransfer)); | 359 Respond(Error(kErrorTransfer)); |
361 } | 360 } |
362 } | 361 } |
363 | 362 |
364 } // namespace extensions | 363 } // namespace extensions |
OLD | NEW |