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: components/signin/core/browser/account_fetcher_service.h

Issue 1380103004: Delay fetching account info until OnRefreshTokensLoaded(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 2 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 COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_FETCHER_SERVICE_H_ 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_FETCHER_SERVICE_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_FETCHER_SERVICE_H_ 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_FETCHER_SERVICE_H_
7 7
8 #include <list> 8 #include <set>
9 #include <map>
10 9
11 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
13 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
14 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
15 #include "google_apis/gaia/oauth2_token_service.h" 14 #include "google_apis/gaia/oauth2_token_service.h"
16 15
17 class AccountInfoFetcher; 16 class AccountInfoFetcher;
18 class AccountTrackerService; 17 class AccountTrackerService;
19 class ChildAccountInfoFetcher; 18 class ChildAccountInfoFetcher;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 60
62 void FetchUserInfoBeforeSignin(const std::string& account_id); 61 void FetchUserInfoBeforeSignin(const std::string& account_id);
63 62
64 AccountTrackerService* account_tracker_service() const { 63 AccountTrackerService* account_tracker_service() const {
65 return account_tracker_service_; 64 return account_tracker_service_;
66 } 65 }
67 66
68 // Called by ChildAccountInfoFetcher. 67 // Called by ChildAccountInfoFetcher.
69 void SetIsChildAccount(const std::string& account_id, bool is_child_account); 68 void SetIsChildAccount(const std::string& account_id, bool is_child_account);
70 69
70 #if defined(OS_ANDROID)
71 // Called by AccountTrackerServiceAndroid.
72 void OnAccountIdNameMapSeeded();
73 #endif
74
71 private: 75 private:
72 friend class AccountInfoFetcher; 76 friend class AccountInfoFetcher;
73 friend class ChildAccountInfoFetcherImpl; 77 friend class ChildAccountInfoFetcherImpl;
74 78
75 void RefreshAllAccountInfo(bool only_fetch_if_invalid); 79 void RefreshAllAccountInfo(bool only_fetch_if_invalid);
76 void RefreshAllAccountsAndScheduleNext(); 80 void RefreshAllAccountsAndScheduleNext();
77 void ScheduleNextRefresh(); 81 void ScheduleNextRefresh();
78 82
79 // Called on all account state changes. Decides whether to fetch new child 83 // Called on all account state changes. Decides whether to fetch new child
80 // status information or reset old values that aren't valid now. 84 // status information or reset old values that aren't valid now.
81 void UpdateChildInfo(); 85 void UpdateChildInfo();
82 86
83 // Virtual so that tests can override the network fetching behaviour. 87 // Virtual so that tests can override the network fetching behaviour.
84 // Further the two fetches are managed by a different refresh logic and 88 // Further the two fetches are managed by a different refresh logic and
85 // thus, can not be combined. 89 // thus, can not be combined.
86 virtual void StartFetchingUserInfo(const std::string& account_id); 90 virtual void StartFetchingUserInfo(const std::string& account_id);
87 virtual void StartFetchingChildInfo(const std::string& account_id); 91 virtual void StartFetchingChildInfo(const std::string& account_id);
88 92
93 // Helper methods to defer fetching until it is enabled and any partial
94 // seeding has been done if it is required (Android).
95 bool DeferFetchingAccountInfo(const std::string& account_id);
96 void FetchPendingAccountInfo();
97
89 // If there is more than one account in a profile, we forcibly reset the 98 // If there is more than one account in a profile, we forcibly reset the
90 // child status for an account to be false. 99 // child status for an account to be false.
91 void ResetChildInfo(); 100 void ResetChildInfo();
92 101
93 // Refreshes the AccountInfo associated with |account_id|. 102 // Refreshes the AccountInfo associated with |account_id|.
94 void RefreshAccountInfo(const std::string& account_id, 103 void RefreshAccountInfo(const std::string& account_id,
95 bool only_fetch_if_invalid); 104 bool only_fetch_if_invalid);
96 105
97 // Virtual so that tests can override the network fetching behaviour. 106 // Virtual so that tests can override the network fetching behaviour.
98 virtual void SendRefreshTokenAnnotationRequest(const std::string& account_id); 107 virtual void SendRefreshTokenAnnotationRequest(const std::string& account_id);
99 void RefreshTokenAnnotationRequestDone(const std::string& account_id); 108 void RefreshTokenAnnotationRequestDone(const std::string& account_id);
100 109
101 // Called by AccountInfoFetcher. 110 // Called by AccountInfoFetcher.
102 void OnUserInfoFetchSuccess(const std::string& account_id, 111 void OnUserInfoFetchSuccess(const std::string& account_id,
103 scoped_ptr<base::DictionaryValue> user_info); 112 scoped_ptr<base::DictionaryValue> user_info);
104 void OnUserInfoFetchFailure(const std::string& account_id); 113 void OnUserInfoFetchFailure(const std::string& account_id);
105 114
106 // OAuth2TokenService::Observer implementation. 115 // OAuth2TokenService::Observer implementation.
107 void OnRefreshTokenAvailable(const std::string& account_id) override; 116 void OnRefreshTokenAvailable(const std::string& account_id) override;
108 void OnRefreshTokenRevoked(const std::string& account_id) override; 117 void OnRefreshTokenRevoked(const std::string& account_id) override;
109 void OnRefreshTokensLoaded() override; 118 void OnRefreshTokensLoaded() override;
110 119
111 AccountTrackerService* account_tracker_service_; // Not owned. 120 AccountTrackerService* account_tracker_service_; // Not owned.
112 OAuth2TokenService* token_service_; // Not owned. 121 OAuth2TokenService* token_service_; // Not owned.
113 SigninClient* signin_client_; // Not owned. 122 SigninClient* signin_client_; // Not owned.
114 invalidation::InvalidationService* invalidation_service_; // Not owned. 123 invalidation::InvalidationService* invalidation_service_; // Not owned.
115 bool network_fetches_enabled_; 124 bool network_fetches_enabled_;
116 std::list<std::string> pending_user_info_fetches_; 125 std::set<std::string> pending_user_info_fetches_;
117 base::Time last_updated_; 126 base::Time last_updated_;
118 base::OneShotTimer timer_; 127 base::OneShotTimer timer_;
119 bool shutdown_called_; 128 bool shutdown_called_;
120 129
121 std::string child_request_account_id_; 130 std::string child_request_account_id_;
122 scoped_ptr<ChildAccountInfoFetcher> child_info_request_; 131 scoped_ptr<ChildAccountInfoFetcher> child_info_request_;
123 132
124 // Holds references to account info fetchers keyed by account_id. 133 // Holds references to account info fetchers keyed by account_id.
125 base::ScopedPtrHashMap<std::string, scoped_ptr<AccountInfoFetcher>> 134 base::ScopedPtrHashMap<std::string, scoped_ptr<AccountInfoFetcher>>
126 user_info_requests_; 135 user_info_requests_;
127 // Holds references to refresh token annotation requests keyed by account_id. 136 // Holds references to refresh token annotation requests keyed by account_id.
128 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> 137 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>>
129 refresh_token_annotation_requests_; 138 refresh_token_annotation_requests_;
130 139
131 DISALLOW_COPY_AND_ASSIGN(AccountFetcherService); 140 DISALLOW_COPY_AND_ASSIGN(AccountFetcherService);
132 }; 141 };
133 142
134 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_FETCHER_SERVICE_H_ 143 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_FETCHER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698