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

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

Issue 2799743006: Remove MessageLoop destruction observer from hid_connection_linux.cc (Closed)
Patch Set: Created 3 years, 8 months 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_linux.cc » ('j') | device/hid/hid_connection_linux.cc » ('J')
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_LINUX_H_ 5 #ifndef DEVICE_HID_HID_CONNECTION_LINUX_H_
6 #define DEVICE_HID_HID_CONNECTION_LINUX_H_ 6 #define DEVICE_HID_HID_CONNECTION_LINUX_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/files/file.h" 13 #include "base/files/scoped_file.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "device/hid/hid_connection.h" 16 #include "device/hid/hid_connection.h"
17 17
18 namespace base { 18 namespace base {
19 class SequencedTaskRunner;
19 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
20 } 21 }
21 22
22 namespace device { 23 namespace device {
23 24
24 class HidConnectionLinux : public HidConnection { 25 class HidConnectionLinux : public HidConnection {
25 public: 26 public:
26 HidConnectionLinux( 27 HidConnectionLinux(
27 scoped_refptr<HidDeviceInfo> device_info, 28 scoped_refptr<HidDeviceInfo> device_info,
28 base::File device_file, 29 base::ScopedFD fd,
29 scoped_refptr<base::SingleThreadTaskRunner> file_thread_runner); 30 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
30 31
31 private: 32 private:
32 friend class base::RefCountedThreadSafe<HidConnectionLinux>; 33 friend class base::RefCountedThreadSafe<HidConnectionLinux>;
33 class FileThreadHelper; 34 class FileThreadHelper;
34 35
35 typedef base::Callback<void(ssize_t)> InternalWriteCallback;
36 typedef base::Callback<void(int)> IoctlCallback;
37
38 ~HidConnectionLinux() override; 36 ~HidConnectionLinux() override;
39 37
40 // HidConnection implementation. 38 // HidConnection implementation.
41 void PlatformClose() override; 39 void PlatformClose() override;
42 void PlatformRead(const ReadCallback& callback) override; 40 void PlatformRead(const ReadCallback& callback) override;
43 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, 41 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
44 size_t size, 42 size_t size,
45 const WriteCallback& callback) override; 43 const WriteCallback& callback) override;
46 void PlatformGetFeatureReport(uint8_t report_id, 44 void PlatformGetFeatureReport(uint8_t report_id,
47 const ReadCallback& callback) override; 45 const ReadCallback& callback) override;
48 void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer, 46 void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer,
49 size_t size, 47 size_t size,
50 const WriteCallback& callback) override; 48 const WriteCallback& callback) override;
51 49
52 // Callbacks for blocking operations run on the FILE thread.
53 void FinishWrite(size_t expected_size,
54 const WriteCallback& callback,
55 ssize_t result);
56 void FinishGetFeatureReport(uint8_t report_id,
57 scoped_refptr<net::IOBuffer> buffer,
58 const ReadCallback& callback,
59 int result);
60 void FinishSendFeatureReport(const WriteCallback& callback, int result);
61
62 // Writes to the device. This operation may block.
63 static void BlockingWrite(
64 base::PlatformFile platform_file,
65 scoped_refptr<net::IOBuffer> buffer,
66 size_t size,
67 const InternalWriteCallback& callback,
68 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
69 // Performs an ioctl on the device. This operation may block.
70 static void BlockingIoctl(
71 base::PlatformFile platform_file,
72 int request,
73 scoped_refptr<net::IOBuffer> buffer,
74 const IoctlCallback& callback,
75 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
76
77 // Closes the device file descriptor. Must be called on the FILE thread.
78 static void CloseDevice(base::File device_file);
79
80 void ProcessInputReport(scoped_refptr<net::IOBuffer> buffer, size_t size); 50 void ProcessInputReport(scoped_refptr<net::IOBuffer> buffer, size_t size);
81 void ProcessReadQueue(); 51 void ProcessReadQueue();
82 52
83 base::File device_file_; 53 int fd_; // Copy of the file descriptor owned by |helper_|.
fdoray 2017/04/07 20:26:23 |fd_| isn't used.
Reilly Grant (use Gerrit) 2017/04/07 22:10:48 Done.
84 FileThreadHelper* helper_; 54 std::unique_ptr<FileThreadHelper> helper_;
85 55
86 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
fdoray 2017/04/07 20:26:23 const scoped_refptr
Reilly Grant (use Gerrit) 2017/04/07 22:10:48 Done.
87 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 57 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
fdoray 2017/04/07 20:26:23 const scoped_refptr
Reilly Grant (use Gerrit) 2017/04/07 22:10:49 Done.
88 58
89 std::queue<PendingHidReport> pending_reports_; 59 std::queue<PendingHidReport> pending_reports_;
90 std::queue<PendingHidRead> pending_reads_; 60 std::queue<PendingHidRead> pending_reads_;
91 61
62 base::ThreadChecker thread_checker_;
fdoray 2017/04/07 20:26:23 missing include
Reilly Grant (use Gerrit) 2017/04/07 22:10:48 Done.
63
92 base::WeakPtrFactory<HidConnectionLinux> weak_factory_; 64 base::WeakPtrFactory<HidConnectionLinux> weak_factory_;
93 65
94 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux); 66 DISALLOW_COPY_AND_ASSIGN(HidConnectionLinux);
95 }; 67 };
96 68
97 } // namespace device 69 } // namespace device
98 70
99 #endif // DEVICE_HID_HID_CONNECTION_LINUX_H_ 71 #endif // DEVICE_HID_HID_CONNECTION_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | device/hid/hid_connection_linux.cc » ('j') | device/hid/hid_connection_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698