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

Unified Diff: chrome/browser/extensions/api/messaging/native_message_process_host.cc

Issue 2384163003: Use FileDescriptorWatcher in NativeMessageProcessHost. (Closed)
Patch Set: fix test 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
Index: chrome/browser/extensions/api/messaging/native_message_process_host.cc
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
index 5921943b51692f941ab781796da37a7110ca8235..7d4304e31ee08ebf2dc8f1d67a29ea805f3bc506 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
@@ -199,17 +199,6 @@ NativeMessageProcessHost::task_runner() const {
return task_runner_;
}
-#if defined(OS_POSIX)
-void NativeMessageProcessHost::OnFileCanReadWithoutBlocking(int fd) {
- DCHECK_EQ(fd, read_file_);
- DoRead();
-}
-
-void NativeMessageProcessHost::OnFileCanWriteWithoutBlocking(int fd) {
- NOTREACHED();
-}
-#endif // !defined(OS_POSIX)
-
void NativeMessageProcessHost::ReadNowForTesting() {
DoRead();
}
@@ -225,9 +214,9 @@ void NativeMessageProcessHost::WaitRead() {
// would always be consuming one thread in the thread pool. On Windows
// FileStream uses overlapped IO, so that optimization isn't necessary there.
#if defined(OS_POSIX)
- base::MessageLoopForIO::current()->WatchFileDescriptor(
- read_file_, false /* persistent */,
- base::MessageLoopForIO::WATCH_READ, &read_watcher_, this);
+ read_controller_ = base::FileDescriptorWatcher::WatchReadable(
+ read_file_,
+ base::Bind(&NativeMessageProcessHost::DoRead, base::Unretained(this)));
#else // defined(OS_POSIX)
DoRead();
#endif // defined(!OS_POSIX)
@@ -236,6 +225,10 @@ void NativeMessageProcessHost::WaitRead() {
void NativeMessageProcessHost::DoRead() {
DCHECK(task_runner_->BelongsToCurrentThread());
+#if defined(OS_POSIX)
+ read_controller_.reset();
+#endif
+
while (!closed_ && !read_pending_) {
read_buffer_ = new net::IOBuffer(kReadBufferSize);
int result =

Powered by Google App Engine
This is Rietveld 408576698