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

Unified Diff: chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc

Issue 2388913002: Use FileDescriptorWatcher in BrlapiConnectionImpl. (Closed)
Patch Set: fix build error Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
diff --git a/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc b/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
index 5739710383dceb519f03c0051fd71f11a875efd0..10dd503680c12a4222d94654bb78b948d292018d 100644
--- a/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
+++ b/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
@@ -6,14 +6,13 @@
#include <errno.h>
+#include "base/files/file_descriptor_watcher_posix.h"
#include "base/macros.h"
#include "base/memory/free_deleter.h"
-#include "base/message_loop/message_loop.h"
#include "base/sys_info.h"
#include "build/build_config.h"
namespace extensions {
-using base::MessageLoopForIO;
namespace api {
namespace braille_display_private {
@@ -30,8 +29,7 @@ static const int kDefaultTtyChromeOS = 1;
#endif
} // namespace
-class BrlapiConnectionImpl : public BrlapiConnection,
- MessageLoopForIO::Watcher {
+class BrlapiConnectionImpl : public BrlapiConnection {
public:
explicit BrlapiConnectionImpl(LibBrlapiLoader* loader) :
libbrlapi_loader_(loader) {}
@@ -47,19 +45,13 @@ class BrlapiConnectionImpl : public BrlapiConnection,
bool WriteDots(const unsigned char* cells) override;
int ReadKey(brlapi_keyCode_t* keyCode) override;
- // MessageLoopForIO::Watcher
- void OnFileCanReadWithoutBlocking(int fd) override { on_data_ready_.Run(); }
-
- void OnFileCanWriteWithoutBlocking(int fd) override {}
-
private:
bool CheckConnected();
ConnectResult ConnectResultForError();
LibBrlapiLoader* libbrlapi_loader_;
std::unique_ptr<brlapi_handle_t, base::FreeDeleter> handle_;
- MessageLoopForIO::FileDescriptorWatcher fd_controller_;
- OnDataReadyCallback on_data_ready_;
+ std::unique_ptr<base::FileDescriptorWatcher::Controller> fd_controller_;
DISALLOW_COPY_AND_ASSIGN(BrlapiConnectionImpl);
};
@@ -132,14 +124,8 @@ BrlapiConnection::ConnectResult BrlapiConnectionImpl::Connect(
return CONNECT_ERROR_RETRY;
}
- if (!MessageLoopForIO::current()->WatchFileDescriptor(
- fd, true, MessageLoopForIO::WATCH_READ, &fd_controller_, this)) {
- LOG(ERROR) << "Couldn't watch file descriptor " << fd;
- Disconnect();
- return CONNECT_ERROR_RETRY;
- }
-
- on_data_ready_ = on_data_ready;
+ fd_controller_ =
+ base::FileDescriptorWatcher::WatchReadable(fd, on_data_ready);
return CONNECT_SUCCESS;
}
@@ -148,7 +134,7 @@ void BrlapiConnectionImpl::Disconnect() {
if (!handle_) {
return;
}
- fd_controller_.StopWatchingFileDescriptor();
+ fd_controller_.reset();
libbrlapi_loader_->brlapi__closeConnection(
handle_.get());
handle_.reset();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698