Chromium Code Reviews| 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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 86 } |
| 87 | 87 |
| 88 void SignalingConnector::OnOnlineStateChanged(bool online) { | 88 void SignalingConnector::OnOnlineStateChanged(bool online) { |
| 89 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
| 90 if (online) { | 90 if (online) { |
| 91 LOG(INFO) << "Network state changed to online."; | 91 LOG(INFO) << "Network state changed to online."; |
| 92 ResetAndTryReconnect(); | 92 ResetAndTryReconnect(); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 void SignalingConnector::OnRefreshTokenResponse(const std::string& access_token, | 96 void SignalingConnector::OnRefreshTokenResponse(const std::string& email, |
| 97 const std::string& access_token, | |
| 97 int expires_seconds) { | 98 int expires_seconds) { |
| 98 DCHECK(CalledOnValidThread()); | 99 DCHECK(CalledOnValidThread()); |
| 99 DCHECK(oauth_credentials_.get()); | 100 DCHECK(oauth_credentials_.get()); |
| 100 LOG(INFO) << "Received OAuth token."; | 101 LOG(INFO) << "Received OAuth token."; |
| 102 | |
| 103 if (email != oauth_credentials_->login) { | |
| 104 LOG(ERROR) << "User email doesn't match expected value. " | |
| 105 "The OAuth token was issued for a different account."; | |
|
Wez
2012/05/16 23:00:07
Suggest "OAuth token and email address do not refe
Sergey Ulanov
2012/05/17 00:38:11
Done.
| |
| 106 auth_failed_callback_.Run(); | |
| 107 return; | |
| 108 } | |
| 109 | |
| 101 refreshing_oauth_token_ = false; | 110 refreshing_oauth_token_ = false; |
| 102 auth_token_expiry_time_ = base::Time::Now() + | 111 auth_token_expiry_time_ = base::Time::Now() + |
| 103 base::TimeDelta::FromSeconds(expires_seconds) - | 112 base::TimeDelta::FromSeconds(expires_seconds) - |
| 104 base::TimeDelta::FromSeconds(kTokenUpdateTimeBeforeExpirySeconds); | 113 base::TimeDelta::FromSeconds(kTokenUpdateTimeBeforeExpirySeconds); |
| 105 signal_strategy_->SetAuthInfo(oauth_credentials_->login, | 114 signal_strategy_->SetAuthInfo(oauth_credentials_->login, |
| 106 access_token, "oauth2"); | 115 access_token, "oauth2"); |
| 107 | 116 |
| 108 // Now that we've got the new token, try to connect using it. | 117 // Now that we've got the new token, try to connect using it. |
| 109 DCHECK_EQ(signal_strategy_->GetState(), SignalStrategy::DISCONNECTED); | 118 DCHECK_EQ(signal_strategy_->GetState(), SignalStrategy::DISCONNECTED); |
| 110 signal_strategy_->Connect(); | 119 signal_strategy_->Connect(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 LOG(INFO) << "Refreshing OAuth token."; | 174 LOG(INFO) << "Refreshing OAuth token."; |
| 166 DCHECK(!refreshing_oauth_token_); | 175 DCHECK(!refreshing_oauth_token_); |
| 167 | 176 |
| 168 refreshing_oauth_token_ = true; | 177 refreshing_oauth_token_ = true; |
| 169 gaia_oauth_client_->RefreshToken( | 178 gaia_oauth_client_->RefreshToken( |
| 170 oauth_credentials_->client_info, | 179 oauth_credentials_->client_info, |
| 171 oauth_credentials_->refresh_token, this); | 180 oauth_credentials_->refresh_token, this); |
| 172 } | 181 } |
| 173 | 182 |
| 174 } // namespace remoting | 183 } // namespace remoting |
| OLD | NEW |