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 namespace device { | 9 namespace device { |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 void HidConnection::Write(scoped_refptr<net::IOBuffer> buffer, | 93 void HidConnection::Write(scoped_refptr<net::IOBuffer> buffer, |
94 size_t size, | 94 size_t size, |
95 const WriteCallback& callback) { | 95 const WriteCallback& callback) { |
96 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
97 if (device_info_->max_output_report_size() == 0) { | 97 if (device_info_->max_output_report_size() == 0) { |
98 VLOG(1) << "This device does not support output reports."; | 98 VLOG(1) << "This device does not support output reports."; |
99 callback.Run(false); | 99 callback.Run(false); |
100 return; | 100 return; |
101 } | 101 } |
| 102 if (size > device_info_->max_output_report_size() + 1) { |
| 103 VLOG(1) << "Output report buffer too long (" << size << " > " |
| 104 << (device_info_->max_output_report_size() + 1) << ")."; |
| 105 callback.Run(false); |
| 106 return; |
| 107 } |
102 DCHECK_GE(size, 1u); | 108 DCHECK_GE(size, 1u); |
103 uint8_t report_id = buffer->data()[0]; | 109 uint8_t report_id = buffer->data()[0]; |
104 if (device_info_->has_report_id() != (report_id != 0)) { | 110 if (device_info_->has_report_id() != (report_id != 0)) { |
105 VLOG(1) << "Invalid output report ID."; | 111 VLOG(1) << "Invalid output report ID."; |
106 callback.Run(false); | 112 callback.Run(false); |
107 return; | 113 return; |
108 } | 114 } |
109 if (IsReportIdProtected(report_id)) { | 115 if (IsReportIdProtected(report_id)) { |
110 VLOG(1) << "Attempt to set a protected output report."; | 116 VLOG(1) << "Attempt to set a protected output report."; |
111 callback.Run(false); | 117 callback.Run(false); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 194 |
189 PendingHidReport::PendingHidReport() {} | 195 PendingHidReport::PendingHidReport() {} |
190 | 196 |
191 PendingHidReport::~PendingHidReport() {} | 197 PendingHidReport::~PendingHidReport() {} |
192 | 198 |
193 PendingHidRead::PendingHidRead() {} | 199 PendingHidRead::PendingHidRead() {} |
194 | 200 |
195 PendingHidRead::~PendingHidRead() {} | 201 PendingHidRead::~PendingHidRead() {} |
196 | 202 |
197 } // namespace device | 203 } // namespace device |
OLD | NEW |