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

Side by Side Diff: google_apis/gaia/fake_oauth2_token_service.h

Issue 336253002: Add IdentityProvider-based AccountTracker to google_apis (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add pointer ownership comment Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_ 5 #ifndef GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_
6 #define GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_ 6 #define GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
12 #include "google_apis/gaia/oauth2_token_service.h" 13 #include "google_apis/gaia/oauth2_token_service.h"
13 14
14 namespace net { 15 namespace net {
15 class URLRequestContextGetter; 16 class URLRequestContextGetter;
16 } 17 }
17 18
18 // Do-nothing implementation of OAuth2TokenService. 19 // Do-nothing implementation of OAuth2TokenService.
19 class FakeOAuth2TokenService : public OAuth2TokenService { 20 class FakeOAuth2TokenService : public OAuth2TokenService {
20 public: 21 public:
21 FakeOAuth2TokenService(); 22 FakeOAuth2TokenService();
22 virtual ~FakeOAuth2TokenService(); 23 virtual ~FakeOAuth2TokenService();
23 24
25 virtual std::vector<std::string> GetAccounts() OVERRIDE;
26
24 void AddAccount(const std::string& account_id); 27 void AddAccount(const std::string& account_id);
28 void RemoveAccount(const std::string& account_id);
29
30 // Helper routines to issue tokens for pending requests.
31 void IssueAllTokensForAccount(const std::string& account_id,
32 const std::string& access_token,
33 const base::Time& expiration);
25 34
26 void set_request_context(net::URLRequestContextGetter* request_context) { 35 void set_request_context(net::URLRequestContextGetter* request_context) {
27 request_context_ = request_context; 36 request_context_ = request_context;
28 } 37 }
29 38
30 protected: 39 protected:
31 // OAuth2TokenService overrides. 40 // OAuth2TokenService overrides.
32 virtual void FetchOAuth2Token(RequestImpl* request, 41 virtual void FetchOAuth2Token(RequestImpl* request,
33 const std::string& account_id, 42 const std::string& account_id,
34 net::URLRequestContextGetter* getter, 43 net::URLRequestContextGetter* getter,
35 const std::string& client_id, 44 const std::string& client_id,
36 const std::string& client_secret, 45 const std::string& client_secret,
37 const ScopeSet& scopes) OVERRIDE; 46 const ScopeSet& scopes) OVERRIDE;
38 47
39 virtual void InvalidateOAuth2Token(const std::string& account_id, 48 virtual void InvalidateOAuth2Token(const std::string& account_id,
40 const std::string& client_id, 49 const std::string& client_id,
41 const ScopeSet& scopes, 50 const ScopeSet& scopes,
42 const std::string& access_token) OVERRIDE; 51 const std::string& access_token) OVERRIDE;
43 52
44 virtual bool RefreshTokenIsAvailable(const std::string& account_id) const 53 virtual bool RefreshTokenIsAvailable(const std::string& account_id) const
45 OVERRIDE; 54 OVERRIDE;
46 55
47 private: 56 private:
57 struct PendingRequest {
58 PendingRequest();
59 ~PendingRequest();
60
61 std::string account_id;
62 std::string client_id;
63 std::string client_secret;
64 ScopeSet scopes;
65 base::WeakPtr<RequestImpl> request;
66 };
67
48 // OAuth2TokenService overrides. 68 // OAuth2TokenService overrides.
49 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 69 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
50 70
51 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( 71 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher(
52 const std::string& account_id, 72 const std::string& account_id,
53 net::URLRequestContextGetter* getter, 73 net::URLRequestContextGetter* getter,
54 OAuth2AccessTokenConsumer* consumer) OVERRIDE; 74 OAuth2AccessTokenConsumer* consumer) OVERRIDE;
55 75
56 std::set<std::string> account_ids_; 76 std::set<std::string> account_ids_;
77 std::vector<PendingRequest> pending_requests_;
78
57 net::URLRequestContextGetter* request_context_; // weak 79 net::URLRequestContextGetter* request_context_; // weak
58 80
59 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenService); 81 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenService);
60 }; 82 };
61 83
62 #endif // GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_ 84 #endif // GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_
OLDNEW
« no previous file with comments | « google_apis/gaia/account_tracker_unittest.cc ('k') | google_apis/gaia/fake_oauth2_token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698