Commit 73df0e52 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

Remove OAuth2TokenServiceRequest

This class exists to enable making access token requests from threads
other than the UI thread. However, it is not used in the codebase, and
it has some amount of maintenance cost and confusion associated with it.
It can always be brought back if needed.

Bug: 967598
Change-Id: I2208d377f852e88f1cd8169202a07ce00d32d53f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1675648Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672057}
parent 6bd6806a
......@@ -26,8 +26,7 @@
//
// See |OAuth2TokenServiceDelegate| for usage details.
//
// Note: requests should be started from the UI thread. To start a
// request from other thread, please use OAuth2TokenServiceRequest.
// Note: requests should be started from the UI thread.
class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate {
public:
OAuth2TokenServiceDelegateAndroid(
......
......@@ -37,8 +37,7 @@ class PrefRegistrySimple;
// Consumer::OnGetTokenSuccess will be invoked, but the access token
// won't be cached.
//
// Note: requests should be started from the UI thread. To start a
// request from other thread, please use OAuth2TokenServiceRequest.
// Note: requests should be started from the UI thread.
class ProfileOAuth2TokenService : public OAuth2TokenService {
public:
typedef base::RepeatingCallback<void(const CoreAccountId& /* account_id */,
......
......@@ -124,8 +124,6 @@ template("google_apis_tmpl") {
"gaia/oauth2_token_service_delegate.cc",
"gaia/oauth2_token_service_delegate.h",
"gaia/oauth2_token_service_observer.h",
"gaia/oauth2_token_service_request.cc",
"gaia/oauth2_token_service_request.h",
"gaia/oauth_multilogin_result.cc",
"gaia/oauth_multilogin_result.h",
"gaia/oauth_request_signer.cc",
......@@ -222,7 +220,6 @@ test("google_apis_unittests") {
"gaia/oauth2_id_token_decoder_unittest.cc",
"gaia/oauth2_mint_token_flow_unittest.cc",
"gaia/oauth2_token_service_delegate_unittest.cc",
"gaia/oauth2_token_service_request_unittest.cc",
"gaia/oauth2_token_service_unittest.cc",
"gaia/oauth_multilogin_result_unittest.cc",
"gaia/oauth_request_signer_unittest.cc",
......
This diff is collapsed.
// 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_REQUEST_H_
#define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_REQUEST_H_
#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h"
#include "base/single_thread_task_runner.h"
#include "google_apis/gaia/oauth2_token_service.h"
// 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:
class Core;
// Interface for providing an OAuth2TokenService.
//
// Ref-counted so that OAuth2TokenServiceRequest can ensure this object isn't
// destroyed out from under the token service task runner thread. Because
// OAuth2TokenServiceRequest has a reference, implementations of
// TokenServiceProvider must be capable of being destroyed on the same thread
// on which the OAuth2TokenServiceRequest was created.
class TokenServiceProvider
: public base::RefCountedThreadSafe<TokenServiceProvider> {
public:
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;
protected:
friend class base::RefCountedThreadSafe<TokenServiceProvider>;
virtual ~TokenServiceProvider();
};
// Creates and starts an access token request for |account_id| and |scopes|.
//
// |provider| is used to get the OAuth2TokenService.
//
// |account_id| must not be empty.
//
// |scopes| must not be empty.
//
// |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 std::unique_ptr<OAuth2TokenServiceRequest> CreateAndStart(
const scoped_refptr<TokenServiceProvider>& provider,
const CoreAccountId& account_id,
const OAuth2TokenService::ScopeSet& scopes,
OAuth2TokenService::Consumer* consumer);
// Invalidates |access_token| for |account_id| and |scopes|.
//
// |provider| is used to get the OAuth2TokenService.
//
// |account_id| must not be empty.
//
// |scopes| must not be empty.
static void InvalidateToken(
const scoped_refptr<TokenServiceProvider>& provider,
const CoreAccountId& account_id,
const OAuth2TokenService::ScopeSet& scopes,
const std::string& access_token);
~OAuth2TokenServiceRequest() override;
// OAuth2TokenService::Request.
CoreAccountId GetAccountId() const override;
private:
OAuth2TokenServiceRequest(const CoreAccountId& account_id);
void StartWithCore(const scoped_refptr<Core>& core);
const CoreAccountId account_id_;
scoped_refptr<Core> core_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceRequest);
};
#endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_REQUEST_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment