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

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

Issue 9147026: API for connection type (Ethernet/WIFI/WWAN ...) in NetworkChangeNotifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review comments 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
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 #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 { 16 namespace net {
17 class URLRequestContextGetter; 17 class URLRequestContextGetter;
18 } // namespace net 18 } // namespace net
19 19
20 namespace remoting { 20 namespace remoting {
21 21
22 // SignalingConnector listens for SignalStrategy status notifications 22 // SignalingConnector listens for SignalStrategy status notifications
23 // and attempts to keep it connected when possible. When signalling is 23 // and attempts to keep it connected when possible. When signalling is
24 // not connected it keeps trying to reconnect it until it is 24 // not connected it keeps trying to reconnect it until it is
25 // connected. It limits connection attempt rate using exponential 25 // connected. It limits connection attempt rate using exponential
26 // backoff. It also monitors network state and reconnects signalling 26 // backoff. It also monitors network state and reconnects signalling
27 // whenever online state changes or IP address changes. 27 // whenever connection type changes or IP address changes.
28 class SignalingConnector 28 class SignalingConnector
29 : public base::SupportsWeakPtr<SignalingConnector>, 29 : public base::SupportsWeakPtr<SignalingConnector>,
30 public base::NonThreadSafe, 30 public base::NonThreadSafe,
31 public SignalStrategy::Listener, 31 public SignalStrategy::Listener,
32 public net::NetworkChangeNotifier::OnlineStateObserver, 32 public net::NetworkChangeNotifier::ConnectionTypeObserver,
33 public net::NetworkChangeNotifier::IPAddressObserver, 33 public net::NetworkChangeNotifier::IPAddressObserver,
34 public GaiaOAuthClient::Delegate { 34 public GaiaOAuthClient::Delegate {
35 public: 35 public:
36 // This structure contains information required to perform 36 // This structure contains information required to perform
37 // authentication to OAuth2. 37 // authentication to OAuth2.
38 struct OAuthCredentials { 38 struct OAuthCredentials {
39 OAuthCredentials(const std::string& login_value, 39 OAuthCredentials(const std::string& login_value,
40 const std::string& refresh_token_value, 40 const std::string& refresh_token_value,
41 const OAuthClientInfo& client_info); 41 const OAuthClientInfo& client_info);
42 42
(...skipping 16 matching lines...) Expand all
59 const base::Closure& oauth_failed_callback, 59 const base::Closure& oauth_failed_callback,
60 net::URLRequestContextGetter* url_context); 60 net::URLRequestContextGetter* url_context);
61 61
62 // SignalStrategy::Listener interface. 62 // SignalStrategy::Listener interface.
63 virtual void OnSignalStrategyStateChange( 63 virtual void OnSignalStrategyStateChange(
64 SignalStrategy::State state) OVERRIDE; 64 SignalStrategy::State state) OVERRIDE;
65 65
66 // NetworkChangeNotifier::IPAddressObserver interface. 66 // NetworkChangeNotifier::IPAddressObserver interface.
67 virtual void OnIPAddressChanged() OVERRIDE; 67 virtual void OnIPAddressChanged() OVERRIDE;
68 68
69 // NetworkChangeNotifier::OnlineStateObserver interface. 69 // NetworkChangeNotifier::ConnectionTypeObserver interface.
70 virtual void OnOnlineStateChanged(bool online) OVERRIDE; 70 virtual void OnConnectionTypeChanged(
71 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
71 72
72 // GaiaOAuthClient::Delegate interface. 73 // GaiaOAuthClient::Delegate interface.
73 virtual void OnRefreshTokenResponse(const std::string& access_token, 74 virtual void OnRefreshTokenResponse(const std::string& access_token,
74 int expires_seconds) OVERRIDE; 75 int expires_seconds) OVERRIDE;
75 virtual void OnOAuthError() OVERRIDE; 76 virtual void OnOAuthError() OVERRIDE;
76 virtual void OnNetworkError(int response_code) OVERRIDE; 77 virtual void OnNetworkError(int response_code) OVERRIDE;
77 78
78 private: 79 private:
79 void ScheduleTryReconnect(); 80 void ScheduleTryReconnect();
80 void ResetAndTryReconnect(); 81 void ResetAndTryReconnect();
(...skipping 14 matching lines...) Expand all
95 base::Time auth_token_expiry_time_; 96 base::Time auth_token_expiry_time_;
96 97
97 base::OneShotTimer<SignalingConnector> timer_; 98 base::OneShotTimer<SignalingConnector> timer_;
98 99
99 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); 100 DISALLOW_COPY_AND_ASSIGN(SignalingConnector);
100 }; 101 };
101 102
102 } // namespace remoting 103 } // namespace remoting
103 104
104 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H 105 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698