| Index: device/hid/hid_connection.cc
|
| diff --git a/device/hid/hid_connection.cc b/device/hid/hid_connection.cc
|
| index 5ff39f3f95e81ac1f99d67e8ec0dffd0a95233dd..6ce2d7fd0024b20fbab5ad50647613f54500188e 100644
|
| --- a/device/hid/hid_connection.cc
|
| +++ b/device/hid/hid_connection.cc
|
| @@ -38,14 +38,12 @@ struct CollectionIsProtected {
|
| }
|
| };
|
|
|
| -bool FindCollectionByReportId(const HidDeviceInfo& device_info,
|
| +bool FindCollectionByReportId(const std::vector<HidCollectionInfo>& collections,
|
| uint8_t report_id,
|
| HidCollectionInfo* collection_info) {
|
| - std::vector<HidCollectionInfo>::const_iterator collection_iter =
|
| - std::find_if(device_info.collections.begin(),
|
| - device_info.collections.end(),
|
| - CollectionHasReportId(report_id));
|
| - if (collection_iter != device_info.collections.end()) {
|
| + std::vector<HidCollectionInfo>::const_iterator collection_iter = std::find_if(
|
| + collections.begin(), collections.end(), CollectionHasReportId(report_id));
|
| + if (collection_iter != collections.end()) {
|
| if (collection_info) {
|
| *collection_info = *collection_iter;
|
| }
|
| @@ -55,17 +53,17 @@ bool FindCollectionByReportId(const HidDeviceInfo& device_info,
|
| return false;
|
| }
|
|
|
| -bool HasProtectedCollection(const HidDeviceInfo& device_info) {
|
| - return std::find_if(device_info.collections.begin(),
|
| - device_info.collections.end(),
|
| - CollectionIsProtected()) != device_info.collections.end();
|
| +bool HasProtectedCollection(const std::vector<HidCollectionInfo>& collections) {
|
| + return std::find_if(collections.begin(), collections.end(),
|
| + CollectionIsProtected()) != collections.end();
|
| }
|
|
|
| } // namespace
|
|
|
| -HidConnection::HidConnection(const HidDeviceInfo& device_info)
|
| +HidConnection::HidConnection(scoped_refptr<HidDeviceInfo> device_info)
|
| : device_info_(device_info), closed_(false) {
|
| - has_protected_collection_ = HasProtectedCollection(device_info);
|
| + has_protected_collection_ =
|
| + HasProtectedCollection(device_info->collections());
|
| }
|
|
|
| HidConnection::~HidConnection() {
|
| @@ -83,7 +81,7 @@ void HidConnection::Close() {
|
|
|
| void HidConnection::Read(const ReadCallback& callback) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - if (device_info_.max_input_report_size == 0) {
|
| + if (device_info_->max_input_report_size() == 0) {
|
| VLOG(1) << "This device does not support input reports.";
|
| callback.Run(false, NULL, 0);
|
| return;
|
| @@ -96,14 +94,14 @@ void HidConnection::Write(scoped_refptr<net::IOBuffer> buffer,
|
| size_t size,
|
| const WriteCallback& callback) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - if (device_info_.max_output_report_size == 0) {
|
| + if (device_info_->max_output_report_size() == 0) {
|
| VLOG(1) << "This device does not support output reports.";
|
| callback.Run(false);
|
| return;
|
| }
|
| DCHECK_GE(size, 1u);
|
| uint8_t report_id = buffer->data()[0];
|
| - if (device_info().has_report_id != (report_id != 0)) {
|
| + if (device_info_->has_report_id() != (report_id != 0)) {
|
| VLOG(1) << "Invalid output report ID.";
|
| callback.Run(false);
|
| return;
|
| @@ -120,12 +118,12 @@ void HidConnection::Write(scoped_refptr<net::IOBuffer> buffer,
|
| void HidConnection::GetFeatureReport(uint8_t report_id,
|
| const ReadCallback& callback) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - if (device_info_.max_feature_report_size == 0) {
|
| + if (device_info_->max_feature_report_size() == 0) {
|
| VLOG(1) << "This device does not support feature reports.";
|
| callback.Run(false, NULL, 0);
|
| return;
|
| }
|
| - if (device_info().has_report_id != (report_id != 0)) {
|
| + if (device_info_->has_report_id() != (report_id != 0)) {
|
| VLOG(1) << "Invalid feature report ID.";
|
| callback.Run(false, NULL, 0);
|
| return;
|
| @@ -143,14 +141,14 @@ void HidConnection::SendFeatureReport(scoped_refptr<net::IOBuffer> buffer,
|
| size_t size,
|
| const WriteCallback& callback) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - if (device_info_.max_feature_report_size == 0) {
|
| + if (device_info_->max_feature_report_size() == 0) {
|
| VLOG(1) << "This device does not support feature reports.";
|
| callback.Run(false);
|
| return;
|
| }
|
| DCHECK_GE(size, 1u);
|
| uint8_t report_id = buffer->data()[0];
|
| - if (device_info().has_report_id != (report_id != 0)) {
|
| + if (device_info_->has_report_id() != (report_id != 0)) {
|
| VLOG(1) << "Invalid feature report ID.";
|
| callback.Run(false);
|
| return;
|
| @@ -180,7 +178,8 @@ bool HidConnection::CompleteRead(scoped_refptr<net::IOBuffer> buffer,
|
|
|
| bool HidConnection::IsReportIdProtected(uint8_t report_id) {
|
| HidCollectionInfo collection_info;
|
| - if (FindCollectionByReportId(device_info_, report_id, &collection_info)) {
|
| + if (FindCollectionByReportId(device_info_->collections(), report_id,
|
| + &collection_info)) {
|
| return collection_info.usage.IsProtected();
|
| }
|
|
|
|
|