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

Unified Diff: google_apis/gaia/oauth2_token_service_request.h

Issue 299943003: Refactor ProfileOAuth2TokenServiceRequest into OAuth2TokenServiceRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments referring to ProfileOAuth2TokenServiceRequest. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gaia/oauth2_token_service_request.h
diff --git a/chrome/browser/signin/profile_oauth2_token_service_request.h b/google_apis/gaia/oauth2_token_service_request.h
similarity index 14%
rename from chrome/browser/signin/profile_oauth2_token_service_request.h
rename to google_apis/gaia/oauth2_token_service_request.h
index e7f628dde3f11e9601de33aaf4221942b903c715..0ebb2a12abd0958367b4e78b7987f76117340f1a 100644
--- a/chrome/browser/signin/profile_oauth2_token_service_request.h
+++ b/google_apis/gaia/oauth2_token_service_request.h
@@ -1,55 +1,99 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_REQUEST_H_
-#define CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_REQUEST_H_
+#ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_REQUEST_H_
+#define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_REQUEST_H_
#include <set>
#include <string>
+#include "base/single_thread_task_runner.h"
#include "base/threading/non_thread_safe.h"
#include "google_apis/gaia/oauth2_token_service.h"
-class Profile;
-
-// ProfileOAuth2TokenServiceRequest represents a request to fetch an
-// OAuth2 access token for a given set of |scopes| by calling |profile|'s
-// ProfileOAuth2TokenService. A request can be created and started from
-// any thread with an object |consumer| that will be called back on the
-// same thread when fetching completes. If the request is destructed
-// before |consumer| is called, |consumer| will never be called back. (Note
-// the actual network activities are not canceled and the cache in
-// ProfileOAuth2TokenService will be populated with the fetched results.)
-class ProfileOAuth2TokenServiceRequest : public OAuth2TokenService::Request,
- public base::NonThreadSafe {
+// OAuth2TokenServiceRequest represents an asynchronous request to an
+// OAuth2TokenService that may live in another thread.
+//
+// An OAuth2TokenServiceRequest can be created and started from any thread.
+class OAuth2TokenServiceRequest : public OAuth2TokenService::Request,
+ public base::NonThreadSafe {
public:
- // Creates and starts a request for |account_id| and |scopes|.
- // Uses the primary account id if |account_id| is the empty string.
- static ProfileOAuth2TokenServiceRequest* CreateAndStart(
- Profile* profile,
+ class Core;
+
+ // Interface for providing an OAuth2TokenService.
+ class TokenServiceProvider {
+ public:
+ TokenServiceProvider();
+ virtual ~TokenServiceProvider();
+
+ // Returns the task runner on which the token service lives.
+ //
+ // This method may be called from any thread.
+ virtual scoped_refptr<base::SingleThreadTaskRunner>
+ GetTokenServiceTaskRunner() = 0;
+
+ // Returns a pointer to a token service.
+ //
+ // Caller does not own the token service and must not delete it. The token
+ // service must outlive all instances of OAuth2TokenServiceRequest.
+ //
+ // This method may only be called from the task runner returned by
+ // |GetTokenServiceTaskRunner|.
+ virtual OAuth2TokenService* GetTokenService() = 0;
+ };
+
+ // Creates and starts an access token request for |account_id| and |scopes|.
+ //
+ // |provider| is used to get the OAuth2TokenService and must outlive the
+ // returned request object.
+ //
msarda 2014/05/30 14:37:31 |account_id|| must not be empty?
maniscalco 2014/05/30 17:48:08 Done.
+ // |consumer| will be invoked in the same thread that invoked CreateAndStart
+ // and must outlive the returned request object. Destroying the request
+ // object ensure that |consumer| will not be called. However, the actual
+ // network activities may not be canceled and the cache in OAuth2TokenService
+ // may be populated with the fetched results.
+ static OAuth2TokenServiceRequest* CreateAndStart(
+ TokenServiceProvider* provider,
const std::string& account_id,
const OAuth2TokenService::ScopeSet& scopes,
OAuth2TokenService::Consumer* consumer);
- virtual ~ProfileOAuth2TokenServiceRequest();
+ // Creates and starts an InvalidateToken request for |account_id|, |scopes|,
+ // and |access_token|.
+ //
+ // |provider| is used to get the OAuth2TokenService and must outlive the
+ // returned request object.
+ static OAuth2TokenServiceRequest* CreateAndStartInvalidate(
+ TokenServiceProvider* provider,
+ const std::string& account_id,
+ const OAuth2TokenService::ScopeSet& scopes,
+ const std::string& access_token);
+
+ virtual ~OAuth2TokenServiceRequest();
// Overridden from Request:
virtual std::string GetAccountId() const OVERRIDE;
private:
- class Core;
- friend class Core;
+ OAuth2TokenServiceRequest(
+ const scoped_refptr<base::SingleThreadTaskRunner>& owner_task_runner,
+ OAuth2TokenServiceRequest::TokenServiceProvider* provider,
+ OAuth2TokenService::Consumer* consumer,
+ const std::string& account_id,
+ const OAuth2TokenService::ScopeSet& scopes);
- ProfileOAuth2TokenServiceRequest(Profile* profile,
- const std::string& account_id,
- const OAuth2TokenService::ScopeSet& scopes,
- OAuth2TokenService::Consumer* consumer);
+ OAuth2TokenServiceRequest(
+ const scoped_refptr<base::SingleThreadTaskRunner>& owner_task_runner,
+ OAuth2TokenServiceRequest::TokenServiceProvider* provider,
+ const std::string& access_token,
+ const std::string& account_id,
+ const OAuth2TokenService::ScopeSet& scopes);
- OAuth2TokenService::Consumer* const consumer_;
+ const std::string account_id_;
scoped_refptr<Core> core_;
- DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenServiceRequest);
+ DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceRequest);
};
-#endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_REQUEST_H_
+#endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_REQUEST_H_

Powered by Google App Engine
This is Rietveld 408576698