Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / device / hid / hid_connection_win.h
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_
6 #define DEVICE_HID_HID_CONNECTION_WIN_H_
7
8 #include <windows.h>
9
10 #include <set>
11
12 #include "base/win/scoped_handle.h"
13 #include "device/hid/hid_connection.h"
14
15 namespace device {
16
17 struct PendingHidTransfer;
18
19 class HidConnectionWin : public HidConnection {
20  public:
21   explicit HidConnectionWin(const HidDeviceInfo& device_info);
22
23  private:
24   friend class HidServiceWin;
25   friend struct PendingHidTransfer;
26
27   ~HidConnectionWin();
28
29   // HidConnection implementation.
30   virtual void PlatformRead(const ReadCallback& callback) OVERRIDE;
31   virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
32                              size_t size,
33                              const WriteCallback& callback) OVERRIDE;
34   virtual void PlatformGetFeatureReport(uint8_t report_id,
35                                         const ReadCallback& callback) OVERRIDE;
36   virtual void PlatformSendFeatureReport(
37       scoped_refptr<net::IOBuffer> buffer,
38       size_t size,
39       const WriteCallback& callback) OVERRIDE;
40
41   bool available() const { return file_.IsValid(); }
42
43   void OnReadComplete(scoped_refptr<net::IOBuffer> buffer,
44                       const ReadCallback& callback,
45                       PendingHidTransfer* transfer,
46                       bool signaled);
47   void OnReadFeatureComplete(scoped_refptr<net::IOBuffer> buffer,
48                              const ReadCallback& callback,
49                              PendingHidTransfer* transfer,
50                              bool signaled);
51   void OnWriteComplete(const WriteCallback& callback,
52                        PendingHidTransfer* transfer,
53                        bool signaled);
54
55   base::win::ScopedHandle file_;
56
57   std::set<scoped_refptr<PendingHidTransfer> > transfers_;
58
59   DISALLOW_COPY_AND_ASSIGN(HidConnectionWin);
60 };
61
62 }  // namespace device
63
64 #endif  // DEVICE_HID_HID_CONNECTION_WIN_H_