diff options
Diffstat (limited to 'device')
-rw-r--r-- | device/hid/hid_connection_linux.cc | 23 | ||||
-rw-r--r-- | device/hid/hid_connection_linux.h | 5 | ||||
-rw-r--r-- | device/hid/hid_service_linux.cc | 17 | ||||
-rw-r--r-- | device/hid/hid_service_linux.h | 5 |
4 files changed, 27 insertions, 23 deletions
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc index e9ca4b2..c653f4b 100644 --- a/device/hid/hid_connection_linux.cc +++ b/device/hid/hid_connection_linux.cc @@ -29,12 +29,13 @@ namespace device { -class HidConnectionLinux::Helper : public base::MessagePumpLibevent::Watcher { +class HidConnectionLinux::FileThreadHelper + : public base::MessagePumpLibevent::Watcher { public: - Helper(base::PlatformFile platform_file, - scoped_refptr<HidDeviceInfo> device_info, - base::WeakPtr<HidConnectionLinux> connection, - scoped_refptr<base::SingleThreadTaskRunner> task_runner) + FileThreadHelper(base::PlatformFile platform_file, + scoped_refptr<HidDeviceInfo> device_info, + base::WeakPtr<HidConnectionLinux> connection, + scoped_refptr<base::SingleThreadTaskRunner> task_runner) : platform_file_(platform_file), connection_(connection), task_runner_(task_runner) { @@ -43,7 +44,9 @@ class HidConnectionLinux::Helper : public base::MessagePumpLibevent::Watcher { has_report_id_ = device_info->has_report_id(); } - ~Helper() override { DCHECK(thread_checker_.CalledOnValidThread()); } + ~FileThreadHelper() override { + DCHECK(thread_checker_.CalledOnValidThread()); + } // Starts the FileDescriptorWatcher that reads input events from the device. // Must be called on a thread that has a base::MessageLoopForIO. The helper @@ -122,10 +125,10 @@ HidConnectionLinux::HidConnectionLinux( // The helper is passed a weak pointer to this connection so that it can be // cleaned up after the connection is closed. - helper_ = new Helper(device_file_.GetPlatformFile(), device_info, - weak_factory_.GetWeakPtr(), task_runner_); - file_task_runner_->PostTask( - FROM_HERE, base::Bind(&Helper::Start, base::Unretained(helper_))); + helper_ = new FileThreadHelper(device_file_.GetPlatformFile(), device_info, + weak_factory_.GetWeakPtr(), task_runner_); + file_task_runner_->PostTask(FROM_HERE, base::Bind(&FileThreadHelper::Start, + base::Unretained(helper_))); } HidConnectionLinux::~HidConnectionLinux() { diff --git a/device/hid/hid_connection_linux.h b/device/hid/hid_connection_linux.h index c8ffc85..1f32420 100644 --- a/device/hid/hid_connection_linux.h +++ b/device/hid/hid_connection_linux.h @@ -25,9 +25,8 @@ class HidConnectionLinux : public HidConnection { scoped_refptr<base::SingleThreadTaskRunner> file_thread_runner); private: - class Helper; - friend class Helper; friend class base::RefCountedThreadSafe<HidConnectionLinux>; + class FileThreadHelper; typedef base::Callback<void(ssize_t)> InternalWriteCallback; typedef base::Callback<void(int)> IoctlCallback; @@ -78,7 +77,7 @@ class HidConnectionLinux : public HidConnection { void ProcessReadQueue(); base::File device_file_; - Helper* helper_; + FileThreadHelper* helper_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; diff --git a/device/hid/hid_service_linux.cc b/device/hid/hid_service_linux.cc index 556f3bb..052a5a2 100644 --- a/device/hid/hid_service_linux.cc +++ b/device/hid/hid_service_linux.cc @@ -60,22 +60,25 @@ struct HidServiceLinux::ConnectParams { base::File device_file; }; -class HidServiceLinux::Helper : public DeviceMonitorLinux::Observer, - public base::MessageLoop::DestructionObserver { +class HidServiceLinux::FileThreadHelper + : public DeviceMonitorLinux::Observer, + public base::MessageLoop::DestructionObserver { public: - Helper(base::WeakPtr<HidServiceLinux> service, - scoped_refptr<base::SingleThreadTaskRunner> task_runner) + FileThreadHelper(base::WeakPtr<HidServiceLinux> service, + scoped_refptr<base::SingleThreadTaskRunner> task_runner) : observer_(this), service_(service), task_runner_(task_runner) { DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance(); observer_.Add(monitor); monitor->Enumerate( - base::Bind(&Helper::OnDeviceAdded, base::Unretained(this))); + base::Bind(&FileThreadHelper::OnDeviceAdded, base::Unretained(this))); task_runner->PostTask( FROM_HERE, base::Bind(&HidServiceLinux::FirstEnumerationComplete, service_)); } - ~Helper() override { DCHECK(thread_checker_.CalledOnValidThread()); } + ~FileThreadHelper() override { + DCHECK(thread_checker_.CalledOnValidThread()); + } private: // DeviceMonitorLinux::Observer: @@ -202,7 +205,7 @@ void HidServiceLinux::StartHelper( scoped_refptr<base::SingleThreadTaskRunner> task_runner) { // Helper is a message loop destruction observer and will delete itself when // this thread's message loop is destroyed. - new Helper(weak_ptr, task_runner); + new FileThreadHelper(weak_ptr, task_runner); } void HidServiceLinux::Connect(const HidDeviceId& device_id, diff --git a/device/hid/hid_service_linux.h b/device/hid/hid_service_linux.h index fd833b6..3cb75c5 100644 --- a/device/hid/hid_service_linux.h +++ b/device/hid/hid_service_linux.h @@ -24,8 +24,7 @@ class HidServiceLinux : public HidService { private: struct ConnectParams; - class Helper; - friend class Helper; + class FileThreadHelper; ~HidServiceLinux() override; @@ -50,7 +49,7 @@ class HidServiceLinux : public HidService { // The helper lives on the FILE thread and holds a weak reference back to the // service that owns it. - scoped_ptr<Helper> helper_; + scoped_ptr<FileThreadHelper> helper_; base::WeakPtrFactory<HidServiceLinux> weak_factory_; DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); |