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

Unified Diff: google_apis/gaia/oauth2_token_service_proxy.h

Issue 299943003: Refactor ProfileOAuth2TokenServiceRequest into OAuth2TokenServiceRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow ProfileOAuth2TokenServiceRequestTest to free UI thread resources. 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_proxy.h
diff --git a/google_apis/gaia/oauth2_token_service_proxy.h b/google_apis/gaia/oauth2_token_service_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a12a0dfafbe424a4241dc00b7092ba72a4fed0f
--- /dev/null
+++ b/google_apis/gaia/oauth2_token_service_proxy.h
@@ -0,0 +1,70 @@
+// 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 GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_PROXY_H_
+#define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_PROXY_H_
+
+#include "base/threading/non_thread_safe.h"
+#include "google_apis/gaia/oauth2_token_service.h"
+
+class GoogleServiceAuthError;
+
+// OAuth2TokenServiceProxy provides a subset of the OAuth2TokenService interface
+// and can be instantiated and used from any thread. OAuth2TokenServiceProxy
+// itself is a NonThreadSafe class and should called only on the thread on which
+// it is created.
+//
+// OAuth2TokenServiceProxy differs from OAuth2TokenService in that it uses
+// callbacks instead of the OAuth2TokenService::Consumer interface.
+class OAuth2TokenServiceProxy : public base::NonThreadSafe {
+ public:
+ typedef base::Callback<void(const GoogleServiceAuthError& /* error */,
+ const std::string& /* access_token */,
+ const base::Time& /* expiration_time */)>
maniscalco 2014/05/27 22:41:25 After talking with pavely@, I'm inclined to remove
+ RequestTokenCallback;
+
+ // Construct an OAuth2TokenServiceProxy.
+ //
+ // |token_service_task_runner| is the message loop |token_service| lives on.
+ //
+ // |token_service| must outlive this object.
+ OAuth2TokenServiceProxy(
+ const scoped_refptr<base::SequencedTaskRunner>& token_service_task_runner,
+ OAuth2TokenService* token_service);
+
+ // Destroying the OAuth2TokenServiceProxy will eventually cancel any
+ // outstanding requests. Why eventually? Why not immediately? The requests
+ // may not be executing in this thread so we cannot guarantee that upon
+ // completion of the destructor they have been cancelled. If you don't want
+ // to receive callbacks from outstanding requests, use WeakPtrs in your
+ // callback.
+ virtual ~OAuth2TokenServiceProxy();
+
+ // See OAuth2TokenService::StartRequest.
+ //
+ // |callback| will be invoked when the request has completed (successfully or
+ // not).
+ //
+ // |requester_id| is a string that describes the service requesting the token.
+ void RequestToken(const std::string& account_id,
+ const OAuth2TokenService::ScopeSet& scopes,
+ const RequestTokenCallback& callback,
+ const std::string& requester_id);
+
+ // See OAuth2TokenService::InvalidateToken.
+ void InvalidateToken(const std::string& account_id,
+ const OAuth2TokenService::ScopeSet& scopes,
+ const std::string& access_token);
+
+ private:
+ class Core;
+ // The thread that core_ lives on.
+ scoped_refptr<base::SequencedTaskRunner> core_task_runner_;
+ // Lives in the token_service_task_runner_ thread and must be destroyed there.
+ scoped_refptr<Core> core_;
+
+ DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceProxy);
+};
+
+#endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_PROXY_H_
« no previous file with comments | « chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc ('k') | google_apis/gaia/oauth2_token_service_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698