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

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

Issue 10920019: [Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to ClientSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. 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
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 18 matching lines...) Expand all
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/auto_thread_task_runner.h"
32 #include "remoting/base/breakpad.h" 32 #include "remoting/base/breakpad.h"
33 #include "remoting/base/constants.h" 33 #include "remoting/base/constants.h"
34 #include "remoting/host/branding.h" 34 #include "remoting/host/branding.h"
35 #include "remoting/host/chromoting_host.h" 35 #include "remoting/host/chromoting_host.h"
36 #include "remoting/host/chromoting_host_context.h" 36 #include "remoting/host/chromoting_host_context.h"
37 #include "remoting/host/composite_host_config.h" 37 #include "remoting/host/composite_host_config.h"
38 #include "remoting/host/constants.h" 38 #include "remoting/host/constants.h"
39 #include "remoting/host/desktop_environment.h" 39 #include "remoting/host/desktop_environment_factory.h"
40 #include "remoting/host/event_executor.h" 40 #include "remoting/host/event_executor.h"
41 #include "remoting/host/heartbeat_sender.h" 41 #include "remoting/host/heartbeat_sender.h"
42 #include "remoting/host/host_config.h" 42 #include "remoting/host/host_config.h"
43 #include "remoting/host/host_event_logger.h" 43 #include "remoting/host/host_event_logger.h"
44 #include "remoting/host/host_user_interface.h" 44 #include "remoting/host/host_user_interface.h"
45 #include "remoting/host/log_to_server.h" 45 #include "remoting/host/log_to_server.h"
46 #include "remoting/host/network_settings.h" 46 #include "remoting/host/network_settings.h"
47 #include "remoting/host/policy_hack/policy_watcher.h" 47 #include "remoting/host/policy_hack/policy_watcher.h"
48 #include "remoting/host/session_manager_factory.h" 48 #include "remoting/host/session_manager_factory.h"
49 #include "remoting/host/signaling_connector.h" 49 #include "remoting/host/signaling_connector.h"
50 #include "remoting/host/usage_stats_consent.h" 50 #include "remoting/host/usage_stats_consent.h"
51 #include "remoting/host/video_frame_capturer.h" 51 #include "remoting/host/video_frame_capturer.h"
52 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 52 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
53 #include "remoting/protocol/me2me_host_authenticator_factory.h" 53 #include "remoting/protocol/me2me_host_authenticator_factory.h"
54 54
55 #if defined(OS_POSIX) 55 #if defined(OS_POSIX)
56 #include "remoting/host/posix/sighup_listener.h" 56 #include "remoting/host/posix/sighup_listener.h"
57 #endif // defined(OS_POSIX) 57 #endif // defined(OS_POSIX)
58 58
59 #if defined(OS_MACOSX) 59 #if defined(OS_MACOSX)
60 #include "base/mac/scoped_cftyperef.h" 60 #include "base/mac/scoped_cftyperef.h"
61 #include "base/mac/scoped_nsautorelease_pool.h" 61 #include "base/mac/scoped_nsautorelease_pool.h"
62 #include "remoting/host/curtain_mode_mac.h" 62 #include "remoting/host/curtain_mode_mac.h"
63 #endif // defined(OS_MACOSX) 63 #endif // defined(OS_MACOSX)
64 64
65 // N.B. OS_WIN is defined by including src/base headers. 65 // N.B. OS_WIN is defined by including src/base headers.
66 #if defined(OS_WIN) 66 #if defined(OS_WIN)
67 #include <commctrl.h> 67 #include <commctrl.h>
68 #include "remoting/host/win/session_desktop_environment_factory.h"
68 #endif // defined(OS_WIN) 69 #endif // defined(OS_WIN)
69 70
70 #if defined(TOOLKIT_GTK) 71 #if defined(TOOLKIT_GTK)
71 #include "ui/gfx/gtk_util.h" 72 #include "ui/gfx/gtk_util.h"
72 #endif // defined(TOOLKIT_GTK) 73 #endif // defined(TOOLKIT_GTK)
73 74
74 namespace { 75 namespace {
75 76
76 // This is used for tagging system event logs. 77 // This is used for tagging system event logs.
77 const char kApplicationName[] = "chromoting"; 78 const char kApplicationName[] = "chromoting";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 HostProcess(scoped_ptr<ChromotingHostContext> context) 114 HostProcess(scoped_ptr<ChromotingHostContext> context)
114 : context_(context.Pass()), 115 : context_(context.Pass()),
115 #ifdef OFFICIAL_BUILD 116 #ifdef OFFICIAL_BUILD
116 oauth_use_official_client_id_(true), 117 oauth_use_official_client_id_(true),
117 #else 118 #else
118 oauth_use_official_client_id_(false), 119 oauth_use_official_client_id_(false),
119 #endif 120 #endif
120 allow_nat_traversal_(true), 121 allow_nat_traversal_(true),
121 restarting_(false), 122 restarting_(false),
122 shutting_down_(false), 123 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)
123 exit_code_(kSuccessExitCode) 129 exit_code_(kSuccessExitCode)
124 #if defined(OS_MACOSX) 130 #if defined(OS_MACOSX)
125 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested, 131 , curtain_(base::Bind(&HostProcess::OnDisconnectRequested,
126 base::Unretained(this)), 132 base::Unretained(this)),
127 base::Bind(&HostProcess::OnDisconnectRequested, 133 base::Bind(&HostProcess::OnDisconnectRequested,
128 base::Unretained(this))) 134 base::Unretained(this)))
129 #endif 135 #endif
130 { 136 {
131 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 137 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
132 config_updated_timer_.reset(new base::DelayTimer<HostProcess>( 138 config_updated_timer_.reset(new base::DelayTimer<HostProcess>(
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 504
499 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( 505 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials(
500 new SignalingConnector::OAuthCredentials( 506 new SignalingConnector::OAuthCredentials(
501 xmpp_login_, oauth_refresh_token_, client_info)); 507 xmpp_login_, oauth_refresh_token_, client_info));
502 signaling_connector_->EnableOAuth( 508 signaling_connector_->EnableOAuth(
503 oauth_credentials.Pass(), 509 oauth_credentials.Pass(),
504 context_->url_request_context_getter()); 510 context_->url_request_context_getter());
505 } 511 }
506 } 512 }
507 513
508 if (!desktop_environment_.get()) {
509 desktop_environment_ =
510 DesktopEnvironment::CreateForService(context_.get());
511 }
512
513 NetworkSettings network_settings( 514 NetworkSettings network_settings(
514 allow_nat_traversal_ ? 515 allow_nat_traversal_ ?
515 NetworkSettings::NAT_TRAVERSAL_ENABLED : 516 NetworkSettings::NAT_TRAVERSAL_ENABLED :
516 NetworkSettings::NAT_TRAVERSAL_DISABLED); 517 NetworkSettings::NAT_TRAVERSAL_DISABLED);
517 if (!allow_nat_traversal_) { 518 if (!allow_nat_traversal_) {
518 network_settings.min_port = kMinPortNumber; 519 network_settings.min_port = kMinPortNumber;
519 network_settings.max_port = kMaxPortNumber; 520 network_settings.max_port = kMaxPortNumber;
520 } 521 }
521 522
522 host_ = new ChromotingHost( 523 host_ = new ChromotingHost(
523 context_.get(), signal_strategy_.get(), desktop_environment_.get(), 524 context_.get(), signal_strategy_.get(),
525 desktop_environment_factory_.get(),
524 CreateHostSessionManager(network_settings, 526 CreateHostSessionManager(network_settings,
525 context_->url_request_context_getter())); 527 context_->url_request_context_getter()));
526 528
527 // TODO(simonmorris): Get the maximum session duration from a policy. 529 // TODO(simonmorris): Get the maximum session duration from a policy.
528 #if defined(OS_LINUX) 530 #if defined(OS_LINUX)
529 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); 531 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
530 #endif 532 #endif
531 533
532 heartbeat_sender_.reset(new HeartbeatSender( 534 heartbeat_sender_.reset(new HeartbeatSender(
533 this, host_id_, signal_strategy_.get(), &key_pair_)); 535 this, host_id_, signal_strategy_.get(), &key_pair_));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } else { 601 } else {
600 OnShutdownFinished(); 602 OnShutdownFinished();
601 } 603 }
602 } 604 }
603 605
604 void OnShutdownFinished() { 606 void OnShutdownFinished() {
605 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 607 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
606 608
607 // Destroy networking objects while we are on the network thread. 609 // Destroy networking objects while we are on the network thread.
608 host_ = NULL; 610 host_ = NULL;
609 desktop_environment_.reset();
610 host_event_logger_.reset(); 611 host_event_logger_.reset();
611 log_to_server_.reset(); 612 log_to_server_.reset();
612 heartbeat_sender_.reset(); 613 heartbeat_sender_.reset();
613 signaling_connector_.reset(); 614 signaling_connector_.reset();
614 signal_strategy_.reset(); 615 signal_strategy_.reset();
615 616
616 // Complete the rest of shutdown on the main thread. 617 // Complete the rest of shutdown on the main thread.
617 context_->ui_task_runner()->PostTask( 618 context_->ui_task_runner()->PostTask(
618 FROM_HERE, 619 FROM_HERE,
619 base::Bind(&HostProcess::ShutdownHostProcess, 620 base::Bind(&HostProcess::ShutdownHostProcess,
(...skipping 18 matching lines...) Expand all
638 bool oauth_use_official_client_id_; 639 bool oauth_use_official_client_id_;
639 640
640 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 641 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
641 bool allow_nat_traversal_; 642 bool allow_nat_traversal_;
642 scoped_ptr<base::files::FilePathWatcher> config_watcher_; 643 scoped_ptr<base::files::FilePathWatcher> config_watcher_;
643 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_; 644 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_;
644 645
645 bool restarting_; 646 bool restarting_;
646 bool shutting_down_; 647 bool shutting_down_;
647 648
649 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
648 scoped_ptr<XmppSignalStrategy> signal_strategy_; 650 scoped_ptr<XmppSignalStrategy> signal_strategy_;
649 scoped_ptr<SignalingConnector> signaling_connector_; 651 scoped_ptr<SignalingConnector> signaling_connector_;
650 scoped_ptr<DesktopEnvironment> desktop_environment_;
651 scoped_ptr<HeartbeatSender> heartbeat_sender_; 652 scoped_ptr<HeartbeatSender> heartbeat_sender_;
652 scoped_ptr<LogToServer> log_to_server_; 653 scoped_ptr<LogToServer> log_to_server_;
653 scoped_ptr<HostEventLogger> host_event_logger_; 654 scoped_ptr<HostEventLogger> host_event_logger_;
654 655
655 #if defined(OS_MACOSX) || defined(OS_WIN) 656 #if defined(OS_MACOSX) || defined(OS_WIN)
656 scoped_ptr<HostUserInterface> host_user_interface_; 657 scoped_ptr<HostUserInterface> host_user_interface_;
657 #endif 658 #endif
658 659
659 scoped_refptr<ChromotingHost> host_; 660 scoped_refptr<ChromotingHost> host_;
660 661
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 user32.GetFunctionPointer("SetProcessDPIAware")); 766 user32.GetFunctionPointer("SetProcessDPIAware"));
766 set_process_dpi_aware(); 767 set_process_dpi_aware();
767 } 768 }
768 769
769 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 770 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
770 // the command line from GetCommandLineW(), so we can safely pass NULL here. 771 // the command line from GetCommandLineW(), so we can safely pass NULL here.
771 return main(0, NULL); 772 return main(0, NULL);
772 } 773 }
773 774
774 #endif // defined(OS_WIN) 775 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698