| 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 #ifndef REMOTING_HOST_SIGNALING_CONNECTOR_H_ | 5 #ifndef REMOTING_HOST_SIGNALING_CONNECTOR_H_ |
| 6 #define REMOTING_HOST_SIGNALING_CONNECTOR_H_ | 6 #define REMOTING_HOST_SIGNALING_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 public base::NonThreadSafe, | 28 public base::NonThreadSafe, |
| 29 public SignalStrategy::Listener, | 29 public SignalStrategy::Listener, |
| 30 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 30 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 31 public net::NetworkChangeNotifier::IPAddressObserver { | 31 public net::NetworkChangeNotifier::IPAddressObserver { |
| 32 public: | 32 public: |
| 33 // The |auth_failed_callback| is called when authentication fails. | 33 // The |auth_failed_callback| is called when authentication fails. |
| 34 SignalingConnector( | 34 SignalingConnector( |
| 35 XmppSignalStrategy* signal_strategy, | 35 XmppSignalStrategy* signal_strategy, |
| 36 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker, | 36 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker, |
| 37 const base::Closure& auth_failed_callback); | 37 const base::Closure& auth_failed_callback); |
| 38 virtual ~SignalingConnector(); | 38 ~SignalingConnector() override; |
| 39 | 39 |
| 40 // May be called immediately after the constructor to enable OAuth | 40 // May be called immediately after the constructor to enable OAuth |
| 41 // access token updating. | 41 // access token updating. |
| 42 // |oauth_token_getter| must outlive SignalingConnector. | 42 // |oauth_token_getter| must outlive SignalingConnector. |
| 43 void EnableOAuth(OAuthTokenGetter* oauth_token_getter); | 43 void EnableOAuth(OAuthTokenGetter* oauth_token_getter); |
| 44 | 44 |
| 45 // OAuthTokenGetter callback. | 45 // OAuthTokenGetter callback. |
| 46 void OnAccessToken(OAuthTokenGetter::Status status, | 46 void OnAccessToken(OAuthTokenGetter::Status status, |
| 47 const std::string& user_email, | 47 const std::string& user_email, |
| 48 const std::string& access_token); | 48 const std::string& access_token); |
| 49 | 49 |
| 50 // SignalStrategy::Listener interface. | 50 // SignalStrategy::Listener interface. |
| 51 virtual void OnSignalStrategyStateChange( | 51 void OnSignalStrategyStateChange(SignalStrategy::State state) override; |
| 52 SignalStrategy::State state) override; | 52 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; |
| 53 virtual bool OnSignalStrategyIncomingStanza( | |
| 54 const buzz::XmlElement* stanza) override; | |
| 55 | 53 |
| 56 // NetworkChangeNotifier::ConnectionTypeObserver interface. | 54 // NetworkChangeNotifier::ConnectionTypeObserver interface. |
| 57 virtual void OnConnectionTypeChanged( | 55 void OnConnectionTypeChanged( |
| 58 net::NetworkChangeNotifier::ConnectionType type) override; | 56 net::NetworkChangeNotifier::ConnectionType type) override; |
| 59 | 57 |
| 60 // NetworkChangeNotifier::IPAddressObserver interface. | 58 // NetworkChangeNotifier::IPAddressObserver interface. |
| 61 virtual void OnIPAddressChanged() override; | 59 void OnIPAddressChanged() override; |
| 62 | 60 |
| 63 private: | 61 private: |
| 64 void OnNetworkError(); | 62 void OnNetworkError(); |
| 65 void ScheduleTryReconnect(); | 63 void ScheduleTryReconnect(); |
| 66 void ResetAndTryReconnect(); | 64 void ResetAndTryReconnect(); |
| 67 void TryReconnect(); | 65 void TryReconnect(); |
| 68 void OnDnsBlackholeCheckerDone(bool allow); | 66 void OnDnsBlackholeCheckerDone(bool allow); |
| 69 | 67 |
| 70 XmppSignalStrategy* signal_strategy_; | 68 XmppSignalStrategy* signal_strategy_; |
| 71 base::Closure auth_failed_callback_; | 69 base::Closure auth_failed_callback_; |
| 72 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker_; | 70 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker_; |
| 73 | 71 |
| 74 OAuthTokenGetter* oauth_token_getter_; | 72 OAuthTokenGetter* oauth_token_getter_; |
| 75 | 73 |
| 76 // Number of times we tried to connect without success. | 74 // Number of times we tried to connect without success. |
| 77 int reconnect_attempts_; | 75 int reconnect_attempts_; |
| 78 | 76 |
| 79 base::OneShotTimer<SignalingConnector> timer_; | 77 base::OneShotTimer<SignalingConnector> timer_; |
| 80 | 78 |
| 81 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); | 79 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 } // namespace remoting | 82 } // namespace remoting |
| 85 | 83 |
| 86 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H_ | 84 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H_ |
| OLD | NEW |