[chromedriver] Don't evaluate document.readyState if we already know it is loading.
[chromium-blink-merge.git] / google_apis / gaia / fake_oauth2_token_service.h
blob77be353e977c446e3decf527652fa178923fff0b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_
6 #define GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_
8 #include "google_apis/gaia/fake_oauth2_token_service_delegate.h"
9 #include "google_apis/gaia/oauth2_token_service.h"
11 namespace net {
12 class URLRequestContextGetter;
15 // Do-nothing implementation of OAuth2TokenService.
16 class FakeOAuth2TokenService : public OAuth2TokenService {
17 public:
18 FakeOAuth2TokenService();
19 ~FakeOAuth2TokenService() override;
21 void AddAccount(const std::string& account_id);
22 void RemoveAccount(const std::string& account_id);
24 // Helper routines to issue tokens for pending requests or complete them with
25 // error.
26 void IssueAllTokensForAccount(const std::string& account_id,
27 const std::string& access_token,
28 const base::Time& expiration);
29 void IssueErrorForAllPendingRequestsForAccount(
30 const std::string& account_id,
31 const GoogleServiceAuthError& auth_error);
33 FakeOAuth2TokenServiceDelegate* GetFakeOAuth2TokenServiceDelegate();
35 protected:
36 // OAuth2TokenService overrides.
37 void FetchOAuth2Token(RequestImpl* request,
38 const std::string& account_id,
39 net::URLRequestContextGetter* getter,
40 const std::string& client_id,
41 const std::string& client_secret,
42 const ScopeSet& scopes) override;
44 void InvalidateAccessTokenImpl(const std::string& account_id,
45 const std::string& client_id,
46 const ScopeSet& scopes,
47 const std::string& access_token) override;
49 private:
50 struct PendingRequest {
51 PendingRequest();
52 ~PendingRequest();
54 std::string account_id;
55 std::string client_id;
56 std::string client_secret;
57 ScopeSet scopes;
58 base::WeakPtr<RequestImpl> request;
61 std::vector<PendingRequest> pending_requests_;
63 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenService);
66 #endif // GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_