| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // The user's account name (i.e. their email address). | 43 // The user's account name (i.e. their email address). |
| 44 std::string login; | 44 std::string login; |
| 45 | 45 |
| 46 // Token delegating authority to us to act as the user. | 46 // Token delegating authority to us to act as the user. |
| 47 std::string refresh_token; | 47 std::string refresh_token; |
| 48 | 48 |
| 49 // Credentials identifying the application to OAuth. | 49 // Credentials identifying the application to OAuth. |
| 50 OAuthClientInfo client_info; | 50 OAuthClientInfo client_info; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // OAuth token is updated refreshed when |oauth_credentials| is | 53 // The |auth_failed_callback| is called when authentication fails. |
| 54 // not NULL. | 54 SignalingConnector(XmppSignalStrategy* signal_strategy, |
| 55 SignalingConnector(XmppSignalStrategy* signal_strategy); | 55 const base::Closure& auth_failed_callback); |
| 56 virtual ~SignalingConnector(); | 56 virtual ~SignalingConnector(); |
| 57 | 57 |
| 58 // May be called immediately after the constructor to enable OAuth |
| 59 // access token updating. |
| 58 void EnableOAuth(scoped_ptr<OAuthCredentials> oauth_credentials, | 60 void EnableOAuth(scoped_ptr<OAuthCredentials> oauth_credentials, |
| 59 const base::Closure& oauth_failed_callback, | |
| 60 net::URLRequestContextGetter* url_context); | 61 net::URLRequestContextGetter* url_context); |
| 61 | 62 |
| 62 // SignalStrategy::Listener interface. | 63 // SignalStrategy::Listener interface. |
| 63 virtual void OnSignalStrategyStateChange( | 64 virtual void OnSignalStrategyStateChange( |
| 64 SignalStrategy::State state) OVERRIDE; | 65 SignalStrategy::State state) OVERRIDE; |
| 65 | 66 |
| 66 // NetworkChangeNotifier::IPAddressObserver interface. | 67 // NetworkChangeNotifier::IPAddressObserver interface. |
| 67 virtual void OnIPAddressChanged() OVERRIDE; | 68 virtual void OnIPAddressChanged() OVERRIDE; |
| 68 | 69 |
| 69 // NetworkChangeNotifier::OnlineStateObserver interface. | 70 // NetworkChangeNotifier::OnlineStateObserver interface. |
| 70 virtual void OnOnlineStateChanged(bool online) OVERRIDE; | 71 virtual void OnOnlineStateChanged(bool online) 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(); |
| 81 void TryReconnect(); | 82 void TryReconnect(); |
| 82 | 83 |
| 83 void RefreshOAuthToken(); | 84 void RefreshOAuthToken(); |
| 84 | 85 |
| 85 XmppSignalStrategy* signal_strategy_; | 86 XmppSignalStrategy* signal_strategy_; |
| 87 base::Closure auth_failed_callback_; |
| 86 | 88 |
| 87 scoped_ptr<OAuthCredentials> oauth_credentials_; | 89 scoped_ptr<OAuthCredentials> oauth_credentials_; |
| 88 base::Closure oauth_failed_callback_; | |
| 89 scoped_ptr<GaiaOAuthClient> gaia_oauth_client_; | 90 scoped_ptr<GaiaOAuthClient> gaia_oauth_client_; |
| 90 | 91 |
| 91 // Number of times we tried to connect without success. | 92 // Number of times we tried to connect without success. |
| 92 int reconnect_attempts_; | 93 int reconnect_attempts_; |
| 93 | 94 |
| 94 bool refreshing_oauth_token_; | 95 bool refreshing_oauth_token_; |
| 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 |
| OLD | NEW |