summaryrefslogtreecommitdiffstats
path: root/remoting/host/signaling_connector.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-18 05:54:40 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-18 05:54:40 +0000
commit6d2c32ce793eeb70f53de9704451afb0e0a2a674 (patch)
treed2c0023e0561b0fb2506a293dbce62cc0ba58e8c /remoting/host/signaling_connector.h
parent0b0a3d32273ec42dba93f080495ca798fb2d5406 (diff)
downloadchromium_src-6d2c32ce793eeb70f53de9704451afb0e0a2a674.zip
chromium_src-6d2c32ce793eeb70f53de9704451afb0e0a2a674.tar.gz
chromium_src-6d2c32ce793eeb70f53de9704451afb0e0a2a674.tar.bz2
Move OAuth token refreshing to SignalingConnector.
BUG=118928 Review URL: http://codereview.chromium.org/9956161 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/signaling_connector.h')
-rw-r--r--remoting/host/signaling_connector.h43
1 files changed, 39 insertions, 4 deletions
diff --git a/remoting/host/signaling_connector.h b/remoting/host/signaling_connector.h
index 23bb667..227bf71 100644
--- a/remoting/host/signaling_connector.h
+++ b/remoting/host/signaling_connector.h
@@ -10,10 +10,13 @@
#include "base/threading/non_thread_safe.h"
#include "base/timer.h"
#include "net/base/network_change_notifier.h"
-#include "remoting/jingle_glue/signal_strategy.h"
+#include "remoting/host/gaia_oauth_client.h"
+#include "remoting/jingle_glue/xmpp_signal_strategy.h"
namespace remoting {
+class URLRequestContextGetter;
+
// SignalingConnector listens for SignalStrategy status notifications
// and attempts to keep it connected when possible. When signalling is
// not connected it keeps trying to reconnect it until it is
@@ -25,11 +28,25 @@ class SignalingConnector
public base::NonThreadSafe,
public SignalStrategy::Listener,
public net::NetworkChangeNotifier::OnlineStateObserver,
- public net::NetworkChangeNotifier::IPAddressObserver {
+ public net::NetworkChangeNotifier::IPAddressObserver,
+ public GaiaOAuthClient::Delegate {
public:
- SignalingConnector(SignalStrategy* signal_strategy);
+ struct OAuthCredentials {
+ OAuthCredentials(const std::string& login_value,
+ const std::string& refresh_token_value);
+ std::string login;
+ std::string refresh_token;
+ };
+
+ // OAuth token is updated refreshed when |oauth_credentials| is
+ // not NULL.
+ SignalingConnector(XmppSignalStrategy* signal_strategy);
virtual ~SignalingConnector();
+ void EnableOAuth(scoped_ptr<OAuthCredentials> oauth_credentials,
+ const base::Closure& oauth_failed_callback,
+ URLRequestContextGetter* url_context);
+
// SignalStrategy::Listener interface.
virtual void OnSignalStrategyStateChange(
SignalStrategy::State state) OVERRIDE;
@@ -40,16 +57,34 @@ class SignalingConnector
// NetworkChangeNotifier::OnlineStateObserver interface.
virtual void OnOnlineStateChanged(bool online) OVERRIDE;
+ // GaiaOAuthClient::Delegate interface.
+ virtual void OnGetTokensResponse(const std::string& refresh_token,
+ const std::string& access_token,
+ int expires_seconds) OVERRIDE;
+ virtual void OnRefreshTokenResponse(const std::string& access_token,
+ int expires_seconds) OVERRIDE;
+ virtual void OnOAuthError() OVERRIDE;
+ virtual void OnNetworkError(int response_code) OVERRIDE;
+
private:
void ScheduleTryReconnect();
void ResetAndTryReconnect();
void TryReconnect();
- SignalStrategy* signal_strategy_;
+ void RefreshOAuthToken();
+
+ XmppSignalStrategy* signal_strategy_;
+
+ scoped_ptr<OAuthCredentials> oauth_credentials_;
+ base::Closure oauth_failed_callback_;
+ scoped_ptr<GaiaOAuthClient> gaia_oauth_client_;
// Number of times we tried to connect without success.
int reconnect_attempts_;
+ bool refreshing_oauth_token_;
+ base::Time auth_token_expiry_time_;
+
base::OneShotTimer<SignalingConnector> timer_;
DISALLOW_COPY_AND_ASSIGN(SignalingConnector);