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

Unified Diff: remoting/host/setup/oauth_client.h

Issue 1099553003: Added unit tests for getCredentialsFromAuthCode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/setup/oauth_client.h
diff --git a/remoting/host/setup/oauth_client.h b/remoting/host/setup/oauth_client.h
index 5cc8f1f3bcfe099ac1e6cacb25db9dd7adbd7cba..771d66c7c0df8a8d77b5ec1458f61002138902c5 100644
--- a/remoting/host/setup/oauth_client.h
+++ b/remoting/host/setup/oauth_client.h
@@ -2,26 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_HOST_SETUP_OAUTH_CLIENT
-#define REMOTING_HOST_SETUP_OAUTH_CLIENT
+#ifndef REMOTING_HOST_SETUP_OAUTH_CLIENT_H_
+#define REMOTING_HOST_SETUP_OAUTH_CLIENT_H_
-#include <queue>
#include <string>
#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-#include "google_apis/gaia/gaia_oauth_client.h"
-#include "net/url_request/url_request_context_getter.h"
-namespace net {
-class URLRequestContext;
+namespace gaia {
+struct OAuthClientInfo;
}
namespace remoting {
-// A wrapper around GaiaOAuthClient that provides a more convenient interface,
-// with queueing of requests and a callback rather than a delegate.
-class OAuthClient : public gaia::GaiaOAuthClient::Delegate {
+class OAuthClient {
public:
// Called when GetCredentialsFromAuthCode is completed, with the |user_email|
// and |refresh_token| that correspond to the given |auth_code|, or with empty
@@ -30,10 +24,7 @@ class OAuthClient : public gaia::GaiaOAuthClient::Delegate {
const std::string& user_email,
const std::string& refresh_token)> CompletionCallback;
- OAuthClient(
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
-
- ~OAuthClient() override;
+ virtual ~OAuthClient() {}
// Redeems |auth_code| using |oauth_client_info| to obtain |refresh_token| and
// |access_token|, then uses the userinfo endpoint to obtain |user_email|.
@@ -41,44 +32,12 @@ class OAuthClient : public gaia::GaiaOAuthClient::Delegate {
// or with empty strings on error.
// If a request is received while another one is being processed, it is
// enqueued and processed after the first one is finished.
- void GetCredentialsFromAuthCode(
+ virtual void GetCredentialsFromAuthCode(
const gaia::OAuthClientInfo& oauth_client_info,
const std::string& auth_code,
- CompletionCallback on_done);
-
- // gaia::GaiaOAuthClient::Delegate
- void OnGetTokensResponse(const std::string& refresh_token,
- const std::string& access_token,
- int expires_in_seconds) override;
- void OnRefreshTokenResponse(const std::string& access_token,
- int expires_in_seconds) override;
- void OnGetUserEmailResponse(const std::string& user_email) override;
-
- void OnOAuthError() override;
- void OnNetworkError(int response_code) override;
-
- private:
- struct Request {
- Request(const gaia::OAuthClientInfo& oauth_client_info,
- const std::string& auth_code,
- CompletionCallback on_done);
- virtual ~Request();
- gaia::OAuthClientInfo oauth_client_info;
- std::string auth_code;
- CompletionCallback on_done;
- };
-
- void SendResponse(const std::string& user_email,
- const std::string& refresh_token);
-
- std::queue<Request> pending_requests_;
- gaia::GaiaOAuthClient gaia_oauth_client_;
- std::string refresh_token_;
- CompletionCallback on_done_;
-
- DISALLOW_COPY_AND_ASSIGN(OAuthClient);
+ CompletionCallback on_done) = 0;
};
} // namespace remoting
-#endif // REMOTING_HOST_SETUP_OAUTH_CLIENT
+#endif // REMOTING_HOST_SETUP_OAUTH_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698