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

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

Issue 2804313005: Make HidConnection::Read reentrancy safe (Closed)
Patch Set: Rebased. Created 3 years, 8 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.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 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 #ifndef DEVICE_HID_HID_CONNECTION_H_ 5 #ifndef DEVICE_HID_HID_CONNECTION_H_
6 #define DEVICE_HID_HID_CONNECTION_H_ 6 #define DEVICE_HID_HID_CONNECTION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 virtual void PlatformRead(const ReadCallback& callback) = 0; 68 virtual void PlatformRead(const ReadCallback& callback) = 0;
69 virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, 69 virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
70 size_t size, 70 size_t size,
71 const WriteCallback& callback) = 0; 71 const WriteCallback& callback) = 0;
72 virtual void PlatformGetFeatureReport(uint8_t report_id, 72 virtual void PlatformGetFeatureReport(uint8_t report_id,
73 const ReadCallback& callback) = 0; 73 const ReadCallback& callback) = 0;
74 virtual void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer, 74 virtual void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer,
75 size_t size, 75 size_t size,
76 const WriteCallback& callback) = 0; 76 const WriteCallback& callback) = 0;
77 77
78 // PlatformRead implementation must call this method on read 78 bool IsReportIdProtected(uint8_t report_id);
79 // success, rather than directly running the callback.
80 // In case incoming buffer is empty or protected, it is filtered
81 // and this method returns false. Otherwise it runs the callback
82 // and returns true.
83 bool CompleteRead(scoped_refptr<net::IOBuffer> buffer,
84 size_t size,
85 const ReadCallback& callback);
86 79
87 private: 80 private:
88 bool IsReportIdProtected(uint8_t report_id);
89
90 scoped_refptr<HidDeviceInfo> device_info_; 81 scoped_refptr<HidDeviceInfo> device_info_;
91 bool has_protected_collection_; 82 bool has_protected_collection_;
92 base::ThreadChecker thread_checker_; 83 base::ThreadChecker thread_checker_;
93 bool closed_; 84 bool closed_;
94 85
95 DISALLOW_COPY_AND_ASSIGN(HidConnection); 86 DISALLOW_COPY_AND_ASSIGN(HidConnection);
96 }; 87 };
97 88
98 struct PendingHidReport { 89 struct PendingHidReport {
99 PendingHidReport(); 90 PendingHidReport();
100 PendingHidReport(const PendingHidReport& other); 91 PendingHidReport(const PendingHidReport& other);
101 ~PendingHidReport(); 92 ~PendingHidReport();
102 93
103 scoped_refptr<net::IOBuffer> buffer; 94 scoped_refptr<net::IOBuffer> buffer;
104 size_t size; 95 size_t size;
105 }; 96 };
106 97
107 struct PendingHidRead { 98 struct PendingHidRead {
108 PendingHidRead(); 99 PendingHidRead();
109 PendingHidRead(const PendingHidRead& other); 100 PendingHidRead(const PendingHidRead& other);
110 ~PendingHidRead(); 101 ~PendingHidRead();
111 102
112 HidConnection::ReadCallback callback; 103 HidConnection::ReadCallback callback;
113 }; 104 };
114 105
115 } // namespace device 106 } // namespace device
116 107
117 #endif // DEVICE_HID_HID_CONNECTION_H_ 108 #endif // DEVICE_HID_HID_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | device/hid/hid_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698