Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: device/hid/hid_connection.cc

Issue 943783003: Pad HID output reports on Windows to the maximum output report size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added "size" to comment. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | device/hid/hid_connection_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | device/hid/hid_connection_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698