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

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

Issue 13212009: Made DesktopEnvironment responsible for creation of the disconnect window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Mac Created 7 years, 8 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "remoting/host/curtaining_host_observer.h" 44 #include "remoting/host/curtaining_host_observer.h"
45 #include "remoting/host/desktop_environment.h" 45 #include "remoting/host/desktop_environment.h"
46 #include "remoting/host/desktop_session_connector.h" 46 #include "remoting/host/desktop_session_connector.h"
47 #include "remoting/host/dns_blackhole_checker.h" 47 #include "remoting/host/dns_blackhole_checker.h"
48 #include "remoting/host/heartbeat_sender.h" 48 #include "remoting/host/heartbeat_sender.h"
49 #include "remoting/host/host_change_notification_listener.h" 49 #include "remoting/host/host_change_notification_listener.h"
50 #include "remoting/host/host_config.h" 50 #include "remoting/host/host_config.h"
51 #include "remoting/host/host_event_logger.h" 51 #include "remoting/host/host_event_logger.h"
52 #include "remoting/host/host_exit_codes.h" 52 #include "remoting/host/host_exit_codes.h"
53 #include "remoting/host/host_main.h" 53 #include "remoting/host/host_main.h"
54 #include "remoting/host/host_user_interface.h"
55 #include "remoting/host/ipc_constants.h" 54 #include "remoting/host/ipc_constants.h"
56 #include "remoting/host/ipc_desktop_environment.h" 55 #include "remoting/host/ipc_desktop_environment.h"
57 #include "remoting/host/ipc_host_event_logger.h" 56 #include "remoting/host/ipc_host_event_logger.h"
58 #include "remoting/host/json_host_config.h" 57 #include "remoting/host/json_host_config.h"
59 #include "remoting/host/log_to_server.h" 58 #include "remoting/host/log_to_server.h"
60 #include "remoting/host/logging.h" 59 #include "remoting/host/logging.h"
61 #include "remoting/host/me2me_desktop_environment.h" 60 #include "remoting/host/me2me_desktop_environment.h"
62 #include "remoting/host/network_settings.h" 61 #include "remoting/host/network_settings.h"
63 #include "remoting/host/policy_hack/policy_watcher.h" 62 #include "remoting/host/policy_hack/policy_watcher.h"
64 #include "remoting/host/service_urls.h" 63 #include "remoting/host/service_urls.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; 268 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_;
270 bool curtain_required_; 269 bool curtain_required_;
271 270
272 scoped_ptr<XmppSignalStrategy> signal_strategy_; 271 scoped_ptr<XmppSignalStrategy> signal_strategy_;
273 scoped_ptr<SignalingConnector> signaling_connector_; 272 scoped_ptr<SignalingConnector> signaling_connector_;
274 scoped_ptr<HeartbeatSender> heartbeat_sender_; 273 scoped_ptr<HeartbeatSender> heartbeat_sender_;
275 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; 274 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_;
276 scoped_ptr<LogToServer> log_to_server_; 275 scoped_ptr<LogToServer> log_to_server_;
277 scoped_ptr<HostEventLogger> host_event_logger_; 276 scoped_ptr<HostEventLogger> host_event_logger_;
278 277
279 // Created on the UI thread and used on the network thread.
280 scoped_ptr<HostUserInterface> host_user_interface_;
281
282 scoped_refptr<ChromotingHost> host_; 278 scoped_refptr<ChromotingHost> host_;
283 279
284 // Used to keep this HostProcess alive until it is shutdown. 280 // Used to keep this HostProcess alive until it is shutdown.
285 scoped_refptr<HostProcess> self_; 281 scoped_refptr<HostProcess> self_;
286 282
287 #if defined(REMOTING_MULTI_PROCESS) 283 #if defined(REMOTING_MULTI_PROCESS)
288 DesktopSessionConnector* desktop_session_connector_; 284 DesktopSessionConnector* desktop_session_connector_;
289 #endif // defined(REMOTING_MULTI_PROCESS) 285 #endif // defined(REMOTING_MULTI_PROCESS)
290 286
291 int* exit_code_out_; 287 int* exit_code_out_;
(...skipping 19 matching lines...) Expand all
311 base::Unretained(this))); 307 base::Unretained(this)));
312 308
313 StartOnUiThread(); 309 StartOnUiThread();
314 } 310 }
315 311
316 HostProcess::~HostProcess() { 312 HostProcess::~HostProcess() {
317 // Verify that UI components have been torn down. 313 // Verify that UI components have been torn down.
318 DCHECK(!config_watcher_); 314 DCHECK(!config_watcher_);
319 DCHECK(!daemon_channel_); 315 DCHECK(!daemon_channel_);
320 DCHECK(!desktop_environment_factory_); 316 DCHECK(!desktop_environment_factory_);
321 DCHECK(!host_user_interface_);
322 317
323 // We might be getting deleted on one of the threads the |host_context| owns, 318 // We might be getting deleted on one of the threads the |host_context| owns,
324 // so we need to post it back to the caller thread to safely join & delete the 319 // so we need to post it back to the caller thread to safely join & delete the
325 // threads it contains. This will go away when we move to AutoThread. 320 // threads it contains. This will go away when we move to AutoThread.
326 // |context_release()| will null |context_| before the method is invoked, so 321 // |context_release()| will null |context_| before the method is invoked, so
327 // we need to pull out the task-runner on which to call DeleteSoon first. 322 // we need to pull out the task-runner on which to call DeleteSoon first.
328 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 323 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
329 context_->ui_task_runner(); 324 context_->ui_task_runner();
330 task_runner->DeleteSoon(FROM_HERE, context_.release()); 325 task_runner->DeleteSoon(FROM_HERE, context_.release());
331 } 326 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // If an audio pipe is specific on the command-line then initialize 539 // If an audio pipe is specific on the command-line then initialize
545 // AudioCapturerLinux to capture from it. 540 // AudioCapturerLinux to capture from it.
546 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> 541 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()->
547 GetSwitchValuePath(kAudioPipeSwitchName); 542 GetSwitchValuePath(kAudioPipeSwitchName);
548 if (!audio_pipe_name.empty()) { 543 if (!audio_pipe_name.empty()) {
549 remoting::AudioCapturerLinux::InitializePipeReader( 544 remoting::AudioCapturerLinux::InitializePipeReader(
550 context_->audio_task_runner(), audio_pipe_name); 545 context_->audio_task_runner(), audio_pipe_name);
551 } 546 }
552 #endif // defined(OS_LINUX) 547 #endif // defined(OS_LINUX)
553 548
549 // TODO(alexeypa): Localize the UI strings. See http://crbug.com/155204.
550 UiStrings ui_strings;
551
554 // Create a desktop environment factory appropriate to the build type & 552 // Create a desktop environment factory appropriate to the build type &
555 // platform. 553 // platform.
556 #if defined(OS_WIN) 554 #if defined(OS_WIN)
557 555
558 #if defined(REMOTING_MULTI_PROCESS) 556 #if defined(REMOTING_MULTI_PROCESS)
559 IpcDesktopEnvironmentFactory* desktop_environment_factory = 557 IpcDesktopEnvironmentFactory* desktop_environment_factory =
560 new IpcDesktopEnvironmentFactory( 558 new IpcDesktopEnvironmentFactory(
561 context_->audio_task_runner(), 559 context_->audio_task_runner(),
562 context_->network_task_runner(), 560 context_->network_task_runner(),
563 context_->video_capture_task_runner(), 561 context_->video_capture_task_runner(),
564 context_->network_task_runner(), 562 context_->network_task_runner(),
565 daemon_channel_.get()); 563 daemon_channel_.get());
566 desktop_session_connector_ = desktop_environment_factory; 564 desktop_session_connector_ = desktop_environment_factory;
567 #else // !defined(REMOTING_MULTI_PROCESS) 565 #else // !defined(REMOTING_MULTI_PROCESS)
568 DesktopEnvironmentFactory* desktop_environment_factory = 566 DesktopEnvironmentFactory* desktop_environment_factory =
569 new SessionDesktopEnvironmentFactory( 567 new SessionDesktopEnvironmentFactory(
570 context_->network_task_runner(), 568 context_->network_task_runner(),
571 context_->input_task_runner(), 569 context_->input_task_runner(),
572 context_->ui_task_runner(), 570 context_->ui_task_runner(),
571 ui_strings,
573 base::Bind(&HostProcess::SendSasToConsole, this)); 572 base::Bind(&HostProcess::SendSasToConsole, this));
574 #endif // !defined(REMOTING_MULTI_PROCESS) 573 #endif // !defined(REMOTING_MULTI_PROCESS)
575 574
576 #else // !defined(OS_WIN) 575 #else // !defined(OS_WIN)
577 DesktopEnvironmentFactory* desktop_environment_factory = 576 DesktopEnvironmentFactory* desktop_environment_factory =
578 new Me2MeDesktopEnvironmentFactory( 577 new Me2MeDesktopEnvironmentFactory(
579 context_->network_task_runner(), 578 context_->network_task_runner(),
580 context_->input_task_runner(), 579 context_->input_task_runner(),
581 context_->ui_task_runner()); 580 context_->ui_task_runner(),
581 ui_strings);
582 #endif // !defined(OS_WIN) 582 #endif // !defined(OS_WIN)
583 583
584 desktop_environment_factory_.reset(desktop_environment_factory); 584 desktop_environment_factory_.reset(desktop_environment_factory);
585 585
586 // The host UI should be created on the UI thread.
587 bool want_user_interface = true;
588 #if defined(OS_LINUX) || defined(REMOTING_MULTI_PROCESS)
589 want_user_interface = false;
590 #elif defined(OS_MACOSX)
591 // Don't try to display any UI on top of the system's login screen as this
592 // is rejected by the Window Server on OS X 10.7.4, and prevents the
593 // capturer from working (http://crbug.com/140984).
594
595 // TODO(lambroslambrou): Use a better technique of detecting whether we're
596 // running in the LoginWindow context, and refactor this into a separate
597 // function to be used here and in CurtainMode::ActivateCurtain().
598 want_user_interface = getuid() != 0;
599 #endif // OS_MACOSX
600
601 if (want_user_interface) {
602 UiStrings ui_strings;
603 host_user_interface_.reset(
604 new HostUserInterface(context_->network_task_runner(),
605 context_->ui_task_runner(), ui_strings));
606 host_user_interface_->Init();
607 }
608
609 context_->network_task_runner()->PostTask( 586 context_->network_task_runner()->PostTask(
610 FROM_HERE, 587 FROM_HERE,
611 base::Bind(&HostProcess::StartOnNetworkThread, this)); 588 base::Bind(&HostProcess::StartOnNetworkThread, this));
612 } 589 }
613 590
614 void HostProcess::SendSasToConsole() { 591 void HostProcess::SendSasToConsole() {
615 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 592 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
616 593
617 if (daemon_channel_) 594 if (daemon_channel_)
618 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_SendSasToConsole()); 595 daemon_channel_->Send(new ChromotingNetworkDaemonMsg_SendSasToConsole());
619 } 596 }
620 597
621 void HostProcess::ShutdownOnUiThread() { 598 void HostProcess::ShutdownOnUiThread() {
622 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 599 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
623 600
624 // Tear down resources that need to be torn down on the UI thread. 601 // Tear down resources that need to be torn down on the UI thread.
625 network_change_notifier_.reset(); 602 network_change_notifier_.reset();
626 daemon_channel_.reset(); 603 daemon_channel_.reset();
627 desktop_environment_factory_.reset(); 604 desktop_environment_factory_.reset();
628 host_user_interface_.reset();
629 605
630 // It is now safe for the HostProcess to be deleted. 606 // It is now safe for the HostProcess to be deleted.
631 self_ = NULL; 607 self_ = NULL;
632 608
633 #if defined(OS_LINUX) 609 #if defined(OS_LINUX)
634 // Cause the global AudioPipeReader to be freed, otherwise the audio 610 // Cause the global AudioPipeReader to be freed, otherwise the audio
635 // thread will remain in-use and prevent the process from exiting. 611 // thread will remain in-use and prevent the process from exiting.
636 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. 612 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader.
637 // See crbug.com/161373 and crbug.com/104544. 613 // See crbug.com/161373 and crbug.com/104544.
638 AudioCapturerLinux::InitializePipeReader(NULL, base::FilePath()); 614 AudioCapturerLinux::InitializePipeReader(NULL, base::FilePath());
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 #else // !defined(REMOTING_RDP_SESSION) 927 #else // !defined(REMOTING_RDP_SESSION)
952 CurtainMode* curtain = curtain_.get(); 928 CurtainMode* curtain = curtain_.get();
953 #endif // !defined(REMOTING_RDP_SESSION) 929 #endif // !defined(REMOTING_RDP_SESSION)
954 930
955 // Create a host observer to enable/disable curtain mode as clients connect 931 // Create a host observer to enable/disable curtain mode as clients connect
956 // and disconnect. 932 // and disconnect.
957 curtaining_host_observer_.reset(new CurtainingHostObserver( 933 curtaining_host_observer_.reset(new CurtainingHostObserver(
958 curtain, host_->AsWeakPtr())); 934 curtain, host_->AsWeakPtr()));
959 curtaining_host_observer_->SetEnableCurtaining(curtain_required_); 935 curtaining_host_observer_->SetEnableCurtaining(curtain_required_);
960 936
961 if (host_user_interface_.get()) {
962 host_user_interface_->Start(
963 host_, base::Bind(&HostProcess::OnDisconnectRequested, this));
964 }
965
966 host_->Start(xmpp_login_); 937 host_->Start(xmpp_login_);
967 938
968 CreateAuthenticatorFactory(); 939 CreateAuthenticatorFactory();
969 } 940 }
970 941
971 void HostProcess::OnAuthFailed() { 942 void HostProcess::OnAuthFailed() {
972 ShutdownHost(kInvalidOauthCredentialsExitCode); 943 ShutdownHost(kInvalidOauthCredentialsExitCode);
973 } 944 }
974 945
975 void HostProcess::OnCurtainModeFailed() { 946 void HostProcess::OnCurtainModeFailed() {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 return exit_code; 1088 return exit_code;
1118 } 1089 }
1119 1090
1120 } // namespace remoting 1091 } // namespace remoting
1121 1092
1122 #if !defined(OS_WIN) 1093 #if !defined(OS_WIN)
1123 int main(int argc, char** argv) { 1094 int main(int argc, char** argv) {
1124 return remoting::HostMain(argc, argv); 1095 return remoting::HostMain(argc, argv);
1125 } 1096 }
1126 #endif // !defined(OS_WIN) 1097 #endif // !defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_script_object.cc ('k') | remoting/host/win/session_desktop_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698