Chromium Code Reviews| Index: remoting/host/remoting_me2me_host.cc |
| diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc |
| index 57d740cb3a05b05170bf9258c8de70e842324c84..659d42576f1b4954ea054eea5df6a6e21614fa09 100644 |
| --- a/remoting/host/remoting_me2me_host.cc |
| +++ b/remoting/host/remoting_me2me_host.cc |
| @@ -46,6 +46,7 @@ |
| #include "remoting/host/config_watcher.h" |
| #include "remoting/host/desktop_environment.h" |
| #include "remoting/host/desktop_session_connector.h" |
| +#include "remoting/host/gcd_rest_client.h" |
| #include "remoting/host/host_change_notification_listener.h" |
| #include "remoting/host/host_config.h" |
| #include "remoting/host/host_event_logger.h" |
| @@ -273,6 +274,8 @@ class HostProcess : public ConfigWatcher::Delegate, |
| bool OnPairingPolicyUpdate(base::DictionaryValue* policies); |
| bool OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies); |
| + scoped_ptr<OAuthTokenGetter> CreateOAuthTokenGetter(); |
| + scoped_ptr<GcdRestClient> CreateGcdRestClient(); |
| scoped_ptr<HostSignalingManager> CreateHostSignalingManager(); |
| void StartHostIfReady(); |
| @@ -305,6 +308,8 @@ class HostProcess : public ConfigWatcher::Delegate, |
| const std::string& file_name, |
| const int& line_number); |
| + bool using_gcd() { return !gcd_device_id_.empty(); } |
| + |
| scoped_ptr<ChromotingHostContext> context_; |
| // Accessed on the UI thread. |
| @@ -357,6 +362,10 @@ class HostProcess : public ConfigWatcher::Delegate, |
| // Used to specify which window to stream, if enabled. |
| webrtc::WindowId window_id_; |
| + scoped_ptr<OAuthTokenGetter> oauth_token_getter_; |
|
Sergey Ulanov
2015/05/07 21:49:55
Comment that this object must outlive gcd_rest_cli
John Williams
2015/05/20 00:22:44
Done.
|
| + |
| + scoped_ptr<GcdRestClient> gcd_rest_client_; |
| + |
| // Used to send heartbeats while running, and the reason for going offline |
| // when shutting down. |
| scoped_ptr<HostSignalingManager> host_signaling_manager_; |
| @@ -1301,18 +1310,41 @@ bool HostProcess::OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies) { |
| return true; |
| } |
| -scoped_ptr<HostSignalingManager> HostProcess::CreateHostSignalingManager() { |
| - DCHECK(!host_id_.empty()); // |ApplyConfig| should already have been run. |
| +scoped_ptr<OAuthTokenGetter> HostProcess::CreateOAuthTokenGetter() { |
| + DCHECK(context_); |
| scoped_ptr<OAuthTokenGetter::OAuthCredentials> oauth_credentials( |
| new OAuthTokenGetter::OAuthCredentials(xmpp_server_config_.username, |
| oauth_refresh_token_, |
| use_service_account_)); |
| + return make_scoped_ptr(new OAuthTokenGetter( |
| + oauth_credentials.Pass(), context_->url_request_context_getter(), false, |
| + !using_gcd())); |
| +} |
| + |
| +scoped_ptr<GcdRestClient> HostProcess::CreateGcdRestClient() { |
| + DCHECK(oauth_token_getter_); |
| + |
| + if (!using_gcd()) { |
| + return nullptr; |
| + } |
| + |
| + ServiceUrls* service_urls = ServiceUrls::GetInstance(); |
| + return make_scoped_ptr(new GcdRestClient( |
| + service_urls->gcd_base_url(), gcd_device_id_, |
| + context_->url_request_context_getter(), oauth_token_getter_.get())); |
| +} |
| + |
| +scoped_ptr<HostSignalingManager> HostProcess::CreateHostSignalingManager() { |
| + DCHECK(!host_id_.empty()); // |ApplyConfig| should already have been run. |
|
Sergey Ulanov
2015/05/07 21:49:55
s/|ApplyConfig|/ApplyConfig()/
FunctionName() vs
John Williams
2015/05/20 00:22:44
Done.
|
| + DCHECK(context_); |
| + DCHECK(oauth_token_getter_); |
| + |
| return HostSignalingManager::Create( |
| this, context_->url_request_context_getter(), xmpp_server_config_, |
| talkgadget_prefix_, host_id_, key_pair_, directory_bot_jid_, |
| - oauth_credentials.Pass(), gcd_device_id_.empty()); |
| + oauth_token_getter_.get(), gcd_rest_client_.get()); |
| } |
| void HostProcess::StartHostIfReady() { |
| @@ -1333,9 +1365,12 @@ void HostProcess::StartHost() { |
| DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| DCHECK(!host_); |
| DCHECK(!host_signaling_manager_); |
| + DCHECK(!gcd_rest_client_); |
| SetState(HOST_STARTED); |
| + oauth_token_getter_ = CreateOAuthTokenGetter(); |
| + gcd_rest_client_ = CreateGcdRestClient(); |
| host_signaling_manager_ = CreateHostSignalingManager(); |
| uint32 network_flags = 0; |
| @@ -1392,9 +1427,14 @@ void HostProcess::StartHost() { |
| this, host_id_, host_signaling_manager_->signal_strategy(), |
| directory_bot_jid_)); |
| - host_status_logger_.reset(new HostStatusLogger( |
| - host_->AsWeakPtr(), ServerLogEntry::ME2ME, |
| - host_signaling_manager_->signal_strategy(), directory_bot_jid_)); |
| + if (using_gcd()) { |
| + // TODO(jrw): Implement logging for GCD hosts. |
| + HOST_LOG << "Logging not implemented for GCD hosts."; |
| + } else { |
| + host_status_logger_.reset(new HostStatusLogger( |
| + host_->AsWeakPtr(), ServerLogEntry::ME2ME, |
| + host_signaling_manager_->signal_strategy(), directory_bot_jid_)); |
| + } |
| // Set up reporting the host status notifications. |
| #if defined(REMOTING_MULTI_PROCESS) |
| @@ -1487,6 +1527,8 @@ void HostProcess::OnHostOfflineReasonAck(bool success) { |
| HOST_LOG << "SendHostOfflineReason " << (success ? "succeeded." : "failed."); |
| host_signaling_manager_.reset(); |
| + gcd_rest_client_.reset(); |
| + oauth_token_getter_.reset(); |
| if (state_ == HOST_GOING_OFFLINE_TO_RESTART) { |
| SetState(HOST_STARTING); |