| Index: device/hid/hid_connection_linux.cc
|
| diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc
|
| index 54a3624d7a396c20cc290ab3a604b34d662dd2f0..5172b0b39ea6a366c22af751e3d48ebf5b933734 100644
|
| --- a/device/hid/hid_connection_linux.cc
|
| +++ b/device/hid/hid_connection_linux.cc
|
| @@ -13,10 +13,10 @@
|
| #include <utility>
|
|
|
| #include "base/bind.h"
|
| +#include "base/files/file_descriptor_watcher_posix.h"
|
| #include "base/files/file_path.h"
|
| #include "base/macros.h"
|
| #include "base/message_loop/message_loop.h"
|
| -#include "base/message_loop/message_pump_libevent.h"
|
| #include "base/posix/eintr_wrapper.h"
|
| #include "base/threading/thread_restrictions.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -34,8 +34,7 @@
|
| namespace device {
|
|
|
| class HidConnectionLinux::FileThreadHelper
|
| - : public base::MessagePumpLibevent::Watcher,
|
| - public base::MessageLoop::DestructionObserver {
|
| + : public base::MessageLoop::DestructionObserver {
|
| public:
|
| FileThreadHelper(base::PlatformFile platform_file,
|
| scoped_refptr<HidDeviceInfo> device_info,
|
| @@ -60,21 +59,18 @@ class HidConnectionLinux::FileThreadHelper
|
| base::ThreadRestrictions::AssertIOAllowed();
|
| self->thread_checker_.DetachFromThread();
|
|
|
| - if (!base::MessageLoopForIO::current()->WatchFileDescriptor(
|
| - self->platform_file_, true, base::MessageLoopForIO::WATCH_READ,
|
| - &self->file_watcher_, self.get())) {
|
| - HID_LOG(ERROR) << "Failed to start watching device file.";
|
| - }
|
| + self->file_watcher_ = base::FileDescriptorWatcher::WatchReadable(
|
| + self->platform_file_,
|
| + base::Bind(&FileThreadHelper::OnFileCanReadWithoutBlocking,
|
| + base::Unretained(self.get())));
|
|
|
| // |self| is now owned by the current message loop.
|
| base::MessageLoop::current()->AddDestructionObserver(self.release());
|
| }
|
|
|
| private:
|
| - // base::MessagePumpLibevent::Watcher implementation.
|
| - void OnFileCanReadWithoutBlocking(int fd) override {
|
| + void OnFileCanReadWithoutBlocking() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - DCHECK_EQ(fd, platform_file_);
|
|
|
| scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(report_buffer_size_));
|
| char* data = buffer->data();
|
| @@ -95,7 +91,7 @@ class HidConnectionLinux::FileThreadHelper
|
| // TODO(reillyg): Investigate starting and stopping the file descriptor
|
| // watcher in response to pending read requests so that per-request
|
| // errors can be returned to the client.
|
| - file_watcher_.StopWatchingFileDescriptor();
|
| + file_watcher_.reset();
|
| }
|
| return;
|
| }
|
| @@ -109,10 +105,6 @@ class HidConnectionLinux::FileThreadHelper
|
| connection_, buffer, bytes_read));
|
| }
|
|
|
| - void OnFileCanWriteWithoutBlocking(int fd) override {
|
| - NOTREACHED(); // Only listening for reads.
|
| - }
|
| -
|
| // base::MessageLoop::DestructionObserver:
|
| void WillDestroyCurrentMessageLoop() override {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| @@ -125,7 +117,7 @@ class HidConnectionLinux::FileThreadHelper
|
| bool has_report_id_;
|
| base::WeakPtr<HidConnectionLinux> connection_;
|
| scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| - base::MessagePumpLibevent::FileDescriptorWatcher file_watcher_;
|
| + std::unique_ptr<base::FileDescriptorWatcher::Controller> file_watcher_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(FileThreadHelper);
|
| };
|
|
|