| 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 "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 OAuthTokenGetter* oauth_token_getter, |
| 30 const base::Closure& auth_failed_callback) | 30 const base::Closure& auth_failed_callback) |
| 31 : signal_strategy_(signal_strategy), | 31 : signal_strategy_(signal_strategy), |
| 32 auth_failed_callback_(auth_failed_callback), | 32 auth_failed_callback_(auth_failed_callback), |
| 33 dns_blackhole_checker_(dns_blackhole_checker.Pass()), | 33 dns_blackhole_checker_(dns_blackhole_checker.Pass()), |
| 34 oauth_token_getter_(oauth_token_getter.Pass()), | 34 oauth_token_getter_(oauth_token_getter), |
| 35 reconnect_attempts_(0) { | 35 reconnect_attempts_(0) { |
| 36 DCHECK(!auth_failed_callback_.is_null()); | 36 DCHECK(!auth_failed_callback_.is_null()); |
| 37 DCHECK(dns_blackhole_checker_.get()); | 37 DCHECK(dns_blackhole_checker_.get()); |
| 38 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 38 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 39 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 39 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 40 signal_strategy_->AddListener(this); | 40 signal_strategy_->AddListener(this); |
| 41 ScheduleTryReconnect(); | 41 ScheduleTryReconnect(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 SignalingConnector::~SignalingConnector() { | 44 SignalingConnector::~SignalingConnector() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 if (signal_strategy_->GetState() == SignalStrategy::DISCONNECTED) { | 167 if (signal_strategy_->GetState() == SignalStrategy::DISCONNECTED) { |
| 168 HOST_LOG << "Attempting to connect signaling."; | 168 HOST_LOG << "Attempting to connect signaling."; |
| 169 oauth_token_getter_->CallWithToken( | 169 oauth_token_getter_->CallWithToken( |
| 170 base::Bind(&SignalingConnector::OnAccessToken, AsWeakPtr())); | 170 base::Bind(&SignalingConnector::OnAccessToken, AsWeakPtr())); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace remoting | 174 } // namespace remoting |
| OLD | NEW |