summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_connection.h
diff options
context:
space:
mode:
authorjracle@logitech.com <jracle@logitech.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-03 02:53:23 +0000
committerjracle@logitech.com <jracle@logitech.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-03 02:53:23 +0000
commit9ff38235dcea4a3a95e25b602c347f5646bdf4bb (patch)
tree8b3c0b46ea6699591de7e55e760b73b4753610ae /device/hid/hid_connection.h
parent5a43fe6ffbd21cc9a494fa6ed841f877fa09e243 (diff)
downloadchromium_src-9ff38235dcea4a3a95e25b602c347f5646bdf4bb.zip
chromium_src-9ff38235dcea4a3a95e25b602c347f5646bdf4bb.tar.gz
chromium_src-9ff38235dcea4a3a95e25b602c347f5646bdf4bb.tar.bz2
chrome.hid: enrich model with report IDs
- add report IDs and max report size - don't expose sensitive usages BUG=364423 R=rockot@chromium.org TESTS=run device_unittests (HidReportDescriptorTest) Review URL: https://codereview.chromium.org/317783010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_connection.h')
-rw-r--r--device/hid/hid_connection.h61
1 files changed, 48 insertions, 13 deletions
diff --git a/device/hid/hid_connection.h b/device/hid/hid_connection.h
index 5c08fbc..963b89f 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,65 @@ 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.
+ // In case incoming buffer is empty or protected, it is filtered
+ // and this method returns false. Otherwise it runs the callback
+ // and returns true.
+ bool CompleteRead(scoped_refptr<net::IOBufferWithSize> buffer,
+ const IOCallback& callback);
+
private:
+ 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);
};