| OLD | NEW |
| 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 EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 6 #define EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace net { | 22 namespace net { |
| 23 class IOBuffer; | 23 class IOBuffer; |
| 24 } // namespace net | 24 } // namespace net |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 | 27 |
| 28 class HidAsyncApiFunction : public AsyncApiFunction { | 28 class HidAsyncApiFunction : public AsyncApiFunction { |
| 29 public: | 29 public: |
| 30 HidAsyncApiFunction(); | 30 HidAsyncApiFunction(); |
| 31 | 31 |
| 32 virtual bool PrePrepare() override; | 32 bool PrePrepare() override; |
| 33 virtual bool Respond() override; | 33 bool Respond() override; |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 virtual ~HidAsyncApiFunction(); | 36 ~HidAsyncApiFunction() override; |
| 37 | 37 |
| 38 HidConnectionResource* GetHidConnectionResource(int api_resource_id); | 38 HidConnectionResource* GetHidConnectionResource(int api_resource_id); |
| 39 void RemoveHidConnectionResource(int api_resource_id); | 39 void RemoveHidConnectionResource(int api_resource_id); |
| 40 | 40 |
| 41 void CompleteWithError(const std::string& error); | 41 void CompleteWithError(const std::string& error); |
| 42 | 42 |
| 43 HidDeviceManager* device_manager_; | 43 HidDeviceManager* device_manager_; |
| 44 ApiResourceManager<HidConnectionResource>* connection_manager_; | 44 ApiResourceManager<HidConnectionResource>* connection_manager_; |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(HidAsyncApiFunction); | 47 DISALLOW_COPY_AND_ASSIGN(HidAsyncApiFunction); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class HidGetDevicesFunction : public HidAsyncApiFunction { | 50 class HidGetDevicesFunction : public HidAsyncApiFunction { |
| 51 public: | 51 public: |
| 52 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); | 52 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); |
| 53 | 53 |
| 54 HidGetDevicesFunction(); | 54 HidGetDevicesFunction(); |
| 55 | 55 |
| 56 protected: | 56 protected: |
| 57 virtual bool Prepare() override; | 57 bool Prepare() override; |
| 58 virtual void AsyncWorkStart() override; | 58 void AsyncWorkStart() override; |
| 59 | 59 |
| 60 virtual ~HidGetDevicesFunction(); | 60 ~HidGetDevicesFunction() override; |
| 61 | 61 |
| 62 scoped_ptr<core_api::hid::GetDevices::Params> parameters_; | 62 scoped_ptr<core_api::hid::GetDevices::Params> parameters_; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); | 65 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class HidConnectFunction : public HidAsyncApiFunction { | 68 class HidConnectFunction : public HidAsyncApiFunction { |
| 69 public: | 69 public: |
| 70 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); | 70 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); |
| 71 | 71 |
| 72 HidConnectFunction(); | 72 HidConnectFunction(); |
| 73 | 73 |
| 74 protected: | 74 protected: |
| 75 virtual bool Prepare() override; | 75 bool Prepare() override; |
| 76 virtual void AsyncWorkStart() override; | 76 void AsyncWorkStart() override; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 virtual ~HidConnectFunction(); | 79 ~HidConnectFunction() override; |
| 80 | 80 |
| 81 void OnConnectComplete(scoped_refptr<device::HidConnection> connection); | 81 void OnConnectComplete(scoped_refptr<device::HidConnection> connection); |
| 82 | 82 |
| 83 scoped_ptr<core_api::hid::Connect::Params> parameters_; | 83 scoped_ptr<core_api::hid::Connect::Params> parameters_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(HidConnectFunction); | 85 DISALLOW_COPY_AND_ASSIGN(HidConnectFunction); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class HidDisconnectFunction : public HidAsyncApiFunction { | 88 class HidDisconnectFunction : public HidAsyncApiFunction { |
| 89 public: | 89 public: |
| 90 DECLARE_EXTENSION_FUNCTION("hid.disconnect", HID_DISCONNECT); | 90 DECLARE_EXTENSION_FUNCTION("hid.disconnect", HID_DISCONNECT); |
| 91 | 91 |
| 92 HidDisconnectFunction(); | 92 HidDisconnectFunction(); |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 virtual bool Prepare() override; | 95 bool Prepare() override; |
| 96 virtual void AsyncWorkStart() override; | 96 void AsyncWorkStart() override; |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 virtual ~HidDisconnectFunction(); | 99 ~HidDisconnectFunction() override; |
| 100 | 100 |
| 101 scoped_ptr<core_api::hid::Disconnect::Params> parameters_; | 101 scoped_ptr<core_api::hid::Disconnect::Params> parameters_; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(HidDisconnectFunction); | 103 DISALLOW_COPY_AND_ASSIGN(HidDisconnectFunction); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 class HidReceiveFunction : public HidAsyncApiFunction { | 106 class HidReceiveFunction : public HidAsyncApiFunction { |
| 107 public: | 107 public: |
| 108 DECLARE_EXTENSION_FUNCTION("hid.receive", HID_RECEIVE); | 108 DECLARE_EXTENSION_FUNCTION("hid.receive", HID_RECEIVE); |
| 109 | 109 |
| 110 HidReceiveFunction(); | 110 HidReceiveFunction(); |
| 111 | 111 |
| 112 protected: | 112 protected: |
| 113 virtual bool Prepare() override; | 113 bool Prepare() override; |
| 114 virtual void AsyncWorkStart() override; | 114 void AsyncWorkStart() override; |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 virtual ~HidReceiveFunction(); | 117 ~HidReceiveFunction() override; |
| 118 | 118 |
| 119 void OnFinished(bool success, | 119 void OnFinished(bool success, |
| 120 scoped_refptr<net::IOBuffer> buffer, | 120 scoped_refptr<net::IOBuffer> buffer, |
| 121 size_t size); | 121 size_t size); |
| 122 | 122 |
| 123 scoped_ptr<core_api::hid::Receive::Params> parameters_; | 123 scoped_ptr<core_api::hid::Receive::Params> parameters_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); | 125 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class HidSendFunction : public HidAsyncApiFunction { | 128 class HidSendFunction : public HidAsyncApiFunction { |
| 129 public: | 129 public: |
| 130 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); | 130 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); |
| 131 | 131 |
| 132 HidSendFunction(); | 132 HidSendFunction(); |
| 133 | 133 |
| 134 protected: | 134 protected: |
| 135 virtual bool Prepare() override; | 135 bool Prepare() override; |
| 136 virtual void AsyncWorkStart() override; | 136 void AsyncWorkStart() override; |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 virtual ~HidSendFunction(); | 139 ~HidSendFunction() override; |
| 140 | 140 |
| 141 void OnFinished(bool success); | 141 void OnFinished(bool success); |
| 142 | 142 |
| 143 scoped_ptr<core_api::hid::Send::Params> parameters_; | 143 scoped_ptr<core_api::hid::Send::Params> parameters_; |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); | 145 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 class HidReceiveFeatureReportFunction : public HidAsyncApiFunction { | 148 class HidReceiveFeatureReportFunction : public HidAsyncApiFunction { |
| 149 public: | 149 public: |
| 150 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", | 150 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", |
| 151 HID_RECEIVEFEATUREREPORT); | 151 HID_RECEIVEFEATUREREPORT); |
| 152 | 152 |
| 153 HidReceiveFeatureReportFunction(); | 153 HidReceiveFeatureReportFunction(); |
| 154 | 154 |
| 155 protected: | 155 protected: |
| 156 virtual bool Prepare() override; | 156 bool Prepare() override; |
| 157 virtual void AsyncWorkStart() override; | 157 void AsyncWorkStart() override; |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 virtual ~HidReceiveFeatureReportFunction(); | 160 ~HidReceiveFeatureReportFunction() override; |
| 161 | 161 |
| 162 void OnFinished(bool success, | 162 void OnFinished(bool success, |
| 163 scoped_refptr<net::IOBuffer> buffer, | 163 scoped_refptr<net::IOBuffer> buffer, |
| 164 size_t size); | 164 size_t size); |
| 165 | 165 |
| 166 scoped_ptr<core_api::hid::ReceiveFeatureReport::Params> parameters_; | 166 scoped_ptr<core_api::hid::ReceiveFeatureReport::Params> parameters_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); | 168 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 class HidSendFeatureReportFunction : public HidAsyncApiFunction { | 171 class HidSendFeatureReportFunction : public HidAsyncApiFunction { |
| 172 public: | 172 public: |
| 173 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); | 173 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); |
| 174 | 174 |
| 175 HidSendFeatureReportFunction(); | 175 HidSendFeatureReportFunction(); |
| 176 | 176 |
| 177 protected: | 177 protected: |
| 178 virtual bool Prepare() override; | 178 bool Prepare() override; |
| 179 virtual void AsyncWorkStart() override; | 179 void AsyncWorkStart() override; |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 virtual ~HidSendFeatureReportFunction(); | 182 ~HidSendFeatureReportFunction() override; |
| 183 | 183 |
| 184 void OnFinished(bool success); | 184 void OnFinished(bool success); |
| 185 | 185 |
| 186 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_; | 186 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_; |
| 187 | 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); | 188 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 } // namespace extensions | 191 } // namespace extensions |
| 192 | 192 |
| 193 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 193 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
| OLD | NEW |