| 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 "remoting/host/chromoting_host_context.h" | 9 #include "remoting/host/chromoting_host_context.h" |
| 10 #include "remoting/host/url_request_context.h" | 10 #include "remoting/host/url_request_context.h" |
| 11 | 11 |
| 12 namespace remoting { | 12 namespace remoting { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // The delay between reconnect attempts will increase exponentially up | 16 // The delay between reconnect attempts will increase exponentially up |
| 17 // to the maximum specified here. | 17 // to the maximum specified here. |
| 18 const int kMaxReconnectDelaySeconds = 10 * 60; | 18 const int kMaxReconnectDelaySeconds = 10 * 60; |
| 19 | 19 |
| 20 // Time when we we try to update OAuth token before its expiration. | 20 // Time when we we try to update OAuth token before its expiration. |
| 21 const int kTokenUpdateTimeBeforeExpirySeconds = 60; | 21 const int kTokenUpdateTimeBeforeExpirySeconds = 60; |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 SignalingConnector::OAuthCredentials::OAuthCredentials( | 25 SignalingConnector::OAuthCredentials::OAuthCredentials( |
| 26 const std::string& login_value, | 26 const std::string& login_value, |
| 27 const std::string& refresh_token_value) | 27 const std::string& refresh_token_value, |
| 28 const OAuthClientInfo& client_info_value) |
| 28 : login(login_value), | 29 : login(login_value), |
| 29 refresh_token(refresh_token_value) { | 30 refresh_token(refresh_token_value), |
| 31 client_info(client_info_value) { |
| 30 } | 32 } |
| 31 | 33 |
| 32 SignalingConnector::SignalingConnector(XmppSignalStrategy* signal_strategy) | 34 SignalingConnector::SignalingConnector(XmppSignalStrategy* signal_strategy) |
| 33 : signal_strategy_(signal_strategy), | 35 : signal_strategy_(signal_strategy), |
| 34 reconnect_attempts_(0), | 36 reconnect_attempts_(0), |
| 35 refreshing_oauth_token_(false) { | 37 refreshing_oauth_token_(false) { |
| 36 net::NetworkChangeNotifier::AddOnlineStateObserver(this); | 38 net::NetworkChangeNotifier::AddOnlineStateObserver(this); |
| 37 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 39 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 38 signal_strategy_->AddListener(this); | 40 signal_strategy_->AddListener(this); |
| 39 ScheduleTryReconnect(); | 41 ScheduleTryReconnect(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 LOG(INFO) << "Attempting to connect signaling."; | 154 LOG(INFO) << "Attempting to connect signaling."; |
| 153 signal_strategy_->Connect(); | 155 signal_strategy_->Connect(); |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 } | 158 } |
| 157 | 159 |
| 158 void SignalingConnector::RefreshOAuthToken() { | 160 void SignalingConnector::RefreshOAuthToken() { |
| 159 DCHECK(CalledOnValidThread()); | 161 DCHECK(CalledOnValidThread()); |
| 160 LOG(INFO) << "Refreshing OAuth token."; | 162 LOG(INFO) << "Refreshing OAuth token."; |
| 161 DCHECK(!refreshing_oauth_token_); | 163 DCHECK(!refreshing_oauth_token_); |
| 162 #ifdef OFFICIAL_BUILD | 164 |
| 163 OAuthClientInfo client_info = { | |
| 164 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com", | |
| 165 "Bgur6DFiOMM1h8x-AQpuTQlK" | |
| 166 }; | |
| 167 #else // OFFICIAL_BUILD | |
| 168 OAuthClientInfo client_info = { | |
| 169 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com", | |
| 170 "W2ieEsG-R1gIA4MMurGrgMc_" | |
| 171 }; | |
| 172 #endif // !OFFICIAL_BUILD | |
| 173 refreshing_oauth_token_ = true; | 165 refreshing_oauth_token_ = true; |
| 174 gaia_oauth_client_->RefreshToken( | 166 gaia_oauth_client_->RefreshToken( |
| 175 client_info, oauth_credentials_->refresh_token, 1, this); | 167 oauth_credentials_->client_info, |
| 168 oauth_credentials_->refresh_token, 1, this); |
| 176 } | 169 } |
| 177 | 170 |
| 178 } // namespace remoting | 171 } // namespace remoting |
| OLD | NEW |