Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 10829467: [Chromoting] Introducing refcount-based life time management of the message loops in the service (d… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/plugin/host_script_object.cc ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 #include "base/synchronization/waitable_event.h" 21 #include "base/synchronization/waitable_event.h"
22 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "crypto/nss_util.h" 26 #include "crypto/nss_util.h"
27 #include "ipc/ipc_channel.h" 27 #include "ipc/ipc_channel.h"
28 #include "ipc/ipc_channel_proxy.h" 28 #include "ipc/ipc_channel_proxy.h"
29 #include "net/base/network_change_notifier.h" 29 #include "net/base/network_change_notifier.h"
30 #include "net/socket/ssl_server_socket.h" 30 #include "net/socket/ssl_server_socket.h"
31 #include "remoting/base/auto_thread_task_runner.h"
31 #include "remoting/base/breakpad.h" 32 #include "remoting/base/breakpad.h"
32 #include "remoting/base/constants.h" 33 #include "remoting/base/constants.h"
33 #include "remoting/host/branding.h" 34 #include "remoting/host/branding.h"
34 #include "remoting/host/chromoting_host.h" 35 #include "remoting/host/chromoting_host.h"
35 #include "remoting/host/chromoting_host_context.h" 36 #include "remoting/host/chromoting_host_context.h"
36 #include "remoting/host/composite_host_config.h" 37 #include "remoting/host/composite_host_config.h"
37 #include "remoting/host/constants.h" 38 #include "remoting/host/constants.h"
38 #include "remoting/host/desktop_environment.h" 39 #include "remoting/host/desktop_environment.h"
39 #include "remoting/host/dns_blackhole_checker.h" 40 #include "remoting/host/dns_blackhole_checker.h"
40 #include "remoting/host/event_executor.h" 41 #include "remoting/host/event_executor.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 FILE_PATH_LITERAL("host.json"); 89 FILE_PATH_LITERAL("host.json");
89 90
90 const char kUnofficialOAuth2ClientId[] = 91 const char kUnofficialOAuth2ClientId[] =
91 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com"; 92 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com";
92 const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_"; 93 const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_";
93 94
94 const char kOfficialOAuth2ClientId[] = 95 const char kOfficialOAuth2ClientId[] =
95 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com"; 96 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com";
96 const char kOfficialOAuth2ClientSecret[] = "Bgur6DFiOMM1h8x-AQpuTQlK"; 97 const char kOfficialOAuth2ClientSecret[] = "Bgur6DFiOMM1h8x-AQpuTQlK";
97 98
99 void QuitMessageLoop(MessageLoop* message_loop) {
100 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
101 }
102
98 } // namespace 103 } // namespace
99 104
100 namespace remoting { 105 namespace remoting {
101 106
102 class HostProcess 107 class HostProcess
103 : public HeartbeatSender::Listener, 108 : public HeartbeatSender::Listener,
104 public IPC::Listener { 109 public IPC::Listener {
105 public: 110 public:
106 HostProcess() 111 HostProcess(scoped_ptr<ChromotingHostContext> context)
107 : message_loop_(MessageLoop::TYPE_UI), 112 : context_(context.Pass()),
108 #ifdef OFFICIAL_BUILD 113 #ifdef OFFICIAL_BUILD
109 oauth_use_official_client_id_(true), 114 oauth_use_official_client_id_(true),
110 #else 115 #else
111 oauth_use_official_client_id_(false), 116 oauth_use_official_client_id_(false),
112 #endif 117 #endif
113 allow_nat_traversal_(true), 118 allow_nat_traversal_(true),
114 restarting_(false), 119 restarting_(false),
115 shutting_down_(false), 120 shutting_down_(false),
116 exit_code_(kSuccessExitCode) 121 exit_code_(kSuccessExitCode)
117 #if defined(OS_MACOSX) 122 #if defined(OS_MACOSX)
118 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested, 123 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested,
119 base::Unretained(this)), 124 base::Unretained(this)),
120 base::Bind(&HostProcess::OnDisconnectRequested, 125 base::Bind(&HostProcess::OnDisconnectRequested,
121 base::Unretained(this))) 126 base::Unretained(this)))
122 #endif 127 #endif
123 { 128 {
124 context_.reset(
125 new ChromotingHostContext(message_loop_.message_loop_proxy()));
126 context_->Start();
127 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 129 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
128 config_updated_timer_.reset(new base::DelayTimer<HostProcess>( 130 config_updated_timer_.reset(new base::DelayTimer<HostProcess>(
129 FROM_HERE, base::TimeDelta::FromSeconds(2), this, 131 FROM_HERE, base::TimeDelta::FromSeconds(2), this,
130 &HostProcess::ConfigUpdatedDelayed)); 132 &HostProcess::ConfigUpdatedDelayed));
131 } 133 }
132 134
133 bool InitWithCommandLine(const CommandLine* cmd_line) { 135 bool InitWithCommandLine(const CommandLine* cmd_line) {
134 // Connect to the daemon process. 136 // Connect to the daemon process.
135 std::string channel_name = 137 std::string channel_name =
136 cmd_line->GetSwitchValueASCII(kDaemonIpcSwitchName); 138 cmd_line->GetSwitchValueASCII(kDaemonIpcSwitchName);
(...skipping 18 matching lines...) Expand all
155 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); 157 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile);
156 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 158 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
157 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 159 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
158 } 160 }
159 config_.AddConfigPath(host_config_path_); 161 config_.AddConfigPath(host_config_path_);
160 162
161 return true; 163 return true;
162 } 164 }
163 165
164 void ConfigUpdated() { 166 void ConfigUpdated() {
165 DCHECK(message_loop_.message_loop_proxy()->BelongsToCurrentThread()); 167 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
166 168
167 // Call ConfigUpdatedDelayed after a short delay, so that this object won't 169 // Call ConfigUpdatedDelayed after a short delay, so that this object won't
168 // try to read the updated configuration file before it has been 170 // try to read the updated configuration file before it has been
169 // completely written. 171 // completely written.
170 // If the writer moves the new configuration file into place atomically, 172 // If the writer moves the new configuration file into place atomically,
171 // this delay may not be necessary. 173 // this delay may not be necessary.
172 config_updated_timer_->Reset(); 174 config_updated_timer_->Reset();
173 } 175 }
174 176
175 void ConfigUpdatedDelayed() { 177 void ConfigUpdatedDelayed() {
176 DCHECK(message_loop_.message_loop_proxy()->BelongsToCurrentThread()); 178 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
177 179
178 if (LoadConfig()) { 180 if (LoadConfig()) {
179 // PostTask to create new authenticator factory in case PIN has changed. 181 // PostTask to create new authenticator factory in case PIN has changed.
180 context_->network_task_runner()->PostTask( 182 context_->network_task_runner()->PostTask(
181 FROM_HERE, 183 FROM_HERE,
182 base::Bind(&HostProcess::CreateAuthenticatorFactory, 184 base::Bind(&HostProcess::CreateAuthenticatorFactory,
183 base::Unretained(this))); 185 base::Unretained(this)));
184 } else { 186 } else {
185 LOG(ERROR) << "Invalid configuration."; 187 LOG(ERROR) << "Invalid configuration.";
186 } 188 }
(...skipping 24 matching lines...) Expand all
211 }; 213 };
212 #endif // defined(OS_WIN) 214 #endif // defined(OS_WIN)
213 215
214 void ListenForConfigChanges() { 216 void ListenForConfigChanges() {
215 #if defined(OS_POSIX) 217 #if defined(OS_POSIX)
216 remoting::RegisterHupSignalHandler( 218 remoting::RegisterHupSignalHandler(
217 base::Bind(&HostProcess::ConfigUpdatedDelayed, base::Unretained(this))); 219 base::Bind(&HostProcess::ConfigUpdatedDelayed, base::Unretained(this)));
218 #elif defined(OS_WIN) 220 #elif defined(OS_WIN)
219 scoped_refptr<base::files::FilePathWatcher::Delegate> delegate( 221 scoped_refptr<base::files::FilePathWatcher::Delegate> delegate(
220 new ConfigChangedDelegate( 222 new ConfigChangedDelegate(
221 message_loop_.message_loop_proxy(), 223 context_->ui_task_runner(),
222 base::Bind(&HostProcess::ConfigUpdated, base::Unretained(this)))); 224 base::Bind(&HostProcess::ConfigUpdated, base::Unretained(this))));
223 config_watcher_.reset(new base::files::FilePathWatcher()); 225 config_watcher_.reset(new base::files::FilePathWatcher());
224 if (!config_watcher_->Watch(host_config_path_, delegate)) { 226 if (!config_watcher_->Watch(host_config_path_, delegate)) {
225 LOG(ERROR) << "Couldn't watch file " << host_config_path_.value(); 227 LOG(ERROR) << "Couldn't watch file " << host_config_path_.value();
226 } 228 }
227 #endif // defined (OS_WIN) 229 #endif // defined (OS_WIN)
228 } 230 }
229 231
230 void CreateAuthenticatorFactory() { 232 void CreateAuthenticatorFactory() {
231 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 233 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
232 scoped_ptr<protocol::AuthenticatorFactory> factory( 234 scoped_ptr<protocol::AuthenticatorFactory> factory(
233 new protocol::Me2MeHostAuthenticatorFactory( 235 new protocol::Me2MeHostAuthenticatorFactory(
234 key_pair_.GenerateCertificate(), 236 key_pair_.GenerateCertificate(),
235 *key_pair_.private_key(), host_secret_hash_)); 237 *key_pair_.private_key(), host_secret_hash_));
236 host_->SetAuthenticatorFactory(factory.Pass()); 238 host_->SetAuthenticatorFactory(factory.Pass());
237 } 239 }
238 240
239 // IPC::Listener implementation. 241 // IPC::Listener implementation.
240 virtual bool OnMessageReceived(const IPC::Message& message) { 242 virtual bool OnMessageReceived(const IPC::Message& message) {
241 return false; 243 return false;
242 } 244 }
243 245
244 int Run() { 246 void StartHostProcess() {
245 if (!LoadConfig()) { 247 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
246 return kInvalidHostConfigurationExitCode; 248
249 if (!InitWithCommandLine(CommandLine::ForCurrentProcess()) ||
250 !LoadConfig()) {
251 context_->network_task_runner()->PostTask(
252 FROM_HERE,
253 base::Bind(&HostProcess::Shutdown, base::Unretained(this),
254 kInvalidHostConfigurationExitCode));
255 return;
247 } 256 }
248 257
249 #if defined(OS_MACOSX) || defined(OS_WIN) 258 #if defined(OS_MACOSX) || defined(OS_WIN)
250 bool want_user_interface = true; 259 bool want_user_interface = true;
251 260
252 #if defined(OS_MACOSX) 261 #if defined(OS_MACOSX)
253 // Don't try to display any UI on top of the system's login screen as this 262 // Don't try to display any UI on top of the system's login screen as this
254 // is rejected by the Window Server on OS X 10.7.4, and prevents the 263 // is rejected by the Window Server on OS X 10.7.4, and prevents the
255 // capturer from working (http://crbug.com/140984). 264 // capturer from working (http://crbug.com/140984).
256 base::mac::ScopedCFTypeRef<CFDictionaryRef> session( 265 base::mac::ScopedCFTypeRef<CFDictionaryRef> session(
(...skipping 11 matching lines...) Expand all
268 #endif // OS_MACOSX || OS_WIN 277 #endif // OS_MACOSX || OS_WIN
269 278
270 StartWatchingPolicy(); 279 StartWatchingPolicy();
271 280
272 #if defined(OS_MACOSX) || defined(OS_WIN) 281 #if defined(OS_MACOSX) || defined(OS_WIN)
273 context_->file_task_runner()->PostTask( 282 context_->file_task_runner()->PostTask(
274 FROM_HERE, 283 FROM_HERE,
275 base::Bind(&HostProcess::ListenForConfigChanges, 284 base::Bind(&HostProcess::ListenForConfigChanges,
276 base::Unretained(this))); 285 base::Unretained(this)));
277 #endif 286 #endif
278 message_loop_.Run(); 287 }
288
289 int get_exit_code() const { return exit_code_; }
290
291 private:
292 void ShutdownHostProcess() {
293 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
294
295 daemon_channel_.reset();
279 296
280 #if defined(OS_MACOSX) || defined(OS_WIN) 297 #if defined(OS_MACOSX) || defined(OS_WIN)
281 host_user_interface_.reset(); 298 host_user_interface_.reset();
282 #endif 299 #endif
283 300
284 daemon_channel_.reset(); 301 if (policy_watcher_.get()) {
285 base::WaitableEvent done_event(true, false); 302 base::WaitableEvent done_event(true, false);
286 policy_watcher_->StopWatching(&done_event); 303 policy_watcher_->StopWatching(&done_event);
287 done_event.Wait(); 304 done_event.Wait();
288 policy_watcher_.reset(); 305 policy_watcher_.reset();
306 }
289 307
290 return exit_code_; 308 context_.reset();
291 } 309 }
292 310
293 // Overridden from HeartbeatSender::Listener 311 // Overridden from HeartbeatSender::Listener
294 virtual void OnUnknownHostIdError() OVERRIDE { 312 virtual void OnUnknownHostIdError() OVERRIDE {
295 LOG(ERROR) << "Host ID not found."; 313 LOG(ERROR) << "Host ID not found.";
296 Shutdown(kInvalidHostIdExitCode); 314 Shutdown(kInvalidHostIdExitCode);
297 } 315 }
298 316
299 private:
300 void StartWatchingPolicy() { 317 void StartWatchingPolicy() {
301 policy_watcher_.reset( 318 policy_watcher_.reset(
302 policy_hack::PolicyWatcher::Create(context_->file_task_runner())); 319 policy_hack::PolicyWatcher::Create(context_->file_task_runner()));
303 policy_watcher_->StartWatching( 320 policy_watcher_->StartWatching(
304 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this))); 321 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)));
305 } 322 }
306 323
307 // Read host config, returning true if successful. 324 // Read host config, returning true if successful.
308 bool LoadConfig() { 325 bool LoadConfig() {
309 DCHECK(message_loop_.message_loop_proxy()->BelongsToCurrentThread()); 326 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
310 327
311 // TODO(sergeyu): There is a potential race condition: this function is 328 // TODO(sergeyu): There is a potential race condition: this function is
312 // called on the main thread while the class members it mutates are used on 329 // called on the main thread while the class members it mutates are used on
313 // the network thread. Fix it. http://crbug.com/140986 . 330 // the network thread. Fix it. http://crbug.com/140986 .
314 331
315 if (!config_.Read()) { 332 if (!config_.Read()) {
316 LOG(ERROR) << "Failed to read config file."; 333 LOG(ERROR) << "Failed to read config file.";
317 return false; 334 return false;
318 } 335 }
319 336
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 CreateAuthenticatorFactory(); 585 CreateAuthenticatorFactory();
569 } 586 }
570 587
571 void OnAuthFailed() { 588 void OnAuthFailed() {
572 Shutdown(kInvalidOauthCredentialsExitCode); 589 Shutdown(kInvalidOauthCredentialsExitCode);
573 } 590 }
574 591
575 // Invoked when the user uses the Disconnect windows to terminate 592 // Invoked when the user uses the Disconnect windows to terminate
576 // the sessions. 593 // the sessions.
577 void OnDisconnectRequested() { 594 void OnDisconnectRequested() {
578 DCHECK(message_loop_.message_loop_proxy()->BelongsToCurrentThread()); 595 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
579 596
580 host_->DisconnectAllClients(); 597 host_->DisconnectAllClients();
581 } 598 }
582 599
583 void RestartHost() { 600 void RestartHost() {
584 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 601 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
585 602
586 if (restarting_ || shutting_down_) 603 if (restarting_ || shutting_down_)
587 return; 604 return;
588 605
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 637 }
621 } 638 }
622 639
623 void OnShutdownFinished() { 640 void OnShutdownFinished() {
624 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 641 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
625 642
626 // Destroy networking objects while we are on the network thread. 643 // Destroy networking objects while we are on the network thread.
627 host_ = NULL; 644 host_ = NULL;
628 ResetHost(); 645 ResetHost();
629 646
630 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); 647 // Complete the rest of shutdown on the main thread.
648 context_->ui_task_runner()->PostTask(
649 FROM_HERE,
650 base::Bind(&HostProcess::ShutdownHostProcess,
651 base::Unretained(this)));
631 } 652 }
632 653
633 void ResetHost() { 654 void ResetHost() {
634 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 655 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
635 656
657 desktop_environment_.reset();
636 host_event_logger_.reset(); 658 host_event_logger_.reset();
637 log_to_server_.reset(); 659 log_to_server_.reset();
638 heartbeat_sender_.reset(); 660 heartbeat_sender_.reset();
639 signaling_connector_.reset(); 661 signaling_connector_.reset();
640 signal_strategy_.reset(); 662 signal_strategy_.reset();
641 } 663 }
642 664
643 MessageLoop message_loop_;
644 scoped_ptr<ChromotingHostContext> context_; 665 scoped_ptr<ChromotingHostContext> context_;
645 scoped_ptr<IPC::ChannelProxy> daemon_channel_; 666 scoped_ptr<IPC::ChannelProxy> daemon_channel_;
646 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 667 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
647 668
648 FilePath host_config_path_; 669 FilePath host_config_path_;
649 CompositeHostConfig config_; 670 CompositeHostConfig config_;
650 671
651 std::string host_id_; 672 std::string host_id_;
652 HostKeyPair key_pair_; 673 HostKeyPair key_pair_;
653 protocol::SharedSecretHash host_secret_hash_; 674 protocol::SharedSecretHash host_secret_hash_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 InitLogging(debug_log.value().c_str(), 730 InitLogging(debug_log.value().c_str(),
710 #if defined(OS_WIN) 731 #if defined(OS_WIN)
711 logging::LOG_ONLY_TO_FILE, 732 logging::LOG_ONLY_TO_FILE,
712 #else 733 #else
713 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 734 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
714 #endif 735 #endif
715 logging::DONT_LOCK_LOG_FILE, 736 logging::DONT_LOCK_LOG_FILE,
716 logging::APPEND_TO_OLD_LOG_FILE, 737 logging::APPEND_TO_OLD_LOG_FILE,
717 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); 738 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
718 739
719 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
720
721 #if defined(TOOLKIT_GTK) 740 #if defined(TOOLKIT_GTK)
722 // Required for any calls into GTK functions, such as the Disconnect and 741 // Required for any calls into GTK functions, such as the Disconnect and
723 // Continue windows, though these should not be used for the Me2Me case 742 // Continue windows, though these should not be used for the Me2Me case
724 // (crbug.com/104377). 743 // (crbug.com/104377).
744 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
725 gfx::GtkInitFromCommandLine(*cmd_line); 745 gfx::GtkInitFromCommandLine(*cmd_line);
726 #endif // TOOLKIT_GTK 746 #endif // TOOLKIT_GTK
727 747
728 // Enable support for SSL server sockets, which must be done while still 748 // Enable support for SSL server sockets, which must be done while still
729 // single-threaded. 749 // single-threaded.
730 net::EnableSSLServerSockets(); 750 net::EnableSSLServerSockets();
731 751
732 #if defined(OS_LINUX) 752 #if defined(OS_LINUX)
733 remoting::VideoFrameCapturer::EnableXDamage(true); 753 remoting::VideoFrameCapturer::EnableXDamage(true);
734 #endif 754 #endif
735 755
736 remoting::HostProcess me2me_host; 756 // Create the main message loop and start helper threads.
737 if (!me2me_host.InitWithCommandLine(cmd_line)) { 757 MessageLoop message_loop(MessageLoop::TYPE_UI);
738 return remoting::kInvalidHostConfigurationExitCode; 758 base::Closure quit_message_loop = base::Bind(&QuitMessageLoop, &message_loop);
739 } 759 scoped_ptr<remoting::ChromotingHostContext> context(
760 new remoting::ChromotingHostContext(
761 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
762 quit_message_loop)));
763 if (!context->Start())
764 return remoting::kHostInitializationFailed;
740 765
741 return me2me_host.Run(); 766 // Create the host process instance and run the rest of the initialization on
767 // the main message loop.
768 remoting::HostProcess me2me_host(context.Pass());
769 message_loop.PostTask(
770 FROM_HERE,
771 base::Bind(&remoting::HostProcess::StartHostProcess,
772 base::Unretained(&me2me_host)));
773 message_loop.Run();
774 return me2me_host.get_exit_code();
742 } 775 }
743 776
744 #if defined(OS_WIN) 777 #if defined(OS_WIN)
745 HMODULE g_hModule = NULL; 778 HMODULE g_hModule = NULL;
746 779
747 int CALLBACK WinMain(HINSTANCE instance, 780 int CALLBACK WinMain(HINSTANCE instance,
748 HINSTANCE previous_instance, 781 HINSTANCE previous_instance,
749 LPSTR command_line, 782 LPSTR command_line,
750 int show_command) { 783 int show_command) {
751 #ifdef OFFICIAL_BUILD 784 #ifdef OFFICIAL_BUILD
(...skipping 23 matching lines...) Expand all
775 user32.GetFunctionPointer("SetProcessDPIAware")); 808 user32.GetFunctionPointer("SetProcessDPIAware"));
776 set_process_dpi_aware(); 809 set_process_dpi_aware();
777 } 810 }
778 811
779 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 812 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
780 // the command line from GetCommandLineW(), so we can safely pass NULL here. 813 // the command line from GetCommandLineW(), so we can safely pass NULL here.
781 return main(0, NULL); 814 return main(0, NULL);
782 } 815 }
783 816
784 #endif // defined(OS_WIN) 817 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_script_object.cc ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698