diff options
author | reillyg <reillyg@chromium.org> | 2014-08-26 12:10:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-26 19:11:25 +0000 |
commit | 0e9bf9bc05be91d727134887b3c453353be1024d (patch) | |
tree | d8f05cc95f76c4452abcd1e229e00e27587a6ad0 /device/hid/hid_connection_mac.h | |
parent | eb08cced4cf6c7d271dd506a13cb889aaa6d45ad (diff) | |
download | chromium_src-0e9bf9bc05be91d727134887b3c453353be1024d.zip chromium_src-0e9bf9bc05be91d727134887b3c453353be1024d.tar.gz chromium_src-0e9bf9bc05be91d727134887b3c453353be1024d.tar.bz2 |
Don't pass buffers to HidConnection::Read because it knows the size.
The HidConnection knows the appropriate read buffer size and the
platform-specific implementation may already have a buffer that it is
waiting to return to the next caller. Passing a buffer in is therefore
unnecessary, one can be provided in the callback.
By standardizing on a buffer format which always includes the report ID
as the first byte (even when it is zero) most of the buffer copying can
be removed except in the case of OS X's persistent read buffer and
getting feature reports on Windows.
BUG=
Review URL: https://codereview.chromium.org/499713002
Cr-Commit-Position: refs/heads/master@{#291954}
Diffstat (limited to 'device/hid/hid_connection_mac.h')
-rw-r--r-- | device/hid/hid_connection_mac.h | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/device/hid/hid_connection_mac.h b/device/hid/hid_connection_mac.h index 02dde04..81153b6 100644 --- a/device/hid/hid_connection_mac.h +++ b/device/hid/hid_connection_mac.h @@ -28,24 +28,21 @@ class HidConnectionMac : public HidConnection { public: explicit HidConnectionMac(HidDeviceInfo device_info); - // HidConnection implementation. - virtual void PlatformRead(scoped_refptr<net::IOBufferWithSize> buffer, - const IOCallback& callback) OVERRIDE; - virtual void PlatformWrite(uint8_t report_id, - scoped_refptr<net::IOBufferWithSize> buffer, - const IOCallback& callback) OVERRIDE; - virtual void PlatformGetFeatureReport( - uint8_t report_id, - scoped_refptr<net::IOBufferWithSize> buffer, - const IOCallback& callback) OVERRIDE; - virtual void PlatformSendFeatureReport( - uint8_t report_id, - scoped_refptr<net::IOBufferWithSize> buffer, - const IOCallback& callback) OVERRIDE; - private: virtual ~HidConnectionMac(); + // HidConnection implementation. + virtual void PlatformRead(const ReadCallback& callback) OVERRIDE; + virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, + size_t size, + const WriteCallback& callback) OVERRIDE; + virtual void PlatformGetFeatureReport(uint8_t report_id, + const ReadCallback& callback) OVERRIDE; + virtual void PlatformSendFeatureReport( + scoped_refptr<net::IOBuffer> buffer, + size_t size, + const WriteCallback& callback) OVERRIDE; + static void InputReportCallback(void* context, IOReturn result, void* sender, @@ -55,9 +52,9 @@ class HidConnectionMac : public HidConnection { CFIndex report_length); void WriteReport(IOHIDReportType type, - uint8_t report_id, - scoped_refptr<net::IOBufferWithSize> buffer, - const IOCallback& callback); + scoped_refptr<net::IOBuffer> buffer, + size_t size, + const WriteCallback& callback); void Flush(); void ProcessInputReport(scoped_refptr<net::IOBufferWithSize> buffer); @@ -65,7 +62,7 @@ class HidConnectionMac : public HidConnection { base::ScopedCFTypeRef<IOHIDDeviceRef> device_; scoped_refptr<base::MessageLoopProxy> message_loop_; - scoped_ptr<uint8_t, base::FreeDeleter> inbound_buffer_; + scoped_ptr<uint8_t[]> inbound_buffer_; std::queue<PendingHidReport> pending_reports_; std::queue<PendingHidRead> pending_reads_; |