| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 <set> | 
|  | 9 #include <windows.h> | 
|  | 10 | 
|  | 11 #include "base/callback.h" | 
|  | 12 #include "base/memory/ref_counted.h" | 
|  | 13 #include "base/message_loop/message_loop.h" | 
|  | 14 #include "base/threading/thread_checker.h" | 
|  | 15 #include "base/win/object_watcher.h" | 
|  | 16 #include "device/hid/hid_connection.h" | 
|  | 17 #include "device/hid/hid_device_info.h" | 
|  | 18 #include "net/base/io_buffer.h" | 
|  | 19 | 
|  | 20 namespace device { | 
|  | 21 | 
|  | 22 class HidConnectionWin : public HidConnection { | 
|  | 23  public: | 
|  | 24   struct PendingTransfer : public base::RefCounted<PendingTransfer>, | 
|  | 25                            public base::win::ObjectWatcher::Delegate, | 
|  | 26                            public base::MessageLoop::DestructionObserver { | 
|  | 27    public: | 
|  | 28     PendingTransfer(scoped_refptr<HidConnectionWin> conn, | 
|  | 29                     scoped_refptr<net::IOBuffer> target, | 
|  | 30                     scoped_refptr<net::IOBuffer> receiving, | 
|  | 31                     bool is_input, | 
|  | 32                     IOCallback callback); | 
|  | 33 | 
|  | 34     void TakeResultFromWindowsAPI(BOOL result); | 
|  | 35 | 
|  | 36     OVERLAPPED* GetOverlapped() { return &overlapped_; } | 
|  | 37 | 
|  | 38     // Implements base::win::ObjectWatcher::Delegate. | 
|  | 39     virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 
|  | 40 | 
|  | 41     // Implements base::MessageLoop::DestructionObserver | 
|  | 42     virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 
|  | 43 | 
|  | 44 | 
|  | 45    private: | 
|  | 46     friend class base::RefCounted<PendingTransfer>; | 
|  | 47     friend class HidConnectionWin; | 
|  | 48 | 
|  | 49     virtual ~PendingTransfer(); | 
|  | 50 | 
|  | 51     scoped_refptr<HidConnectionWin> conn_; | 
|  | 52     bool is_input_; | 
|  | 53     scoped_refptr<net::IOBuffer> target_; | 
|  | 54     scoped_refptr<net::IOBuffer> receiving_; | 
|  | 55     IOCallback callback_; | 
|  | 56     OVERLAPPED overlapped_; | 
|  | 57     base::win::ScopedHandle event_; | 
|  | 58     base::win::ObjectWatcher watcher_; | 
|  | 59 | 
|  | 60     DISALLOW_COPY_AND_ASSIGN(PendingTransfer); | 
|  | 61   }; | 
|  | 62 | 
|  | 63   HidConnectionWin(HidDeviceInfo device_info); | 
|  | 64 | 
|  | 65   virtual void Read(scoped_refptr<net::IOBuffer> buffer, | 
|  | 66                     size_t size, | 
|  | 67                     const IOCallback& callback) OVERRIDE; | 
|  | 68   virtual void Write(scoped_refptr<net::IOBuffer> buffer, | 
|  | 69                      size_t size, | 
|  | 70                      const IOCallback& callback) OVERRIDE; | 
|  | 71   virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, | 
|  | 72                                 size_t size, | 
|  | 73                                 const IOCallback& callback) OVERRIDE; | 
|  | 74   virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, | 
|  | 75                                  size_t size, | 
|  | 76                                  const IOCallback& callback) OVERRIDE; | 
|  | 77 | 
|  | 78   void OnTransferFinished(scoped_refptr<PendingTransfer> transfer); | 
|  | 79   void OnTransferCanceled(scoped_refptr<PendingTransfer> transfer); | 
|  | 80 | 
|  | 81   bool available() const { return available_; } | 
|  | 82 | 
|  | 83  private: | 
|  | 84   ~HidConnectionWin(); | 
|  | 85 | 
|  | 86   base::win::ScopedHandle file_; | 
|  | 87   std::set<scoped_refptr<PendingTransfer> > transfers_; | 
|  | 88 | 
|  | 89   DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); | 
|  | 90 | 
|  | 91   bool available_; | 
|  | 92 }; | 
|  | 93 | 
|  | 94 }  // namespace device | 
|  | 95 | 
|  | 96 #endif  // DEVICE_HID_HID_CONNECTION_WIN_H_ | 
| OLD | NEW | 
|---|