| 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" |
| 11 #include "base/timer.h" | 11 #include "base/timer.h" |
| 12 #include "net/base/network_change_notifier.h" | 12 #include "net/base/network_change_notifier.h" |
| 13 #include "remoting/host/gaia_oauth_client.h" | 13 #include "remoting/host/gaia_oauth_client.h" |
| 14 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 14 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 15 | 15 |
| 16 namespace net { |
| 17 class URLRequestContextGetter; |
| 18 } // namespace net |
| 19 |
| 16 namespace remoting { | 20 namespace remoting { |
| 17 | 21 |
| 18 class URLRequestContextGetter; | |
| 19 | |
| 20 // SignalingConnector listens for SignalStrategy status notifications | 22 // SignalingConnector listens for SignalStrategy status notifications |
| 21 // and attempts to keep it connected when possible. When signalling is | 23 // and attempts to keep it connected when possible. When signalling is |
| 22 // not connected it keeps trying to reconnect it until it is | 24 // not connected it keeps trying to reconnect it until it is |
| 23 // connected. It limits connection attempt rate using exponential | 25 // connected. It limits connection attempt rate using exponential |
| 24 // backoff. It also monitors network state and reconnects signalling | 26 // backoff. It also monitors network state and reconnects signalling |
| 25 // whenever online state changes or IP address changes. | 27 // whenever online state changes or IP address changes. |
| 26 class SignalingConnector | 28 class SignalingConnector |
| 27 : public base::SupportsWeakPtr<SignalingConnector>, | 29 : public base::SupportsWeakPtr<SignalingConnector>, |
| 28 public base::NonThreadSafe, | 30 public base::NonThreadSafe, |
| 29 public SignalStrategy::Listener, | 31 public SignalStrategy::Listener, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 OAuthClientInfo client_info; | 50 OAuthClientInfo client_info; |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 // OAuth token is updated refreshed when |oauth_credentials| is | 53 // OAuth token is updated refreshed when |oauth_credentials| is |
| 52 // not NULL. | 54 // not NULL. |
| 53 SignalingConnector(XmppSignalStrategy* signal_strategy); | 55 SignalingConnector(XmppSignalStrategy* signal_strategy); |
| 54 virtual ~SignalingConnector(); | 56 virtual ~SignalingConnector(); |
| 55 | 57 |
| 56 void EnableOAuth(scoped_ptr<OAuthCredentials> oauth_credentials, | 58 void EnableOAuth(scoped_ptr<OAuthCredentials> oauth_credentials, |
| 57 const base::Closure& oauth_failed_callback, | 59 const base::Closure& oauth_failed_callback, |
| 58 URLRequestContextGetter* url_context); | 60 net::URLRequestContextGetter* url_context); |
| 59 | 61 |
| 60 // SignalStrategy::Listener interface. | 62 // SignalStrategy::Listener interface. |
| 61 virtual void OnSignalStrategyStateChange( | 63 virtual void OnSignalStrategyStateChange( |
| 62 SignalStrategy::State state) OVERRIDE; | 64 SignalStrategy::State state) OVERRIDE; |
| 63 | 65 |
| 64 // NetworkChangeNotifier::IPAddressObserver interface. | 66 // NetworkChangeNotifier::IPAddressObserver interface. |
| 65 virtual void OnIPAddressChanged() OVERRIDE; | 67 virtual void OnIPAddressChanged() OVERRIDE; |
| 66 | 68 |
| 67 // NetworkChangeNotifier::OnlineStateObserver interface. | 69 // NetworkChangeNotifier::OnlineStateObserver interface. |
| 68 virtual void OnOnlineStateChanged(bool online) OVERRIDE; | 70 virtual void OnOnlineStateChanged(bool online) OVERRIDE; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 93 base::Time auth_token_expiry_time_; | 95 base::Time auth_token_expiry_time_; |
| 94 | 96 |
| 95 base::OneShotTimer<SignalingConnector> timer_; | 97 base::OneShotTimer<SignalingConnector> timer_; |
| 96 | 98 |
| 97 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); | 99 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); |
| 98 }; | 100 }; |
| 99 | 101 |
| 100 } // namespace remoting | 102 } // namespace remoting |
| 101 | 103 |
| 102 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H | 104 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H |
| OLD | NEW |