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

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

Issue 1267843003: Fix reconcilor loop when the primary account is in an auth error state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 5 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
6 #define CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ 6 #define CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
7 7
8 #include "base/memory/linked_ptr.h"
9 #include "google_apis/gaia/google_service_auth_error.h"
8 #include "google_apis/gaia/oauth2_token_service_delegate.h" 10 #include "google_apis/gaia/oauth2_token_service_delegate.h"
9 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
10 12
11 class FakeOAuth2TokenServiceDelegate : public OAuth2TokenServiceDelegate { 13 class FakeOAuth2TokenServiceDelegate : public OAuth2TokenServiceDelegate {
12 public: 14 public:
13 FakeOAuth2TokenServiceDelegate(net::URLRequestContextGetter* request_context); 15 FakeOAuth2TokenServiceDelegate(net::URLRequestContextGetter* request_context);
14 ~FakeOAuth2TokenServiceDelegate() override; 16 ~FakeOAuth2TokenServiceDelegate() override;
15 17
16 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( 18 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher(
17 const std::string& account_id, 19 const std::string& account_id,
18 net::URLRequestContextGetter* getter, 20 net::URLRequestContextGetter* getter,
19 OAuth2AccessTokenConsumer* consumer) override; 21 OAuth2AccessTokenConsumer* consumer) override;
20 22
21 // Overriden to make sure it works on Android. 23 // Overriden to make sure it works on Android.
22 bool RefreshTokenIsAvailable(const std::string& account_id) const override; 24 bool RefreshTokenIsAvailable(const std::string& account_id) const override;
25 bool RefreshTokenHasError(const std::string& account_id) const override;
23 26
24 std::vector<std::string> GetAccounts() override; 27 std::vector<std::string> GetAccounts() override;
25 void RevokeAllCredentials() override; 28 void RevokeAllCredentials() override;
26 29
27 void LoadCredentials(const std::string& primary_account_id) override; 30 void LoadCredentials(const std::string& primary_account_id) override;
28 31
29 void UpdateCredentials(const std::string& account_id, 32 void UpdateCredentials(const std::string& account_id,
30 const std::string& refresh_token) override; 33 const std::string& refresh_token) override;
31 void RevokeCredentials(const std::string& account_id) override; 34 void RevokeCredentials(const std::string& account_id) override;
32 35
33 net::URLRequestContextGetter* GetRequestContext() const override; 36 net::URLRequestContextGetter* GetRequestContext() const override;
34 37
35 void set_request_context(net::URLRequestContextGetter* request_context) { 38 void set_request_context(net::URLRequestContextGetter* request_context) {
36 request_context_ = request_context; 39 request_context_ = request_context;
37 } 40 }
38 41
42 void SetLastErrorForAccount(const std::string& account_id,
43 const GoogleServiceAuthError& error);
44
39 private: 45 private:
46 struct AccountInfo {
47 AccountInfo(const std::string& refresh_token);
48
49 const std::string refresh_token;
50 GoogleServiceAuthError error;
51 };
52
40 void IssueRefreshTokenForUser(const std::string& account_id, 53 void IssueRefreshTokenForUser(const std::string& account_id,
41 const std::string& token); 54 const std::string& token);
42 std::string GetRefreshToken(const std::string& account_id) const; 55 std::string GetRefreshToken(const std::string& account_id) const;
43 56
44 // Maps account ids to their refresh token strings. 57 // Maps account ids to info.
45 std::map<std::string, std::string> refresh_tokens_; 58 typedef std::map<std::string, linked_ptr<AccountInfo>> AccountInfoMap;
59 AccountInfoMap refresh_tokens_;
46 60
47 scoped_refptr<net::URLRequestContextGetter> request_context_; 61 scoped_refptr<net::URLRequestContextGetter> request_context_;
48 62
49 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenServiceDelegate); 63 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenServiceDelegate);
50 }; 64 };
51 #endif 65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698