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

Unified Diff: remoting/base/auto_thread.cc

Issue 2378663006: Enable the FileDescriptorWatcher API on TYPE_IO AutoThreads. (Closed)
Patch Set: fix 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: remoting/base/auto_thread.cc
diff --git a/remoting/base/auto_thread.cc b/remoting/base/auto_thread.cc
index b9b8f3006dfae5d075553bda444b80573d92caab..0e56ab5437006edf8b1d85df378e034380515ffc 100644
--- a/remoting/base/auto_thread.cc
+++ b/remoting/base/auto_thread.cc
@@ -4,6 +4,8 @@
#include "remoting/base/auto_thread.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/lazy_instance.h"
@@ -16,6 +18,10 @@
#include "build/build_config.h"
#include "remoting/base/auto_thread_task_runner.h"
+#if defined(OS_POSIX) && !defined(OS_NACL)
+#include "base/files/file_descriptor_watcher_posix.h"
+#endif
+
#if defined(OS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif
@@ -202,6 +208,16 @@ void AutoThread::ThreadMain() {
// startup_data_ can't be touched anymore since the starting thread is now
// unlocked.
+#if defined(OS_POSIX) && !defined(OS_NACL)
+ // Allow threads running a MessageLoopForIO to use FileDescriptorWatcher.
+ std::unique_ptr<base::FileDescriptorWatcher> file_descriptor_watcher;
+ if (startup_data_->loop_type == base::MessageLoop::TYPE_IO) {
Wez 2016/10/04 00:58:06 You shouldn't access startup_data_ here, since you
+ DCHECK_EQ(&message_loop, base::MessageLoopForIO::current());
+ file_descriptor_watcher.reset(
+ new base::FileDescriptorWatcher(base::MessageLoopForIO::current()));
+ }
+#endif
+
#if defined(OS_WIN)
// Initialize COM on the thread, if requested.
std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer(
« 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