Chromium Code Reviews| Index: chrome/browser/services/gcm/gcm_account_tracker.h |
| diff --git a/chrome/browser/services/gcm/gcm_account_tracker.h b/chrome/browser/services/gcm/gcm_account_tracker.h |
| index f50dd87b5a6263dd84b0ebc42ab3e6ad9778d971..017535a7b33656ca80f0f005bfc0af035f085ab0 100644 |
| --- a/chrome/browser/services/gcm/gcm_account_tracker.h |
| +++ b/chrome/browser/services/gcm/gcm_account_tracker.h |
| @@ -14,6 +14,16 @@ |
| #include "google_apis/gaia/account_tracker.h" |
| #include "google_apis/gaia/oauth2_token_service.h" |
| +class PrefService; |
| + |
| +namespace base { |
| +class Time; |
| +} |
| + |
| +namespace user_prefs { |
| +class PrefRegistrySyncable; |
| +} |
| + |
| namespace gcm { |
| class GCMDriver; |
| @@ -56,11 +66,14 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| AccountState state; |
| }; |
| + static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| + |
| // Creates an instance of GCMAccountTracker. |account_tracker| is used to |
| // deliver information about the accounts present in the browser context to |
| // |driver|. |
| GCMAccountTracker(scoped_ptr<gaia::AccountTracker> account_tracker, |
| - GCMDriver* driver); |
| + GCMDriver* driver, |
| + PrefService* prefs); |
| virtual ~GCMAccountTracker(); |
| // Shuts down the tracker ensuring a proper clean up. After Shutdown() is |
| @@ -98,13 +111,22 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE; |
| virtual void OnDisconnected() OVERRIDE; |
| + // Schedules fetching tokens at the time when they are needed to be reported. |
| + void ScheduleFetchingTokens(); |
| // Report the list of accounts with OAuth2 tokens back using the |callback_| |
| // function. If there are token requests in progress, do nothing. |
| - void CompleteCollectingTokens(); |
| + void ReportTokens(); |
| // Verify that all of the tokens are ready to be passed down to the GCM |
| // Driver, e.g. none of them has expired or is missing. Returns true if not |
| // all tokens are valid and a fetching yet more tokens is required. |
| bool SanitizeTokens(); |
| + // Indicates whether token reporting is required, either because it is due, or |
| + // some of the accounts were removed. |
| + bool IsTokenReportingRequired(); |
| + // Indicates whether there are tokens that still need fetching. |
| + bool IsTokenFetchingRequired(); |
| + // Gets the time until next token fetching. |
| + base::TimeDelta GetTimeToNextTokenFetching(); |
| // Deletes a token request. Should be called from OnGetTokenSuccess(..) or |
| // OnGetTokenFailure(..). |
| void DeleteTokenRequest(const OAuth2TokenService::Request* request); |
| @@ -132,8 +154,15 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| // Indicates whether shutdown has been called. |
| bool shutdown_called_; |
| + // Pref service for storing timestamp of last token fetching. Not owned. |
| + PrefService* prefs_; |
| + |
| + base::Time last_token_fetch_time_; |
|
Nicolas Zea
2014/10/08 00:45:29
nit: comment about what this is for
fgorski
2014/11/06 01:16:14
Done.
|
| + |
| ScopedVector<OAuth2TokenService::Request> pending_token_requests_; |
| + base::WeakPtrFactory<GCMAccountTracker> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(GCMAccountTracker); |
| }; |