| OLD | NEW |
| 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 #include "remoting/host/signaling_connector.h" | 5 #include "remoting/host/signaling_connector.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "google_apis/google_api_keys.h" | 9 #include "google_apis/google_api_keys.h" |
| 10 #include "net/url_request/url_fetcher.h" | 10 #include "net/url_request/url_fetcher.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker, | 37 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker, |
| 38 const base::Closure& auth_failed_callback) | 38 const base::Closure& auth_failed_callback) |
| 39 : signal_strategy_(signal_strategy), | 39 : signal_strategy_(signal_strategy), |
| 40 url_request_context_getter_(url_request_context_getter), | 40 url_request_context_getter_(url_request_context_getter), |
| 41 auth_failed_callback_(auth_failed_callback), | 41 auth_failed_callback_(auth_failed_callback), |
| 42 dns_blackhole_checker_(dns_blackhole_checker.Pass()), | 42 dns_blackhole_checker_(dns_blackhole_checker.Pass()), |
| 43 reconnect_attempts_(0), | 43 reconnect_attempts_(0), |
| 44 refreshing_oauth_token_(false) { | 44 refreshing_oauth_token_(false) { |
| 45 DCHECK(!auth_failed_callback_.is_null()); | 45 DCHECK(!auth_failed_callback_.is_null()); |
| 46 DCHECK(dns_blackhole_checker_.get()); | 46 DCHECK(dns_blackhole_checker_.get()); |
| 47 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 47 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
| 48 net::NetworkChangeNotifier::AddIPAddressObserver(this); | |
| 49 signal_strategy_->AddListener(this); | 48 signal_strategy_->AddListener(this); |
| 50 ScheduleTryReconnect(); | 49 ScheduleTryReconnect(); |
| 51 } | 50 } |
| 52 | 51 |
| 53 SignalingConnector::~SignalingConnector() { | 52 SignalingConnector::~SignalingConnector() { |
| 54 signal_strategy_->RemoveListener(this); | 53 signal_strategy_->RemoveListener(this); |
| 55 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 54 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| 56 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 void SignalingConnector::EnableOAuth( | 57 void SignalingConnector::EnableOAuth( |
| 60 scoped_ptr<OAuthCredentials> oauth_credentials) { | 58 scoped_ptr<OAuthCredentials> oauth_credentials) { |
| 61 oauth_credentials_ = oauth_credentials.Pass(); | 59 oauth_credentials_ = oauth_credentials.Pass(); |
| 62 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient( | 60 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient( |
| 63 gaia::kGaiaOAuth2Url, url_request_context_getter_)); | 61 gaia::kGaiaOAuth2Url, url_request_context_getter_)); |
| 64 } | 62 } |
| 65 | 63 |
| 66 void SignalingConnector::OnSignalStrategyStateChange( | 64 void SignalingConnector::OnSignalStrategyStateChange( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 82 ScheduleTryReconnect(); | 80 ScheduleTryReconnect(); |
| 83 } | 81 } |
| 84 } | 82 } |
| 85 } | 83 } |
| 86 | 84 |
| 87 bool SignalingConnector::OnSignalStrategyIncomingStanza( | 85 bool SignalingConnector::OnSignalStrategyIncomingStanza( |
| 88 const buzz::XmlElement* stanza) { | 86 const buzz::XmlElement* stanza) { |
| 89 return false; | 87 return false; |
| 90 } | 88 } |
| 91 | 89 |
| 92 void SignalingConnector::OnConnectionTypeChanged( | 90 void SignalingConnector::OnNetworkChanged( |
| 93 net::NetworkChangeNotifier::ConnectionType type) { | 91 net::NetworkChangeNotifier::ConnectionType type) { |
| 94 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
| 95 if (type != net::NetworkChangeNotifier::CONNECTION_NONE) { | 93 if (type != net::NetworkChangeNotifier::CONNECTION_NONE) { |
| 96 LOG(INFO) << "Network state changed to online."; | 94 LOG(INFO) << "Network state changed to online."; |
| 97 ResetAndTryReconnect(); | 95 ResetAndTryReconnect(); |
| 98 } | 96 } |
| 99 } | 97 } |
| 100 | 98 |
| 101 void SignalingConnector::OnIPAddressChanged() { | |
| 102 DCHECK(CalledOnValidThread()); | |
| 103 LOG(INFO) << "IP address has changed."; | |
| 104 ResetAndTryReconnect(); | |
| 105 } | |
| 106 | |
| 107 void SignalingConnector::OnGetTokensResponse(const std::string& user_email, | 99 void SignalingConnector::OnGetTokensResponse(const std::string& user_email, |
| 108 const std::string& access_token, | 100 const std::string& access_token, |
| 109 int expires_seconds) { | 101 int expires_seconds) { |
| 110 NOTREACHED(); | 102 NOTREACHED(); |
| 111 } | 103 } |
| 112 | 104 |
| 113 void SignalingConnector::OnRefreshTokenResponse( | 105 void SignalingConnector::OnRefreshTokenResponse( |
| 114 const std::string& access_token, | 106 const std::string& access_token, |
| 115 int expires_seconds) { | 107 int expires_seconds) { |
| 116 DCHECK(CalledOnValidThread()); | 108 DCHECK(CalledOnValidThread()); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // is not required when getting access tokens. | 224 // is not required when getting access tokens. |
| 233 "" | 225 "" |
| 234 }; | 226 }; |
| 235 | 227 |
| 236 refreshing_oauth_token_ = true; | 228 refreshing_oauth_token_ = true; |
| 237 gaia_oauth_client_->RefreshToken( | 229 gaia_oauth_client_->RefreshToken( |
| 238 client_info, oauth_credentials_->refresh_token, 1, this); | 230 client_info, oauth_credentials_->refresh_token, 1, this); |
| 239 } | 231 } |
| 240 | 232 |
| 241 } // namespace remoting | 233 } // namespace remoting |
| OLD | NEW |