OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "remoting/base/auto_thread_task_runner.h" | 32 #include "remoting/base/auto_thread_task_runner.h" |
33 #include "remoting/base/breakpad.h" | 33 #include "remoting/base/breakpad.h" |
34 #include "remoting/base/constants.h" | 34 #include "remoting/base/constants.h" |
35 #include "remoting/host/branding.h" | 35 #include "remoting/host/branding.h" |
36 #include "remoting/host/chromoting_host.h" | 36 #include "remoting/host/chromoting_host.h" |
37 #include "remoting/host/chromoting_host_context.h" | 37 #include "remoting/host/chromoting_host_context.h" |
38 #include "remoting/host/chromoting_messages.h" | 38 #include "remoting/host/chromoting_messages.h" |
39 #include "remoting/host/config_file_watcher.h" | 39 #include "remoting/host/config_file_watcher.h" |
40 #include "remoting/host/constants.h" | 40 #include "remoting/host/constants.h" |
41 #include "remoting/host/config_file_watcher.h" | 41 #include "remoting/host/config_file_watcher.h" |
42 #include "remoting/host/desktop_environment_factory.h" | 42 #include "remoting/host/desktop_environment.h" |
43 #include "remoting/host/dns_blackhole_checker.h" | 43 #include "remoting/host/dns_blackhole_checker.h" |
44 #include "remoting/host/event_executor.h" | 44 #include "remoting/host/event_executor.h" |
45 #include "remoting/host/heartbeat_sender.h" | 45 #include "remoting/host/heartbeat_sender.h" |
46 #include "remoting/host/host_config.h" | 46 #include "remoting/host/host_config.h" |
47 #include "remoting/host/host_event_logger.h" | 47 #include "remoting/host/host_event_logger.h" |
48 #include "remoting/host/host_user_interface.h" | 48 #include "remoting/host/host_user_interface.h" |
49 #include "remoting/host/json_host_config.h" | 49 #include "remoting/host/json_host_config.h" |
50 #include "remoting/host/log_to_server.h" | 50 #include "remoting/host/log_to_server.h" |
51 #include "remoting/host/network_settings.h" | 51 #include "remoting/host/network_settings.h" |
52 #include "remoting/host/policy_hack/policy_watcher.h" | 52 #include "remoting/host/policy_hack/policy_watcher.h" |
(...skipping 15 matching lines...) Expand all Loading... |
68 #include "remoting/host/curtain_mode_mac.h" | 68 #include "remoting/host/curtain_mode_mac.h" |
69 #endif // defined(OS_MACOSX) | 69 #endif // defined(OS_MACOSX) |
70 | 70 |
71 #if defined(OS_POSIX) | 71 #if defined(OS_POSIX) |
72 #include <signal.h> | 72 #include <signal.h> |
73 #endif // defined(OS_POSIX) | 73 #endif // defined(OS_POSIX) |
74 | 74 |
75 // N.B. OS_WIN is defined by including src/base headers. | 75 // N.B. OS_WIN is defined by including src/base headers. |
76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
77 #include <commctrl.h> | 77 #include <commctrl.h> |
78 #include "remoting/host/win/session_desktop_environment_factory.h" | |
79 #endif // defined(OS_WIN) | 78 #endif // defined(OS_WIN) |
80 | 79 |
81 #if defined(TOOLKIT_GTK) | 80 #if defined(TOOLKIT_GTK) |
82 #include "ui/gfx/gtk_util.h" | 81 #include "ui/gfx/gtk_util.h" |
83 #endif // defined(TOOLKIT_GTK) | 82 #endif // defined(TOOLKIT_GTK) |
84 | 83 |
85 namespace { | 84 namespace { |
86 | 85 |
87 // This is used for tagging system event logs. | 86 // This is used for tagging system event logs. |
88 const char kApplicationName[] = "chromoting"; | 87 const char kApplicationName[] = "chromoting"; |
(...skipping 25 matching lines...) Expand all Loading... |
114 : context_(context.Pass()), | 113 : context_(context.Pass()), |
115 config_(FilePath()), | 114 config_(FilePath()), |
116 #ifdef OFFICIAL_BUILD | 115 #ifdef OFFICIAL_BUILD |
117 oauth_use_official_client_id_(true), | 116 oauth_use_official_client_id_(true), |
118 #else | 117 #else |
119 oauth_use_official_client_id_(false), | 118 oauth_use_official_client_id_(false), |
120 #endif | 119 #endif |
121 allow_nat_traversal_(true), | 120 allow_nat_traversal_(true), |
122 restarting_(false), | 121 restarting_(false), |
123 shutting_down_(false), | 122 shutting_down_(false), |
124 #if defined(OS_WIN) | |
125 desktop_environment_factory_(new SessionDesktopEnvironmentFactory()), | |
126 #else // !defined(OS_WIN) | |
127 desktop_environment_factory_(new DesktopEnvironmentFactory()), | |
128 #endif // !defined(OS_WIN) | |
129 exit_code_(kSuccessExitCode) | 123 exit_code_(kSuccessExitCode) |
130 #if defined(OS_MACOSX) | 124 #if defined(OS_MACOSX) |
131 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested, | 125 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested, |
132 base::Unretained(this)), | 126 base::Unretained(this)), |
133 base::Bind(&HostProcess::OnDisconnectRequested, | 127 base::Bind(&HostProcess::OnDisconnectRequested, |
134 base::Unretained(this))) | 128 base::Unretained(this))) |
135 #endif | 129 #endif |
136 { | 130 { |
137 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 131 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
138 } | 132 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 client_info = official_client_info; | 530 client_info = official_client_info; |
537 } | 531 } |
538 #endif // OFFICIAL_BUILD | 532 #endif // OFFICIAL_BUILD |
539 | 533 |
540 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( | 534 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( |
541 new SignalingConnector::OAuthCredentials( | 535 new SignalingConnector::OAuthCredentials( |
542 xmpp_login_, oauth_refresh_token_, client_info)); | 536 xmpp_login_, oauth_refresh_token_, client_info)); |
543 signaling_connector_->EnableOAuth(oauth_credentials.Pass()); | 537 signaling_connector_->EnableOAuth(oauth_credentials.Pass()); |
544 } | 538 } |
545 | 539 |
| 540 if (!desktop_environment_.get()) { |
| 541 desktop_environment_ = |
| 542 DesktopEnvironment::CreateForService(context_.get()); |
| 543 } |
| 544 |
546 NetworkSettings network_settings( | 545 NetworkSettings network_settings( |
547 allow_nat_traversal_ ? | 546 allow_nat_traversal_ ? |
548 NetworkSettings::NAT_TRAVERSAL_ENABLED : | 547 NetworkSettings::NAT_TRAVERSAL_ENABLED : |
549 NetworkSettings::NAT_TRAVERSAL_DISABLED); | 548 NetworkSettings::NAT_TRAVERSAL_DISABLED); |
550 if (!allow_nat_traversal_) { | 549 if (!allow_nat_traversal_) { |
551 network_settings.min_port = NetworkSettings::kDefaultMinPort; | 550 network_settings.min_port = NetworkSettings::kDefaultMinPort; |
552 network_settings.max_port = NetworkSettings::kDefaultMaxPort; | 551 network_settings.max_port = NetworkSettings::kDefaultMaxPort; |
553 } | 552 } |
554 | 553 |
555 host_ = new ChromotingHost( | 554 host_ = new ChromotingHost( |
556 context_.get(), signal_strategy_.get(), | 555 context_.get(), signal_strategy_.get(), desktop_environment_.get(), |
557 desktop_environment_factory_.get(), | |
558 CreateHostSessionManager(network_settings, | 556 CreateHostSessionManager(network_settings, |
559 context_->url_request_context_getter())); | 557 context_->url_request_context_getter())); |
560 | 558 |
561 // TODO(simonmorris): Get the maximum session duration from a policy. | 559 // TODO(simonmorris): Get the maximum session duration from a policy. |
562 #if defined(OS_LINUX) | 560 #if defined(OS_LINUX) |
563 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); | 561 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); |
564 #endif | 562 #endif |
565 | 563 |
566 heartbeat_sender_.reset(new HeartbeatSender( | 564 heartbeat_sender_.reset(new HeartbeatSender( |
567 this, host_id_, signal_strategy_.get(), &key_pair_)); | 565 this, host_id_, signal_strategy_.get(), &key_pair_)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 // Complete the rest of shutdown on the main thread. | 643 // Complete the rest of shutdown on the main thread. |
646 context_->ui_task_runner()->PostTask( | 644 context_->ui_task_runner()->PostTask( |
647 FROM_HERE, | 645 FROM_HERE, |
648 base::Bind(&HostProcess::ShutdownHostProcess, | 646 base::Bind(&HostProcess::ShutdownHostProcess, |
649 base::Unretained(this))); | 647 base::Unretained(this))); |
650 } | 648 } |
651 | 649 |
652 void ResetHost() { | 650 void ResetHost() { |
653 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 651 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
654 | 652 |
| 653 desktop_environment_.reset(); |
655 host_event_logger_.reset(); | 654 host_event_logger_.reset(); |
656 log_to_server_.reset(); | 655 log_to_server_.reset(); |
657 heartbeat_sender_.reset(); | 656 heartbeat_sender_.reset(); |
658 signaling_connector_.reset(); | 657 signaling_connector_.reset(); |
659 signal_strategy_.reset(); | 658 signal_strategy_.reset(); |
660 } | 659 } |
661 | 660 |
662 scoped_ptr<ChromotingHostContext> context_; | 661 scoped_ptr<ChromotingHostContext> context_; |
663 scoped_ptr<IPC::ChannelProxy> daemon_channel_; | 662 scoped_ptr<IPC::ChannelProxy> daemon_channel_; |
664 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 663 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
(...skipping 14 matching lines...) Expand all Loading... |
679 std::string oauth_refresh_token_; | 678 std::string oauth_refresh_token_; |
680 bool oauth_use_official_client_id_; | 679 bool oauth_use_official_client_id_; |
681 | 680 |
682 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 681 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
683 bool allow_nat_traversal_; | 682 bool allow_nat_traversal_; |
684 std::string talkgadget_prefix_; | 683 std::string talkgadget_prefix_; |
685 | 684 |
686 bool restarting_; | 685 bool restarting_; |
687 bool shutting_down_; | 686 bool shutting_down_; |
688 | 687 |
689 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; | |
690 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 688 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
691 scoped_ptr<SignalingConnector> signaling_connector_; | 689 scoped_ptr<SignalingConnector> signaling_connector_; |
| 690 scoped_ptr<DesktopEnvironment> desktop_environment_; |
692 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 691 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
693 scoped_ptr<LogToServer> log_to_server_; | 692 scoped_ptr<LogToServer> log_to_server_; |
694 scoped_ptr<HostEventLogger> host_event_logger_; | 693 scoped_ptr<HostEventLogger> host_event_logger_; |
695 | 694 |
696 #if defined(OS_MACOSX) || defined(OS_WIN) | 695 #if defined(OS_MACOSX) || defined(OS_WIN) |
697 scoped_ptr<HostUserInterface> host_user_interface_; | 696 scoped_ptr<HostUserInterface> host_user_interface_; |
698 #endif | 697 #endif |
699 | 698 |
700 scoped_refptr<ChromotingHost> host_; | 699 scoped_refptr<ChromotingHost> host_; |
701 | 700 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 user32.GetFunctionPointer("SetProcessDPIAware")); | 805 user32.GetFunctionPointer("SetProcessDPIAware")); |
807 set_process_dpi_aware(); | 806 set_process_dpi_aware(); |
808 } | 807 } |
809 | 808 |
810 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 809 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
811 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 810 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
812 return main(0, NULL); | 811 return main(0, NULL); |
813 } | 812 } |
814 | 813 |
815 #endif // defined(OS_WIN) | 814 #endif // defined(OS_WIN) |
OLD | NEW |