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 be25fa363bd9e0e28aa3ef1fa00777313f1a5ae9..819ae47c8bb1e40e96d7308af6fa60a405198dc6 100644 |
| --- a/remoting/host/remoting_me2me_host.cc |
| +++ b/remoting/host/remoting_me2me_host.cc |
| @@ -36,6 +36,7 @@ |
| #include "remoting/host/composite_host_config.h" |
| #include "remoting/host/constants.h" |
| #include "remoting/host/desktop_environment.h" |
| +#include "remoting/host/dns_blackhole_checker.h" |
| #include "remoting/host/event_executor.h" |
| #include "remoting/host/heartbeat_sender.h" |
| #include "remoting/host/host_config.h" |
| @@ -378,6 +379,11 @@ class HostProcess |
| &bool_value)) { |
| OnCurtainPolicyUpdate(bool_value); |
| } |
| + if (policies->GetString( |
| + policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName, |
| + &string_value)) { |
| + OnHostTalkGadgetPrefixPolicyUpdate(string_value); |
| + } |
| } |
| void OnHostDomainPolicyUpdate(const std::string& host_domain) { |
| @@ -445,47 +451,64 @@ class HostProcess |
| #endif |
| } |
| + void OnHostTalkGadgetPrefixPolicyUpdate( |
| + const std::string& talkgadget_prefix) { |
| + if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
| + context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( |
| + &HostProcess::OnHostTalkGadgetPrefixPolicyUpdate, |
| + base::Unretained(this), talkgadget_prefix)); |
| + return; |
| + } |
| + |
| + if (talkgadget_prefix != talkgadget_prefix_) { |
| + LOG(INFO) << "Restarting host due to updated talkgadget policy:"; |
| + talkgadget_prefix_ = talkgadget_prefix; |
| + RestartHost(); |
| + } |
| + } |
| + |
| void StartHost() { |
| DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| DCHECK(!host_); |
| + DCHECK(!signal_strategy_.get()); |
| + DCHECK(!dns_blackhole_checker_.get()); |
| if (shutting_down_) |
| return; |
| - if (!signal_strategy_.get()) { |
| - signal_strategy_.reset( |
| - new XmppSignalStrategy(context_->url_request_context_getter(), |
| - xmpp_login_, xmpp_auth_token_, |
| - xmpp_auth_service_)); |
| + signal_strategy_.reset( |
| + new XmppSignalStrategy(context_->url_request_context_getter(), |
| + xmpp_login_, xmpp_auth_token_, |
| + xmpp_auth_service_)); |
| - signaling_connector_.reset(new SignalingConnector( |
| - signal_strategy_.get(), |
| - base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); |
| + dns_blackhole_checker_.reset( |
| + new DnsBlackholeChecker(context_.get(), talkgadget_prefix_)); |
| - if (!oauth_refresh_token_.empty()) { |
| - OAuthClientInfo client_info = { |
| - kUnofficialOAuth2ClientId, |
| - kUnofficialOAuth2ClientSecret |
| - }; |
| + signaling_connector_.reset(new SignalingConnector( |
| + signal_strategy_.get(), context_.get(), dns_blackhole_checker_.get(), |
| + base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); |
| + |
| + if (!oauth_refresh_token_.empty()) { |
| + OAuthClientInfo client_info = { |
| + kUnofficialOAuth2ClientId, |
| + kUnofficialOAuth2ClientSecret |
| + }; |
| #ifdef OFFICIAL_BUILD |
| - if (oauth_use_official_client_id_) { |
| - OAuthClientInfo official_client_info = { |
| - kOfficialOAuth2ClientId, |
| - kOfficialOAuth2ClientSecret |
| - }; |
| - |
| - client_info = official_client_info; |
| - } |
| -#endif // OFFICIAL_BUILD |
| + if (oauth_use_official_client_id_) { |
| + OAuthClientInfo official_client_info = { |
| + kOfficialOAuth2ClientId, |
| + kOfficialOAuth2ClientSecret |
| + }; |
| - scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( |
| - new SignalingConnector::OAuthCredentials( |
| - xmpp_login_, oauth_refresh_token_, client_info)); |
| - signaling_connector_->EnableOAuth( |
| - oauth_credentials.Pass(), |
| - context_->url_request_context_getter()); |
| + client_info = official_client_info; |
| } |
| +#endif // OFFICIAL_BUILD |
| + |
| + scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( |
| + new SignalingConnector::OAuthCredentials( |
| + xmpp_login_, oauth_refresh_token_, client_info)); |
| + signaling_connector_->EnableOAuth(oauth_credentials.Pass()); |
| } |
| if (!desktop_environment_.get()) { |
| @@ -561,9 +584,7 @@ class HostProcess |
| restarting_ = false; |
| host_ = NULL; |
| - log_to_server_.reset(); |
| - host_event_logger_.reset(); |
| - heartbeat_sender_.reset(); |
| + ResetHost(); |
| StartHost(); |
| } |
| @@ -589,13 +610,20 @@ class HostProcess |
| // Destroy networking objects while we are on the network thread. |
| host_ = NULL; |
| + ResetHost(); |
| + |
| + message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| + } |
| + |
| + void ResetHost() { |
| + DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| + |
| host_event_logger_.reset(); |
| log_to_server_.reset(); |
| heartbeat_sender_.reset(); |
| signaling_connector_.reset(); |
| + dns_blackhole_checker_.reset(); |
| signal_strategy_.reset(); |
| - |
| - message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| } |
| MessageLoop message_loop_; |
| @@ -618,6 +646,7 @@ class HostProcess |
| scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
| bool allow_nat_traversal_; |
| + std::string talkgadget_prefix_; |
| scoped_ptr<base::files::FilePathWatcher> config_watcher_; |
|
Sergey Ulanov
2012/08/30 18:05:01
Please add an empty line above this one to separat
garykac
2012/08/31 18:28:23
Done.
|
| scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_; |
| @@ -625,6 +654,7 @@ class HostProcess |
| bool shutting_down_; |
| scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| + scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker_; |
|
Sergey Ulanov
2012/08/30 18:05:01
We don't really use this thing here. Just pass own
garykac
2012/08/31 18:28:23
Done.
|
| scoped_ptr<SignalingConnector> signaling_connector_; |
| scoped_ptr<DesktopEnvironment> desktop_environment_; |
| scoped_ptr<HeartbeatSender> heartbeat_sender_; |