Commit fc94b640 authored by fdoray's avatar fdoray Committed by Commit bot

Enable the FileDescriptorWatcher API on MessageLoopForIO threads.

With this CL, a FileDescriptorWatcher is instantiated on every
base::Thread that runs a MessageLoopForIO. This allows
FileDescriptorWatcher::WatchReadable/WatchWritable to be used
on these threads.

BUG=645114

Review-Url: https://codereview.chromium.org/2372583002
Cr-Commit-Position: refs/heads/master@{#421190}
parent d40525dc
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_POSIX) && !defined(OS_NACL)
#include "base/files/file_descriptor_watcher_posix.h"
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_com_initializer.h"
#endif #endif
...@@ -295,6 +299,16 @@ void Thread::ThreadMain() { ...@@ -295,6 +299,16 @@ void Thread::ThreadMain() {
message_loop_->BindToCurrentThread(); message_loop_->BindToCurrentThread();
message_loop_->SetTimerSlack(message_loop_timer_slack_); message_loop_->SetTimerSlack(message_loop_timer_slack_);
#if defined(OS_POSIX) && !defined(OS_NACL)
// Allow threads running a MessageLoopForIO to use FileDescriptorWatcher API.
std::unique_ptr<FileDescriptorWatcher> file_descriptor_watcher;
if (MessageLoopForIO::IsCurrent()) {
DCHECK_EQ(message_loop_, MessageLoopForIO::current());
file_descriptor_watcher.reset(
new FileDescriptorWatcher(MessageLoopForIO::current()));
}
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
std::unique_ptr<win::ScopedCOMInitializer> com_initializer; std::unique_ptr<win::ScopedCOMInitializer> com_initializer;
if (com_status_ != NONE) { if (com_status_ != NONE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment