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

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

Powered by Google App Engine
This is Rietveld 408576698