OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "device/hid/hid_connection.h" | 5 #include "device/hid/hid_connection.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/stl_util.h" |
9 #include "components/device_event_log/device_event_log.h" | 10 #include "components/device_event_log/device_event_log.h" |
10 | 11 |
11 namespace device { | 12 namespace device { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // Functor used to filter collections by report ID. | 16 // Functor used to filter collections by report ID. |
16 struct CollectionHasReportId { | 17 struct CollectionHasReportId { |
17 explicit CollectionHasReportId(uint8_t report_id) : report_id_(report_id) {} | 18 explicit CollectionHasReportId(uint8_t report_id) : report_id_(report_id) {} |
18 | 19 |
19 bool operator()(const HidCollectionInfo& info) const { | 20 bool operator()(const HidCollectionInfo& info) const { |
20 if (info.report_ids.size() == 0 || | 21 if (info.report_ids.size() == 0 || |
21 report_id_ == HidConnection::kNullReportId) | 22 report_id_ == HidConnection::kNullReportId) |
22 return false; | 23 return false; |
23 | 24 |
24 if (report_id_ == HidConnection::kAnyReportId) | 25 if (report_id_ == HidConnection::kAnyReportId) |
25 return true; | 26 return true; |
26 | 27 |
27 return std::find(info.report_ids.begin(), | 28 return base::ContainsValue(info.report_ids, report_id_); |
28 info.report_ids.end(), | |
29 report_id_) != info.report_ids.end(); | |
30 } | 29 } |
31 | 30 |
32 private: | 31 private: |
33 const uint8_t report_id_; | 32 const uint8_t report_id_; |
34 }; | 33 }; |
35 | 34 |
36 // Functor returning true if collection has a protected usage. | 35 // Functor returning true if collection has a protected usage. |
37 struct CollectionIsProtected { | 36 struct CollectionIsProtected { |
38 bool operator()(const HidCollectionInfo& info) const { | 37 bool operator()(const HidCollectionInfo& info) const { |
39 return info.usage.IsProtected(); | 38 return info.usage.IsProtected(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 185 |
187 PendingHidReport::~PendingHidReport() {} | 186 PendingHidReport::~PendingHidReport() {} |
188 | 187 |
189 PendingHidRead::PendingHidRead() {} | 188 PendingHidRead::PendingHidRead() {} |
190 | 189 |
191 PendingHidRead::PendingHidRead(const PendingHidRead& other) = default; | 190 PendingHidRead::PendingHidRead(const PendingHidRead& other) = default; |
192 | 191 |
193 PendingHidRead::~PendingHidRead() {} | 192 PendingHidRead::~PendingHidRead() {} |
194 | 193 |
195 } // namespace device | 194 } // namespace device |
OLD | NEW |