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

Side by Side Diff: components/signin/core/browser/account_reconcilor.h

Issue 369353002: Create a FakeAccountReconcilor that doesn't perform network requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 4 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_
5 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 5 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_
6 6
7 #include <deque> 7 #include <deque>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // KeyedService implementation. 54 // KeyedService implementation.
55 virtual void Shutdown() OVERRIDE; 55 virtual void Shutdown() OVERRIDE;
56 56
57 // Add or remove observers for the merge session notification. 57 // Add or remove observers for the merge session notification.
58 void AddMergeSessionObserver(MergeSessionHelper::Observer* observer); 58 void AddMergeSessionObserver(MergeSessionHelper::Observer* observer);
59 void RemoveMergeSessionObserver(MergeSessionHelper::Observer* observer); 59 void RemoveMergeSessionObserver(MergeSessionHelper::Observer* observer);
60 60
61 ProfileOAuth2TokenService* token_service() { return token_service_; } 61 ProfileOAuth2TokenService* token_service() { return token_service_; }
62 SigninClient* client() { return client_; } 62 SigninClient* client() { return client_; }
63 63
64 protected:
65 // Used during GetAccountsFromCookie.
66 // Stores a callback for the next action to perform.
67 typedef base::Callback<
68 void(const GoogleServiceAuthError& error,
69 const std::vector<std::pair<std::string, bool> >&)>
70 GetAccountsFromCookieCallback;
71
72 virtual void GetAccountsFromCookie(GetAccountsFromCookieCallback callback);
73
64 private: 74 private:
65 // An std::set<> for use with email addresses that uses 75 // An std::set<> for use with email addresses that uses
66 // gaia::CanonicalizeEmail() during comparisons. 76 // gaia::CanonicalizeEmail() during comparisons.
67 // TODO(rogerta): this is a workaround for the fact that SigninManager and 77 // TODO(rogerta): this is a workaround for the fact that SigninManager and
68 // SigninOAuthHelper use the gaia "email" property when adding accounts to 78 // SigninOAuthHelper use the gaia "email" property when adding accounts to
69 // the token service, whereas gaia::ParseListAccountsData() returns email 79 // the token service, whereas gaia::ParseListAccountsData() returns email
70 // addresses that have been passed through gaia::CanonicalizeEmail(). These 80 // addresses that have been passed through gaia::CanonicalizeEmail(). These
71 // two types of email addresses are not directly comparable. 81 // two types of email addresses are not directly comparable.
72 class EmailLessFunc : public std::less<std::string> { 82 class EmailLessFunc : public std::less<std::string> {
73 public: 83 public:
(...skipping 18 matching lines...) Expand all
92 } 102 }
93 103
94 const EmailSet& GetValidChromeAccountsForTesting() const { 104 const EmailSet& GetValidChromeAccountsForTesting() const {
95 return valid_chrome_accounts_; 105 return valid_chrome_accounts_;
96 } 106 }
97 107
98 const EmailSet& GetInvalidChromeAccountsForTesting() const { 108 const EmailSet& GetInvalidChromeAccountsForTesting() const {
99 return invalid_chrome_accounts_; 109 return invalid_chrome_accounts_;
100 } 110 }
101 111
102 // Used during GetAccountsFromCookie.
103 // Stores a callback for the next action to perform.
104 typedef base::Callback<
105 void(const GoogleServiceAuthError& error,
106 const std::vector<std::pair<std::string, bool> >&)>
107 GetAccountsFromCookieCallback;
108 112
109 friend class AccountReconcilorTest; 113 friend class AccountReconcilorTest;
110 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, SigninManagerRegistration); 114 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, SigninManagerRegistration);
111 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, Reauth); 115 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, Reauth);
112 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ProfileAlreadyConnected); 116 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ProfileAlreadyConnected);
113 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieSuccess); 117 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieSuccess);
114 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieFailure); 118 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieFailure);
115 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ValidateAccountsFromTokens); 119 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ValidateAccountsFromTokens);
116 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 120 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
117 ValidateAccountsFromTokensFailedUserInfo); 121 ValidateAccountsFromTokensFailedUserInfo);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void StartReconcile(); 170 void StartReconcile();
167 void FinishReconcile(); 171 void FinishReconcile();
168 void AbortReconcile(); 172 void AbortReconcile();
169 void CalculateIfReconcileIsDone(); 173 void CalculateIfReconcileIsDone();
170 void ScheduleStartReconcileIfChromeAccountsChanged(); 174 void ScheduleStartReconcileIfChromeAccountsChanged();
171 void HandleSuccessfulAccountIdCheck(const std::string& account_id); 175 void HandleSuccessfulAccountIdCheck(const std::string& account_id);
172 void HandleFailedAccountIdCheck(const std::string& account_id); 176 void HandleFailedAccountIdCheck(const std::string& account_id);
173 void HandleRefreshTokenFetched(const std::string& account_id, 177 void HandleRefreshTokenFetched(const std::string& account_id,
174 const std::string& refresh_token); 178 const std::string& refresh_token);
175 179
176 void GetAccountsFromCookie(GetAccountsFromCookieCallback callback);
177 void ContinueReconcileActionAfterGetGaiaAccounts( 180 void ContinueReconcileActionAfterGetGaiaAccounts(
178 const GoogleServiceAuthError& error, 181 const GoogleServiceAuthError& error,
179 const std::vector<std::pair<std::string, bool> >& accounts); 182 const std::vector<std::pair<std::string, bool> >& accounts);
180 void ValidateAccountsFromTokenService(); 183 void ValidateAccountsFromTokenService();
181 // Note internally that this |account_id| is added to the cookie jar. 184 // Note internally that this |account_id| is added to the cookie jar.
182 bool MarkAccountAsAddedToCookie(const std::string& account_id); 185 bool MarkAccountAsAddedToCookie(const std::string& account_id);
183 // Note internally that this |account_id| is added to the token service. 186 // Note internally that this |account_id| is added to the token service.
184 void MarkAccountAsAddedToChrome(const std::string& account_id); 187 void MarkAccountAsAddedToChrome(const std::string& account_id);
185 188
186 void OnCookieChanged(const net::CanonicalCookie* cookie); 189 void OnCookieChanged(const net::CanonicalCookie* cookie);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 EmailSet invalid_chrome_accounts_; 256 EmailSet invalid_chrome_accounts_;
254 std::vector<std::string> add_to_cookie_; 257 std::vector<std::string> add_to_cookie_;
255 std::vector<std::pair<std::string, int> > add_to_chrome_; 258 std::vector<std::pair<std::string, int> > add_to_chrome_;
256 259
257 std::deque<GetAccountsFromCookieCallback> get_gaia_accounts_callbacks_; 260 std::deque<GetAccountsFromCookieCallback> get_gaia_accounts_callbacks_;
258 261
259 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); 262 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor);
260 }; 263 };
261 264
262 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 265 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698