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) |
38 { | |
Sergey Ulanov
2012/04/19 01:57:32
Looks like this was unintentional change
Alpha Left Google
2012/04/20 22:13:50
Done.
| |
36 net::NetworkChangeNotifier::AddOnlineStateObserver(this); | 39 net::NetworkChangeNotifier::AddOnlineStateObserver(this); |
37 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 40 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
38 signal_strategy_->AddListener(this); | 41 signal_strategy_->AddListener(this); |
39 ScheduleTryReconnect(); | 42 ScheduleTryReconnect(); |
40 } | 43 } |
41 | 44 |
42 SignalingConnector::~SignalingConnector() { | 45 SignalingConnector::~SignalingConnector() { |
43 signal_strategy_->RemoveListener(this); | 46 signal_strategy_->RemoveListener(this); |
44 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); | 47 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); |
45 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 48 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 LOG(INFO) << "Attempting to connect signaling."; | 155 LOG(INFO) << "Attempting to connect signaling."; |
153 signal_strategy_->Connect(); | 156 signal_strategy_->Connect(); |
154 } | 157 } |
155 } | 158 } |
156 } | 159 } |
157 | 160 |
158 void SignalingConnector::RefreshOAuthToken() { | 161 void SignalingConnector::RefreshOAuthToken() { |
159 DCHECK(CalledOnValidThread()); | 162 DCHECK(CalledOnValidThread()); |
160 LOG(INFO) << "Refreshing OAuth token."; | 163 LOG(INFO) << "Refreshing OAuth token."; |
161 DCHECK(!refreshing_oauth_token_); | 164 DCHECK(!refreshing_oauth_token_); |
162 #ifdef OFFICIAL_BUILD | 165 |
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; | 166 refreshing_oauth_token_ = true; |
174 gaia_oauth_client_->RefreshToken( | 167 gaia_oauth_client_->RefreshToken( |
175 client_info, oauth_credentials_->refresh_token, 1, this); | 168 oauth_credentials_->client_info, |
169 oauth_credentials_->refresh_token, 1, this); | |
176 } | 170 } |
177 | 171 |
178 } // namespace remoting | 172 } // namespace remoting |
OLD | NEW |