Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: device/hid/hid_connection_win.h

Issue 2573683002: Fix leak of HID transfers and handles on Windows. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | device/hid/hid_connection_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 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 DEVICE_HID_HID_CONNECTION_WIN_H_ 5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_
6 #define DEVICE_HID_HID_CONNECTION_WIN_H_ 6 #define DEVICE_HID_HID_CONNECTION_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include <set> 12 #include <list>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/win/scoped_handle.h" 15 #include "base/win/scoped_handle.h"
16 #include "device/hid/hid_connection.h" 16 #include "device/hid/hid_connection.h"
17 17
18 namespace device { 18 namespace device {
19 19
20 struct PendingHidTransfer; 20 class PendingHidTransfer;
21 21
22 class HidConnectionWin : public HidConnection { 22 class HidConnectionWin : public HidConnection {
23 public: 23 public:
24 HidConnectionWin(scoped_refptr<HidDeviceInfo> device_info, 24 HidConnectionWin(scoped_refptr<HidDeviceInfo> device_info,
25 base::win::ScopedHandle file); 25 base::win::ScopedHandle file);
26 26
27 private: 27 private:
28 friend class HidServiceWin; 28 friend class HidServiceWin;
29 friend struct PendingHidTransfer; 29 friend class PendingHidTransfer;
30 30
31 ~HidConnectionWin() override; 31 ~HidConnectionWin() override;
32 32
33 // HidConnection implementation. 33 // HidConnection implementation.
34 void PlatformClose() override; 34 void PlatformClose() override;
35 void PlatformRead(const ReadCallback& callback) override; 35 void PlatformRead(const ReadCallback& callback) override;
36 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, 36 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
37 size_t size, 37 size_t size,
38 const WriteCallback& callback) override; 38 const WriteCallback& callback) override;
39 void PlatformGetFeatureReport(uint8_t report_id, 39 void PlatformGetFeatureReport(uint8_t report_id,
40 const ReadCallback& callback) override; 40 const ReadCallback& callback) override;
41 void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer, 41 void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer,
42 size_t size, 42 size_t size,
43 const WriteCallback& callback) override; 43 const WriteCallback& callback) override;
44 44
45 void OnReadComplete(scoped_refptr<net::IOBuffer> buffer, 45 void OnReadComplete(scoped_refptr<net::IOBuffer> buffer,
46 const ReadCallback& callback, 46 const ReadCallback& callback,
47 PendingHidTransfer* transfer, 47 PendingHidTransfer* transfer,
48 bool signaled); 48 bool signaled);
49 void OnReadFeatureComplete(scoped_refptr<net::IOBuffer> buffer, 49 void OnReadFeatureComplete(scoped_refptr<net::IOBuffer> buffer,
50 const ReadCallback& callback, 50 const ReadCallback& callback,
51 PendingHidTransfer* transfer, 51 PendingHidTransfer* transfer,
52 bool signaled); 52 bool signaled);
53 void OnWriteComplete(const WriteCallback& callback, 53 void OnWriteComplete(const WriteCallback& callback,
54 PendingHidTransfer* transfer, 54 PendingHidTransfer* transfer,
55 bool signaled); 55 bool signaled);
56 56
57 std::unique_ptr<PendingHidTransfer> UnlinkTransfer(
58 PendingHidTransfer* transfer);
59
57 base::win::ScopedHandle file_; 60 base::win::ScopedHandle file_;
58 61
59 std::set<scoped_refptr<PendingHidTransfer> > transfers_; 62 std::list<std::unique_ptr<PendingHidTransfer>> transfers_;
60 63
61 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); 64 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin);
62 }; 65 };
63 66
64 } // namespace device 67 } // namespace device
65 68
66 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_ 69 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | device/hid/hid_connection_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698