| 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 CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ |    5 #ifndef CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ | 
|    6 #define CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ |    6 #define CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ | 
|    7  |    7  | 
|    8 #include <string> |    8 #include <string> | 
|    9  |    9  | 
|   10 #include "base/basictypes.h" |  | 
|   11 #include "base/memory/ref_counted.h" |   10 #include "base/memory/ref_counted.h" | 
 |   11 #include "base/memory/scoped_ptr.h" | 
|   12 #include "chrome/browser/extensions/api/api_function.h" |   12 #include "chrome/browser/extensions/api/api_function.h" | 
|   13 #include "chrome/browser/extensions/api/api_resource_manager.h" |   13 #include "chrome/browser/extensions/api/api_resource_manager.h" | 
|   14 #include "chrome/browser/extensions/api/hid/hid_device_resource.h" |   14 #include "chrome/browser/extensions/api/hid/hid_connection_resource.h" | 
 |   15 #include "chrome/browser/extensions/api/hid/hid_device_manager.h" | 
|   15 #include "chrome/browser/extensions/extension_function_histogram_value.h" |   16 #include "chrome/browser/extensions/extension_function_histogram_value.h" | 
|   16 #include "chrome/common/extensions/api/hid.h" |   17 #include "chrome/common/extensions/api/hid.h" | 
|   17  |   18  | 
|   18 namespace net { |   19 namespace net { | 
|   19  |   20  | 
|   20 class IOBuffer; |   21 class IOBufferWithSize; | 
|   21  |   22  | 
|   22 }  // namespace net |   23 }  // namespace net | 
|   23  |   24  | 
|   24 namespace extensions { |   25 namespace extensions { | 
|   25  |   26  | 
|   26 class HidAsyncApiFunction : public AsyncApiFunction { |   27 class HidAsyncApiFunction : public AsyncApiFunction { | 
|   27  public: |   28  public: | 
|   28   HidAsyncApiFunction(); |   29   HidAsyncApiFunction(); | 
|   29  |   30  | 
|   30   virtual bool PrePrepare() OVERRIDE; |   31   virtual bool PrePrepare() OVERRIDE; | 
|   31   virtual bool Respond() OVERRIDE; |   32   virtual bool Respond() OVERRIDE; | 
|   32  |   33  | 
|   33  protected: |   34  protected: | 
|   34   virtual ~HidAsyncApiFunction(); |   35   virtual ~HidAsyncApiFunction(); | 
|   35  |   36  | 
|   36   HidConnectionResource* GetHidConnectionResource(int api_resource_id); |   37   HidConnectionResource* GetHidConnectionResource(int api_resource_id); | 
|   37   void RemoveHidConnectionResource(int api_resource_id); |   38   void RemoveHidConnectionResource(int api_resource_id); | 
|   38  |   39  | 
|   39   void CompleteWithError(const std::string& error); |   40   void CompleteWithError(const std::string& error); | 
|   40  |   41  | 
|   41   ApiResourceManager<HidConnectionResource>* manager_; |   42   HidDeviceManager* device_manager_; | 
 |   43   ApiResourceManager<HidConnectionResource>* connection_manager_; | 
|   42  |   44  | 
|   43  private: |   45  private: | 
|   44   DISALLOW_COPY_AND_ASSIGN(HidAsyncApiFunction); |   46   DISALLOW_COPY_AND_ASSIGN(HidAsyncApiFunction); | 
|   45 }; |   47 }; | 
|   46  |   48  | 
|   47 class HidGetDevicesFunction : public HidAsyncApiFunction { |   49 class HidGetDevicesFunction : public HidAsyncApiFunction { | 
|   48  public: |   50  public: | 
|   49   DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); |   51   DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); | 
|   50  |   52  | 
|   51   HidGetDevicesFunction(); |   53   HidGetDevicesFunction(); | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  109  |  111  | 
|  110  protected: |  112  protected: | 
|  111   virtual bool Prepare() OVERRIDE; |  113   virtual bool Prepare() OVERRIDE; | 
|  112   virtual void AsyncWorkStart() OVERRIDE; |  114   virtual void AsyncWorkStart() OVERRIDE; | 
|  113  |  115  | 
|  114  private: |  116  private: | 
|  115   virtual ~HidReceiveFunction(); |  117   virtual ~HidReceiveFunction(); | 
|  116  |  118  | 
|  117   void OnFinished(bool success, size_t bytes); |  119   void OnFinished(bool success, size_t bytes); | 
|  118  |  120  | 
|  119   scoped_refptr<net::IOBuffer> buffer_; |  121   scoped_refptr<net::IOBufferWithSize> buffer_; | 
|  120   scoped_ptr<base::ListValue> result_; |  122   scoped_ptr<base::ListValue> result_; | 
|  121   scoped_ptr<extensions::api::hid::Receive::Params> parameters_; |  123   scoped_ptr<extensions::api::hid::Receive::Params> parameters_; | 
|  122  |  124  | 
|  123   DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); |  125   DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); | 
|  124 }; |  126 }; | 
|  125  |  127  | 
|  126 class HidSendFunction : public HidAsyncApiFunction { |  128 class HidSendFunction : public HidAsyncApiFunction { | 
|  127  public: |  129  public: | 
|  128   DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); |  130   DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); | 
|  129  |  131  | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|  153  |  155  | 
|  154  protected: |  156  protected: | 
|  155   virtual bool Prepare() OVERRIDE; |  157   virtual bool Prepare() OVERRIDE; | 
|  156   virtual void AsyncWorkStart() OVERRIDE; |  158   virtual void AsyncWorkStart() OVERRIDE; | 
|  157  |  159  | 
|  158  private: |  160  private: | 
|  159   virtual ~HidReceiveFeatureReportFunction(); |  161   virtual ~HidReceiveFeatureReportFunction(); | 
|  160  |  162  | 
|  161   void OnFinished(bool success, size_t bytes); |  163   void OnFinished(bool success, size_t bytes); | 
|  162  |  164  | 
|  163   scoped_refptr<net::IOBuffer> buffer_; |  165   scoped_refptr<net::IOBufferWithSize> buffer_; | 
|  164   scoped_ptr<base::ListValue> result_; |  166   scoped_ptr<base::ListValue> result_; | 
|  165   scoped_ptr<extensions::api::hid::ReceiveFeatureReport::Params> parameters_; |  167   scoped_ptr<extensions::api::hid::ReceiveFeatureReport::Params> parameters_; | 
|  166  |  168  | 
|  167   DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); |  169   DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); | 
|  168 }; |  170 }; | 
|  169  |  171  | 
|  170 class HidSendFeatureReportFunction : public HidAsyncApiFunction { |  172 class HidSendFeatureReportFunction : public HidAsyncApiFunction { | 
|  171  public: |  173  public: | 
|  172   DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); |  174   DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); | 
|  173  |  175  | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  184  |  186  | 
|  185   scoped_ptr<base::ListValue> result_; |  187   scoped_ptr<base::ListValue> result_; | 
|  186   scoped_ptr<extensions::api::hid::SendFeatureReport::Params> parameters_; |  188   scoped_ptr<extensions::api::hid::SendFeatureReport::Params> parameters_; | 
|  187  |  189  | 
|  188   DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); |  190   DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); | 
|  189 }; |  191 }; | 
|  190  |  192  | 
|  191 }  // namespace extensions |  193 }  // namespace extensions | 
|  192  |  194  | 
|  193 #endif  // CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ |  195 #endif  // CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ | 
| OLD | NEW |