| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This is an application of a minimal host process in a Chromoting | 5 // This is an application of a minimal host process in a Chromoting |
| 6 // system. It serves the purpose of gluing different pieces together | 6 // system. It serves the purpose of gluing different pieces together |
| 7 // to make a functional host process for testing. | 7 // to make a functional host process for testing. |
| 8 // | 8 // |
| 9 // It peforms the following functionality: | 9 // It peforms the following functionality: |
| 10 // 1. Connect to the GTalk network and register the machine as a host. | 10 // 1. Connect to the GTalk network and register the machine as a host. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 30 #include "media/base/media.h" | 30 #include "media/base/media.h" |
| 31 #include "remoting/base/tracer.h" | 31 #include "remoting/base/tracer.h" |
| 32 #include "remoting/host/capturer_fake.h" | 32 #include "remoting/host/capturer_fake.h" |
| 33 #include "remoting/host/chromoting_host.h" | 33 #include "remoting/host/chromoting_host.h" |
| 34 #include "remoting/host/chromoting_host_context.h" | 34 #include "remoting/host/chromoting_host_context.h" |
| 35 #include "remoting/host/event_executor.h" | 35 #include "remoting/host/event_executor.h" |
| 36 #include "remoting/host/json_host_config.h" | 36 #include "remoting/host/json_host_config.h" |
| 37 #include "remoting/proto/video.pb.h" | 37 #include "remoting/proto/video.pb.h" |
| 38 | 38 |
| 39 #if defined(TOOLKIT_USES_GTK) |
| 40 #include "ui/gfx/gtk_util.h" |
| 41 #endif |
| 42 |
| 39 using remoting::ChromotingHost; | 43 using remoting::ChromotingHost; |
| 40 using remoting::protocol::CandidateSessionConfig; | 44 using remoting::protocol::CandidateSessionConfig; |
| 41 using remoting::protocol::ChannelConfig; | 45 using remoting::protocol::ChannelConfig; |
| 42 using std::string; | 46 using std::string; |
| 43 using std::wstring; | 47 using std::wstring; |
| 44 | 48 |
| 45 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 46 const wchar_t kDefaultConfigPath[] = L".ChromotingConfig.json"; | 50 const wchar_t kDefaultConfigPath[] = L".ChromotingConfig.json"; |
| 47 const wchar_t kHomeDrive[] = L"HOMEDRIVE"; | 51 const wchar_t kHomeDrive[] = L"HOMEDRIVE"; |
| 48 const wchar_t kHomePath[] = L"HOMEPATH"; | 52 const wchar_t kHomePath[] = L"HOMEPATH"; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 // Needed for the Mac, so we don't leak objects when threads are created. | 75 // Needed for the Mac, so we don't leak objects when threads are created. |
| 72 base::mac::ScopedNSAutoreleasePool pool; | 76 base::mac::ScopedNSAutoreleasePool pool; |
| 73 | 77 |
| 74 CommandLine::Init(argc, argv); | 78 CommandLine::Init(argc, argv); |
| 75 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 79 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 76 | 80 |
| 77 base::AtExitManager exit_manager; | 81 base::AtExitManager exit_manager; |
| 78 base::EnsureNSPRInit(); | 82 base::EnsureNSPRInit(); |
| 79 | 83 |
| 80 // Allocate a chromoting context and starts it. | 84 // Allocate a chromoting context and starts it. |
| 81 remoting::ChromotingHostContext context; | 85 #if defined(TOOLKIT_USES_GTK) |
| 86 gfx::GtkInitFromCommandLine(*cmd_line); |
| 87 #endif |
| 88 MessageLoopForUI message_loop; |
| 89 remoting::ChromotingHostContext context(&message_loop); |
| 82 context.Start(); | 90 context.Start(); |
| 83 | 91 |
| 84 | 92 |
| 85 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 86 wstring home_path = GetEnvironmentVar(kHomeDrive); | 94 wstring home_path = GetEnvironmentVar(kHomeDrive); |
| 87 home_path += GetEnvironmentVar(kHomePath); | 95 home_path += GetEnvironmentVar(kHomePath); |
| 88 #else | 96 #else |
| 89 string home_path = GetEnvironmentVar(base::env_vars::kHome); | 97 string home_path = GetEnvironmentVar(base::env_vars::kHome); |
| 90 #endif | 98 #endif |
| 91 FilePath config_path(home_path); | 99 FilePath config_path(home_path); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 << "Cannot load media library"; | 121 << "Cannot load media library"; |
| 114 | 122 |
| 115 // Construct a chromoting host. | 123 // Construct a chromoting host. |
| 116 scoped_refptr<ChromotingHost> host; | 124 scoped_refptr<ChromotingHost> host; |
| 117 | 125 |
| 118 bool fake = cmd_line->HasSwitch(kFakeSwitchName); | 126 bool fake = cmd_line->HasSwitch(kFakeSwitchName); |
| 119 if (fake) { | 127 if (fake) { |
| 120 remoting::Capturer* capturer = | 128 remoting::Capturer* capturer = |
| 121 new remoting::CapturerFake(context.main_message_loop()); | 129 new remoting::CapturerFake(context.main_message_loop()); |
| 122 remoting::protocol::InputStub* input_stub = | 130 remoting::protocol::InputStub* input_stub = |
| 123 CreateEventExecutor(context.main_message_loop(), capturer); | 131 CreateEventExecutor(context.ui_message_loop(), capturer); |
| 124 host = ChromotingHost::Create( | 132 host = ChromotingHost::Create( |
| 125 &context, config, capturer, input_stub); | 133 &context, config, capturer, input_stub); |
| 126 } else { | 134 } else { |
| 127 host = ChromotingHost::Create(&context, config); | 135 host = ChromotingHost::Create(&context, config); |
| 128 } | 136 } |
| 129 | 137 |
| 130 if (cmd_line->HasSwitch(kVideoSwitchName)) { | 138 if (cmd_line->HasSwitch(kVideoSwitchName)) { |
| 131 string video_codec = cmd_line->GetSwitchValueASCII(kVideoSwitchName); | 139 string video_codec = cmd_line->GetSwitchValueASCII(kVideoSwitchName); |
| 132 scoped_ptr<CandidateSessionConfig> config( | 140 scoped_ptr<CandidateSessionConfig> config( |
| 133 CandidateSessionConfig::CreateDefault()); | 141 CandidateSessionConfig::CreateDefault()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 148 LOG(ERROR) << "Unknown video codec: " << video_codec; | 156 LOG(ERROR) << "Unknown video codec: " << video_codec; |
| 149 context.Stop(); | 157 context.Stop(); |
| 150 return 1; | 158 return 1; |
| 151 } | 159 } |
| 152 config->mutable_video_configs()->push_back(ChannelConfig( | 160 config->mutable_video_configs()->push_back(ChannelConfig( |
| 153 transport, remoting::protocol::kDefaultStreamVersion, codec)); | 161 transport, remoting::protocol::kDefaultStreamVersion, codec)); |
| 154 host->set_protocol_config(config.release()); | 162 host->set_protocol_config(config.release()); |
| 155 } | 163 } |
| 156 | 164 |
| 157 // Let the chromoting host run until the shutdown task is executed. | 165 // Let the chromoting host run until the shutdown task is executed. |
| 158 MessageLoop message_loop(MessageLoop::TYPE_UI); | |
| 159 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); | 166 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); |
| 160 message_loop.Run(); | 167 message_loop.MessageLoop::Run(); |
| 161 | 168 |
| 162 // And then stop the chromoting context. | 169 // And then stop the chromoting context. |
| 163 context.Stop(); | 170 context.Stop(); |
| 164 file_io_thread.Stop(); | 171 file_io_thread.Stop(); |
| 165 return 0; | 172 return 0; |
| 166 } | 173 } |
| OLD | NEW |