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

Unified Diff: device/hid/hid_connection.h

Issue 317783010: chrome.hid: enrich model with report IDs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: device/hid/hid_connection.h
diff --git a/device/hid/hid_connection.h b/device/hid/hid_connection.h
index 5c08fbc5bbdf5733e1e3a3c63149bed7044d768b..35d9c84d38b5e45ed19eeccbce6de2bd8307e227 100644
--- a/device/hid/hid_connection.h
+++ b/device/hid/hid_connection.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
+#include "base/threading/thread_checker.h"
#include "device/hid/hid_device_info.h"
#include "net/base/io_buffer.h"
@@ -16,31 +17,67 @@ namespace device {
class HidConnection : public base::RefCountedThreadSafe<HidConnection> {
public:
- typedef base::Callback<void(bool success, size_t size)> IOCallback;
+ enum SpecialReportIds {
+ kNullReportId = 0x00,
+ kAnyReportId = 0xFF,
+ };
- virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer,
- const IOCallback& callback) = 0;
- virtual void Write(uint8_t report_id,
- scoped_refptr<net::IOBufferWithSize> buffer,
- const IOCallback& callback) = 0;
- virtual void GetFeatureReport(uint8_t report_id,
- scoped_refptr<net::IOBufferWithSize> buffer,
- const IOCallback& callback) = 0;
- virtual void SendFeatureReport(uint8_t report_id,
- scoped_refptr<net::IOBufferWithSize> buffer,
- const IOCallback& callback) = 0;
+ typedef base::Callback<void(bool success, size_t size)> IOCallback;
const HidDeviceInfo& device_info() const { return device_info_; }
+ bool has_protected_collection() const { return has_protected_collection_; }
+ bool has_report_id() const { return has_report_id_; }
+ const base::ThreadChecker& thread_checker() const { return thread_checker_; }
+
+ void Read(scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
+ void Write(uint8_t report_id,
+ scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
+ void GetFeatureReport(uint8_t report_id,
+ scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
+ void SendFeatureReport(uint8_t report_id,
+ scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
protected:
friend class base::RefCountedThreadSafe<HidConnection>;
- friend struct HidDeviceInfo;
explicit HidConnection(const HidDeviceInfo& device_info);
virtual ~HidConnection();
+ virtual void PlatformRead(scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback) = 0;
+ virtual void PlatformWrite(uint8_t report_id,
+ scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback) = 0;
+ virtual void PlatformGetFeatureReport(
+ uint8_t report_id,
+ scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback) = 0;
+ virtual void PlatformSendFeatureReport(
+ uint8_t report_id,
+ scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback) = 0;
+
+ // PlatformRead implementation must call this method on read
+ // success, rather than directly running the callback.
+ // It filters protected reports, running the callback with an
+ // empty buffer in such case.
Ken Rockot(use gerrit already) 2014/06/30 15:19:46 "It filters protected reports and runs the callbac
jracle (use Gerrit) 2014/06/30 15:38:39 Sure. On 2014/06/30 15:19:46, Ken Rockot wrote:
+ void CompleteRead(scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
+
private:
+ bool FilterInputReport(scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
+
+ bool IsReportIdProtected(const uint8_t report_id);
+
const HidDeviceInfo device_info_;
+ bool has_report_id_;
+ bool has_protected_collection_;
+ base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(HidConnection);
};

Powered by Google App Engine
This is Rietveld 408576698