| 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/gaia/gaia_urls.h" | |
| 10 #include "google_apis/google_api_keys.h" | 9 #include "google_apis/google_api_keys.h" |
| 11 #include "net/url_request/url_fetcher.h" | 10 #include "net/url_request/url_fetcher.h" |
| 12 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
| 13 #include "remoting/host/dns_blackhole_checker.h" | 12 #include "remoting/host/dns_blackhole_checker.h" |
| 14 | 13 |
| 15 namespace remoting { | 14 namespace remoting { |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 // The delay between reconnect attempts will increase exponentially up | 18 // The delay between reconnect attempts will increase exponentially up |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 SignalingConnector::~SignalingConnector() { | 53 SignalingConnector::~SignalingConnector() { |
| 55 signal_strategy_->RemoveListener(this); | 54 signal_strategy_->RemoveListener(this); |
| 56 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 55 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 57 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 56 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 58 } | 57 } |
| 59 | 58 |
| 60 void SignalingConnector::EnableOAuth( | 59 void SignalingConnector::EnableOAuth( |
| 61 scoped_ptr<OAuthCredentials> oauth_credentials) { | 60 scoped_ptr<OAuthCredentials> oauth_credentials) { |
| 62 oauth_credentials_ = oauth_credentials.Pass(); | 61 oauth_credentials_ = oauth_credentials.Pass(); |
| 63 gaia_oauth_client_.reset( | 62 gaia_oauth_client_.reset( |
| 64 new gaia::GaiaOAuthClient(GaiaUrls::GetInstance()->oauth2_token_url(), | 63 new gaia::GaiaOAuthClient(url_request_context_getter_.get())); |
| 65 url_request_context_getter_.get())); | |
| 66 } | 64 } |
| 67 | 65 |
| 68 void SignalingConnector::OnSignalStrategyStateChange( | 66 void SignalingConnector::OnSignalStrategyStateChange( |
| 69 SignalStrategy::State state) { | 67 SignalStrategy::State state) { |
| 70 DCHECK(CalledOnValidThread()); | 68 DCHECK(CalledOnValidThread()); |
| 71 | 69 |
| 72 if (state == SignalStrategy::CONNECTED) { | 70 if (state == SignalStrategy::CONNECTED) { |
| 73 LOG(INFO) << "Signaling connected."; | 71 LOG(INFO) << "Signaling connected."; |
| 74 reconnect_attempts_ = 0; | 72 reconnect_attempts_ = 0; |
| 75 } else if (state == SignalStrategy::DISCONNECTED) { | 73 } else if (state == SignalStrategy::DISCONNECTED) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 230 |
| 233 gaia::OAuthClientInfo client_info = { | 231 gaia::OAuthClientInfo client_info = { |
| 234 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING), | 232 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING), |
| 235 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING), | 233 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING), |
| 236 // Redirect URL is only used when getting tokens from auth code. It | 234 // Redirect URL is only used when getting tokens from auth code. It |
| 237 // is not required when getting access tokens. | 235 // is not required when getting access tokens. |
| 238 "" | 236 "" |
| 239 }; | 237 }; |
| 240 | 238 |
| 241 refreshing_oauth_token_ = true; | 239 refreshing_oauth_token_ = true; |
| 240 std::vector<std::string> empty_scope_list; // (Use scope from refresh token.) |
| 242 gaia_oauth_client_->RefreshToken( | 241 gaia_oauth_client_->RefreshToken( |
| 243 client_info, oauth_credentials_->refresh_token, 1, this); | 242 client_info, oauth_credentials_->refresh_token, empty_scope_list, |
| 243 1, this); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace remoting | 246 } // namespace remoting |
| OLD | NEW |