Run event executor on the ui thread to remove the need to explicitly XFlush() the XTest calls.

BUG=none
TEST=Connect to a host and try moving the mouse and typing. Both inputs should be reflected correctly.

Review URL: http://codereview.chromium.org/6489031
Patch from Jamie Walch <[email protected]>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75477 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 289da0f..59034892 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -36,6 +36,10 @@
 #include "remoting/host/json_host_config.h"
 #include "remoting/proto/video.pb.h"
 
+#if defined(TOOLKIT_USES_GTK)
+#include "ui/gfx/gtk_util.h"
+#endif
+
 using remoting::ChromotingHost;
 using remoting::protocol::CandidateSessionConfig;
 using remoting::protocol::ChannelConfig;
@@ -78,7 +82,11 @@
   base::EnsureNSPRInit();
 
   // Allocate a chromoting context and starts it.
-  remoting::ChromotingHostContext context;
+#if defined(TOOLKIT_USES_GTK)
+  gfx::GtkInitFromCommandLine(*cmd_line);
+#endif
+  MessageLoopForUI message_loop;
+  remoting::ChromotingHostContext context(&message_loop);
   context.Start();
 
 
@@ -120,7 +128,7 @@
     remoting::Capturer* capturer =
         new remoting::CapturerFake(context.main_message_loop());
     remoting::protocol::InputStub* input_stub =
-        CreateEventExecutor(context.main_message_loop(), capturer);
+        CreateEventExecutor(context.ui_message_loop(), capturer);
     host = ChromotingHost::Create(
         &context, config, capturer, input_stub);
   } else {
@@ -155,9 +163,8 @@
   }
 
   // Let the chromoting host run until the shutdown task is executed.
-  MessageLoop message_loop(MessageLoop::TYPE_UI);
   host->Start(NewRunnableFunction(&ShutdownTask, &message_loop));
-  message_loop.Run();
+  message_loop.MessageLoop::Run();
 
   // And then stop the chromoting context.
   context.Stop();