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

Unified Diff: base/threading/thread.cc

Issue 2372583002: Enable the FileDescriptorWatcher API on MessageLoopForIO threads. (Closed)
Patch Set: fix nacl build error Created 4 years, 3 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: base/threading/thread.cc
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index 761bc871885ede525866ca4a6c3e6226cb0e3005..88025e96aa93ad6c2d39beaedcdad604bdced698 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -17,6 +17,10 @@
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
+#if defined(OS_POSIX) && !defined(OS_NACL_SFI)
+#include "base/files/file_descriptor_watcher_posix.h"
+#endif
+
#if defined(OS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif
@@ -295,6 +299,15 @@ void Thread::ThreadMain() {
message_loop_->BindToCurrentThread();
message_loop_->SetTimerSlack(message_loop_timer_slack_);
+#if defined(OS_POSIX) && !defined(OS_NACL_SFI)
+ // Allow threads running a MessageLoopForIO to use FileDescriptorWatcher API.
+ std::unique_ptr<FileDescriptorWatcher> file_descriptor_watcher;
+ if (MessageLoopForIO::IsCurrent()) {
+ file_descriptor_watcher.reset(
+ new FileDescriptorWatcher(MessageLoopForIO::current()));
dcheng 2016/09/26 17:34:40 Is there a time when this wouldn't return the same
fdoray 2016/09/26 17:44:07 No. message_loop_->BindToCurrentThread() above se
+ }
+#endif
+
#if defined(OS_WIN)
std::unique_ptr<win::ScopedCOMInitializer> com_initializer;
if (com_status_ != NONE) {
« 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