OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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. |
11 // 2. Accepts connection through libjingle. | 11 // 2. Accepts connection through libjingle. |
12 // 3. Receive mouse / keyboard events through libjingle. | 12 // 3. Receive mouse / keyboard events through libjingle. |
13 // 4. Sends screen capture through libjingle. | 13 // 4. Sends screen capture through libjingle. |
14 | 14 |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 | 16 |
17 #include <iostream> | 17 #include <iostream> |
18 #include <string> | 18 #include <string> |
19 | 19 |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 | 21 |
22 #include "base/at_exit.h" | 22 #include "base/at_exit.h" |
23 #include "base/bind.h" | 23 #include "base/bind.h" |
24 #include "base/callback.h" | 24 #include "base/callback.h" |
25 #include "base/command_line.h" | 25 #include "base/command_line.h" |
26 #include "base/environment.h" | 26 #include "base/environment.h" |
27 #include "base/file_path.h" | 27 #include "base/file_path.h" |
28 #include "base/logging.h" | 28 #include "base/logging.h" |
29 #include "base/mac/scoped_nsautorelease_pool.h" | |
30 #include "base/message_loop.h" | 29 #include "base/message_loop.h" |
31 #include "base/path_service.h" | 30 #include "base/path_service.h" |
32 #include "base/test/mock_chrome_application_mac.h" | 31 #include "base/test/mock_chrome_application_mac.h" |
33 #include "base/threading/thread.h" | 32 #include "base/threading/thread.h" |
34 #include "crypto/nss_util.h" | 33 #include "crypto/nss_util.h" |
35 #include "remoting/base/constants.h" | 34 #include "remoting/base/constants.h" |
36 #include "remoting/host/capturer_fake.h" | 35 #include "remoting/host/capturer_fake.h" |
37 #include "remoting/host/chromoting_host.h" | 36 #include "remoting/host/chromoting_host.h" |
38 #include "remoting/host/chromoting_host_context.h" | 37 #include "remoting/host/chromoting_host_context.h" |
39 #include "remoting/host/continue_window.h" | 38 #include "remoting/host/continue_window.h" |
40 #include "remoting/host/curtain.h" | 39 #include "remoting/host/curtain.h" |
41 #include "remoting/host/desktop_environment.h" | 40 #include "remoting/host/desktop_environment.h" |
42 #include "remoting/host/disconnect_window.h" | 41 #include "remoting/host/disconnect_window.h" |
43 #include "remoting/host/event_executor.h" | 42 #include "remoting/host/event_executor.h" |
44 #include "remoting/host/heartbeat_sender.h" | 43 #include "remoting/host/heartbeat_sender.h" |
45 #include "remoting/host/local_input_monitor.h" | 44 #include "remoting/host/local_input_monitor.h" |
46 #include "remoting/host/json_host_config.h" | 45 #include "remoting/host/json_host_config.h" |
47 #include "remoting/host/register_support_host_request.h" | 46 #include "remoting/host/register_support_host_request.h" |
48 #include "remoting/host/self_access_verifier.h" | 47 #include "remoting/host/self_access_verifier.h" |
49 #include "remoting/host/support_access_verifier.h" | 48 #include "remoting/host/support_access_verifier.h" |
50 #include "remoting/proto/video.pb.h" | 49 #include "remoting/proto/video.pb.h" |
51 | 50 |
52 #if defined(TOOLKIT_USES_GTK) | 51 #if defined(TOOLKIT_USES_GTK) |
53 #include "ui/gfx/gtk_util.h" | 52 #include "ui/gfx/gtk_util.h" |
54 #endif | 53 #elif defined(OS_MACOSX) |
55 | 54 #include "base/mac/scoped_nsautorelease_pool.h" |
56 #if defined(OS_WIN) | 55 #elif defined(OS_WIN) |
57 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we | 56 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we |
58 // have an hModule for the dialog resource. | 57 // have an hModule for the dialog resource. |
59 HMODULE g_hModule = NULL; | 58 HMODULE g_hModule = NULL; |
60 #endif | 59 #endif |
61 | 60 |
62 using remoting::ChromotingHost; | 61 using remoting::ChromotingHost; |
63 using remoting::DesktopEnvironment; | 62 using remoting::DesktopEnvironment; |
64 using remoting::kChromotingTokenDefaultServiceName; | 63 using remoting::kChromotingTokenDefaultServiceName; |
65 using remoting::kXmppAuthServiceConfigPath; | 64 using remoting::kXmppAuthServiceConfigPath; |
66 using remoting::protocol::CandidateSessionConfig; | 65 using remoting::protocol::CandidateSessionConfig; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 253 |
255 FilePath config_path_; | 254 FilePath config_path_; |
256 bool fake_; | 255 bool fake_; |
257 bool is_it2me_; | 256 bool is_it2me_; |
258 scoped_ptr<CandidateSessionConfig> protocol_config_; | 257 scoped_ptr<CandidateSessionConfig> protocol_config_; |
259 | 258 |
260 scoped_refptr<ChromotingHost> host_; | 259 scoped_refptr<ChromotingHost> host_; |
261 }; | 260 }; |
262 | 261 |
263 int main(int argc, char** argv) { | 262 int main(int argc, char** argv) { |
264 // Needed for the Mac, so we don't leak objects when threads are created. | 263 #if defined(OS_MACOSX) |
| 264 // Needed so we don't leak objects when threads are created. |
265 base::mac::ScopedNSAutoreleasePool pool; | 265 base::mac::ScopedNSAutoreleasePool pool; |
| 266 mock_cr_app::RegisterMockCrApp(); |
| 267 #endif |
266 | 268 |
267 CommandLine::Init(argc, argv); | 269 CommandLine::Init(argc, argv); |
268 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 270 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
269 | 271 |
270 base::AtExitManager exit_manager; | 272 base::AtExitManager exit_manager; |
271 crypto::EnsureNSPRInit(); | 273 crypto::EnsureNSPRInit(); |
272 | 274 |
273 #if defined(TOOLKIT_USES_GTK) | 275 #if defined(TOOLKIT_USES_GTK) |
274 gfx::GtkInitFromCommandLine(*cmd_line); | 276 gfx::GtkInitFromCommandLine(*cmd_line); |
275 #endif // TOOLKIT_USES_GTK | 277 #endif // TOOLKIT_USES_GTK |
276 | 278 |
277 #if defined(OS_MACOSX) | |
278 mock_cr_app::RegisterMockCrApp(); | |
279 #endif // OS_MACOSX | |
280 | |
281 SimpleHost simple_host; | 279 SimpleHost simple_host; |
282 | 280 |
283 if (cmd_line->HasSwitch(kConfigSwitchName)) { | 281 if (cmd_line->HasSwitch(kConfigSwitchName)) { |
284 simple_host.set_config_path( | 282 simple_host.set_config_path( |
285 cmd_line->GetSwitchValuePath(kConfigSwitchName)); | 283 cmd_line->GetSwitchValuePath(kConfigSwitchName)); |
286 } | 284 } |
287 simple_host.set_fake(cmd_line->HasSwitch(kFakeSwitchName)); | 285 simple_host.set_fake(cmd_line->HasSwitch(kFakeSwitchName)); |
288 simple_host.set_is_it2me(cmd_line->HasSwitch(kIT2MeSwitchName)); | 286 simple_host.set_is_it2me(cmd_line->HasSwitch(kIT2MeSwitchName)); |
289 | 287 |
290 if (cmd_line->HasSwitch(kVideoSwitchName)) { | 288 if (cmd_line->HasSwitch(kVideoSwitchName)) { |
(...skipping 17 matching lines...) Expand all Loading... |
308 LOG(ERROR) << "Unknown video codec: " << video_codec; | 306 LOG(ERROR) << "Unknown video codec: " << video_codec; |
309 return 1; | 307 return 1; |
310 } | 308 } |
311 config->mutable_video_configs()->push_back(ChannelConfig( | 309 config->mutable_video_configs()->push_back(ChannelConfig( |
312 transport, remoting::protocol::kDefaultStreamVersion, codec)); | 310 transport, remoting::protocol::kDefaultStreamVersion, codec)); |
313 simple_host.set_protocol_config(config.release()); | 311 simple_host.set_protocol_config(config.release()); |
314 } | 312 } |
315 | 313 |
316 return simple_host.Run(); | 314 return simple_host.Run(); |
317 } | 315 } |
OLD | NEW |