Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: remoting/host/signaling_connector.cc

Issue 10388226: This broke M20 build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/signaling_connector.h ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 SignalingConnector::~SignalingConnector() { 48 SignalingConnector::~SignalingConnector() {
49 signal_strategy_->RemoveListener(this); 49 signal_strategy_->RemoveListener(this);
50 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 50 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
51 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 51 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
52 } 52 }
53 53
54 void SignalingConnector::EnableOAuth( 54 void SignalingConnector::EnableOAuth(
55 scoped_ptr<OAuthCredentials> oauth_credentials, 55 scoped_ptr<OAuthCredentials> oauth_credentials,
56 net::URLRequestContextGetter* url_context) { 56 net::URLRequestContextGetter* url_context) {
57 oauth_credentials_ = oauth_credentials.Pass(); 57 oauth_credentials_ = oauth_credentials.Pass();
58 gaia_oauth_client_.reset(new GaiaOAuthClient( 58 gaia_oauth_client_.reset(new GaiaOAuthClient(kGaiaOAuth2Url, url_context));
59 OAuthProviderInfo::GetDefault(), url_context));
60 } 59 }
61 60
62 void SignalingConnector::OnSignalStrategyStateChange( 61 void SignalingConnector::OnSignalStrategyStateChange(
63 SignalStrategy::State state) { 62 SignalStrategy::State state) {
64 DCHECK(CalledOnValidThread()); 63 DCHECK(CalledOnValidThread());
65 64
66 if (state == SignalStrategy::CONNECTED) { 65 if (state == SignalStrategy::CONNECTED) {
67 LOG(INFO) << "Signaling connected."; 66 LOG(INFO) << "Signaling connected.";
68 reconnect_attempts_ = 0; 67 reconnect_attempts_ = 0;
69 } else if (state == SignalStrategy::DISCONNECTED) { 68 } else if (state == SignalStrategy::DISCONNECTED) {
(...skipping 17 matching lines...) Expand all
87 } 86 }
88 87
89 void SignalingConnector::OnOnlineStateChanged(bool online) { 88 void SignalingConnector::OnOnlineStateChanged(bool online) {
90 DCHECK(CalledOnValidThread()); 89 DCHECK(CalledOnValidThread());
91 if (online) { 90 if (online) {
92 LOG(INFO) << "Network state changed to online."; 91 LOG(INFO) << "Network state changed to online.";
93 ResetAndTryReconnect(); 92 ResetAndTryReconnect();
94 } 93 }
95 } 94 }
96 95
97 void SignalingConnector::OnRefreshTokenResponse(const std::string& user_email, 96 void SignalingConnector::OnRefreshTokenResponse(const std::string& access_token,
98 const std::string& access_token,
99 int expires_seconds) { 97 int expires_seconds) {
100 DCHECK(CalledOnValidThread()); 98 DCHECK(CalledOnValidThread());
101 DCHECK(oauth_credentials_.get()); 99 DCHECK(oauth_credentials_.get());
102 LOG(INFO) << "Received OAuth token."; 100 LOG(INFO) << "Received OAuth token.";
103
104 if (user_email != oauth_credentials_->login) {
105 LOG(ERROR) << "OAuth token and email address do not refer to "
106 "the same account.";
107 auth_failed_callback_.Run();
108 return;
109 }
110
111 refreshing_oauth_token_ = false; 101 refreshing_oauth_token_ = false;
112 auth_token_expiry_time_ = base::Time::Now() + 102 auth_token_expiry_time_ = base::Time::Now() +
113 base::TimeDelta::FromSeconds(expires_seconds) - 103 base::TimeDelta::FromSeconds(expires_seconds) -
114 base::TimeDelta::FromSeconds(kTokenUpdateTimeBeforeExpirySeconds); 104 base::TimeDelta::FromSeconds(kTokenUpdateTimeBeforeExpirySeconds);
115 signal_strategy_->SetAuthInfo(oauth_credentials_->login, 105 signal_strategy_->SetAuthInfo(oauth_credentials_->login,
116 access_token, "oauth2"); 106 access_token, "oauth2");
117 107
118 // Now that we've got the new token, try to connect using it. 108 // Now that we've got the new token, try to connect using it.
119 DCHECK_EQ(signal_strategy_->GetState(), SignalStrategy::DISCONNECTED); 109 DCHECK_EQ(signal_strategy_->GetState(), SignalStrategy::DISCONNECTED);
120 signal_strategy_->Connect(); 110 signal_strategy_->Connect();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 LOG(INFO) << "Refreshing OAuth token."; 165 LOG(INFO) << "Refreshing OAuth token.";
176 DCHECK(!refreshing_oauth_token_); 166 DCHECK(!refreshing_oauth_token_);
177 167
178 refreshing_oauth_token_ = true; 168 refreshing_oauth_token_ = true;
179 gaia_oauth_client_->RefreshToken( 169 gaia_oauth_client_->RefreshToken(
180 oauth_credentials_->client_info, 170 oauth_credentials_->client_info,
181 oauth_credentials_->refresh_token, this); 171 oauth_credentials_->refresh_token, this);
182 } 172 }
183 173
184 } // namespace remoting 174 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/signaling_connector.h ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698