diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-28 21:49:30 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-28 21:49:30 +0000 |
commit | 92698ce853664cdd1dee6e7b4a7e6d382dfb8786 (patch) | |
tree | 7e81512de53a8d8a333e1a23743b83a5caa50996 /remoting/host/simple_host_process.cc | |
parent | 75f30cc2d6e90120b4ac43fcea1c38e783299f6e (diff) | |
download | chromium_src-92698ce853664cdd1dee6e7b4a7e6d382dfb8786.zip chromium_src-92698ce853664cdd1dee6e7b4a7e6d382dfb8786.tar.gz chromium_src-92698ce853664cdd1dee6e7b4a7e6d382dfb8786.tar.bz2 |
Fix thread usage in chromoting host
There are several things done in this patch:
1. Isloate thread start and stop to ChromotingHostContext
2. SessionManager now doesn't own capturer and encoder, ownership moved to ChromotingHost
3. Fix up the sequence of actions when ChromotingHost shuts down
TEST=remoting_unittests
BUG=none
Review URL: http://codereview.chromium.org/2829018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/simple_host_process.cc')
-rw-r--r-- | remoting/host/simple_host_process.cc | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index 0f12c43..8697b3d 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -27,6 +27,7 @@ #include "base/waitable_event.h" #include "remoting/host/capturer_fake.h" #include "remoting/host/chromoting_host.h" +#include "remoting/host/chromoting_host_context.h" #include "remoting/host/encoder_verbatim.h" #include "remoting/host/json_host_config.h" @@ -52,6 +53,10 @@ const char kHomePath[] = "HOME"; static char* GetEnvironmentVar(const char* x) { return getenv(x); } #endif +void ShutdownTask(MessageLoop* message_loop) { + message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); +} + const std::string kFakeSwitchName = "fake"; const std::string kConfigSwitchName = "config"; @@ -96,6 +101,7 @@ int main(int argc, char** argv) { if (fake) { // Inject a fake capturer. + LOG(INFO) << "Usage a fake capturer."; capturer.reset(new remoting::CapturerFake()); } @@ -111,16 +117,25 @@ int main(int argc, char** argv) { return 1; } - base::WaitableEvent host_done(false, false); + // Allocate a chromoting context and starts it. + remoting::ChromotingHostContext context; + context.Start(); + + // Construct a chromoting host. scoped_refptr<remoting::ChromotingHost> host = - new remoting::ChromotingHost(config, + new remoting::ChromotingHost(&context, + config, capturer.release(), encoder.release(), - executor.release(), - &host_done); - host->Run(); - host_done.Wait(); + executor.release()); + + // Let the chromoting host runs until the shutdown task is executed. + MessageLoop message_loop; + host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); + message_loop.Run(); + // And then stop the chromoting context. + context.Stop(); file_io_thread.Stop(); return 0; } |