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

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

Issue 959033004: Remove ClientLogin support from remoting host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « remoting/host/signaling_connector.h ('k') | remoting/remoting_srcs.gypi » ('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 "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "google_apis/google_api_keys.h" 10 #include "google_apis/google_api_keys.h"
11 #include "net/url_request/url_fetcher.h" 11 #include "net/url_request/url_fetcher.h"
12 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
13 #include "remoting/base/logging.h" 13 #include "remoting/base/logging.h"
14 #include "remoting/host/dns_blackhole_checker.h" 14 #include "remoting/host/dns_blackhole_checker.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 namespace { 18 namespace {
19 19
20 // The delay between reconnect attempts will increase exponentially up 20 // The delay between reconnect attempts will increase exponentially up
21 // to the maximum specified here. 21 // to the maximum specified here.
22 const int kMaxReconnectDelaySeconds = 10 * 60; 22 const int kMaxReconnectDelaySeconds = 10 * 60;
23 23
24 } // namespace 24 } // namespace
25 25
26 SignalingConnector::SignalingConnector( 26 SignalingConnector::SignalingConnector(
27 XmppSignalStrategy* signal_strategy, 27 XmppSignalStrategy* signal_strategy,
28 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker, 28 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker,
29 scoped_ptr<OAuthTokenGetter> oauth_token_getter,
29 const base::Closure& auth_failed_callback) 30 const base::Closure& auth_failed_callback)
30 : signal_strategy_(signal_strategy), 31 : signal_strategy_(signal_strategy),
31 auth_failed_callback_(auth_failed_callback), 32 auth_failed_callback_(auth_failed_callback),
32 dns_blackhole_checker_(dns_blackhole_checker.Pass()), 33 dns_blackhole_checker_(dns_blackhole_checker.Pass()),
34 oauth_token_getter_(oauth_token_getter.Pass()),
33 reconnect_attempts_(0) { 35 reconnect_attempts_(0) {
34 DCHECK(!auth_failed_callback_.is_null()); 36 DCHECK(!auth_failed_callback_.is_null());
35 DCHECK(dns_blackhole_checker_.get()); 37 DCHECK(dns_blackhole_checker_.get());
36 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 38 net::NetworkChangeNotifier::AddConnectionTypeObserver(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();
40 } 42 }
41 43
42 SignalingConnector::~SignalingConnector() { 44 SignalingConnector::~SignalingConnector() {
43 signal_strategy_->RemoveListener(this); 45 signal_strategy_->RemoveListener(this);
44 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 46 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
45 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 47 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
46 } 48 }
47 49
48 void SignalingConnector::EnableOAuth(
49 scoped_ptr<OAuthTokenGetter> oauth_token_getter) {
50 oauth_token_getter_ = oauth_token_getter.Pass();
51 }
52
53 void SignalingConnector::OnSignalStrategyStateChange( 50 void SignalingConnector::OnSignalStrategyStateChange(
54 SignalStrategy::State state) { 51 SignalStrategy::State state) {
55 DCHECK(CalledOnValidThread()); 52 DCHECK(CalledOnValidThread());
56 53
57 if (state == SignalStrategy::CONNECTED) { 54 if (state == SignalStrategy::CONNECTED) {
58 HOST_LOG << "Signaling connected."; 55 HOST_LOG << "Signaling connected.";
59 reconnect_attempts_ = 0; 56 reconnect_attempts_ = 0;
60 } else if (state == SignalStrategy::DISCONNECTED) { 57 } else if (state == SignalStrategy::DISCONNECTED) {
61 HOST_LOG << "Signaling disconnected."; 58 HOST_LOG << "Signaling disconnected.";
62 reconnect_attempts_++; 59 reconnect_attempts_++;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 auth_failed_callback_.Run(); 100 auth_failed_callback_.Run();
104 return; 101 return;
105 } else if (status == OAuthTokenGetter::NETWORK_ERROR) { 102 } else if (status == OAuthTokenGetter::NETWORK_ERROR) {
106 OnNetworkError(); 103 OnNetworkError();
107 return; 104 return;
108 } 105 }
109 106
110 DCHECK_EQ(status, OAuthTokenGetter::SUCCESS); 107 DCHECK_EQ(status, OAuthTokenGetter::SUCCESS);
111 HOST_LOG << "Received user info."; 108 HOST_LOG << "Received user info.";
112 109
113 signal_strategy_->SetAuthInfo(user_email, access_token, "oauth2"); 110 signal_strategy_->SetAuthInfo(user_email, access_token);
114 111
115 // Now that we've refreshed the token and verified that it's for the correct 112 // Now that we've refreshed the token and verified that it's for the correct
116 // user account, try to connect using the new token. 113 // user account, try to connect using the new token.
117 DCHECK_EQ(signal_strategy_->GetState(), SignalStrategy::DISCONNECTED); 114 DCHECK_EQ(signal_strategy_->GetState(), SignalStrategy::DISCONNECTED);
118 signal_strategy_->Connect(); 115 signal_strategy_->Connect();
119 } 116 }
120 117
121 void SignalingConnector::OnNetworkError() { 118 void SignalingConnector::OnNetworkError() {
122 DCHECK(CalledOnValidThread()); 119 DCHECK(CalledOnValidThread());
123 reconnect_attempts_++; 120 reconnect_attempts_++;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 165 }
169 166
170 if (signal_strategy_->GetState() == SignalStrategy::DISCONNECTED) { 167 if (signal_strategy_->GetState() == SignalStrategy::DISCONNECTED) {
171 HOST_LOG << "Attempting to connect signaling."; 168 HOST_LOG << "Attempting to connect signaling.";
172 oauth_token_getter_->CallWithToken( 169 oauth_token_getter_->CallWithToken(
173 base::Bind(&SignalingConnector::OnAccessToken, AsWeakPtr())); 170 base::Bind(&SignalingConnector::OnAccessToken, AsWeakPtr()));
174 } 171 }
175 } 172 }
176 173
177 } // namespace remoting 174 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/signaling_connector.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698