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

Unified Diff: remoting/host/desktop_process_main.cc

Issue 11272036: Fixing threading issues in remoting::DesktopProcess. The UI thread is now owned by the caller of re… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 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 | « remoting/host/desktop_process.cc ('k') | remoting/host/desktop_process_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/desktop_process_main.cc
diff --git a/remoting/host/desktop_process_main.cc b/remoting/host/desktop_process_main.cc
index bdfb8af23de3379a659d56715cc941c311490a7a..c7b6a0df0750e172f049f928a6683a83528f0fda 100644
--- a/remoting/host/desktop_process_main.cc
+++ b/remoting/host/desktop_process_main.cc
@@ -6,12 +6,17 @@
// running within user sessions.
#include "base/at_exit.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/file_path.h"
+#include "base/message_loop.h"
+#include "base/run_loop.h"
#include "base/scoped_native_library.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "base/win/windows_version.h"
+#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/desktop_process.h"
#include "remoting/host/host_exit_codes.h"
#include "remoting/host/logging.h"
@@ -77,8 +82,25 @@ int main(int argc, char** argv) {
return remoting::kUsageExitCode;
}
- remoting::DesktopProcess desktop_process(channel_name);
- return desktop_process.Run();
+ MessageLoop message_loop(MessageLoop::TYPE_UI);
+ base::RunLoop run_loop;
+ base::Closure quit_ui_task_runner = base::Bind(
+ base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask),
+ message_loop.message_loop_proxy(),
+ FROM_HERE, run_loop.QuitClosure());
+ scoped_refptr<remoting::AutoThreadTaskRunner> ui_task_runner =
+ new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
+ quit_ui_task_runner);
+
+ remoting::DesktopProcess desktop_process(ui_task_runner, channel_name);
+ if (!desktop_process.Start())
+ return remoting::kInitializationFailed;
+
+ // Run the UI message loop.
+ ui_task_runner = NULL;
+ run_loop.Run();
+
+ return remoting::kSuccessExitCode;
}
#if defined(OS_WIN)
« no previous file with comments | « remoting/host/desktop_process.cc ('k') | remoting/host/desktop_process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698