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 0b1c5e81f32cb42623ea79a8667de59f666ee05c..43c5f33557f9edbcf994e84a61d03de10c24e864 100644 |
| --- a/chrome/browser/services/gcm/gcm_account_tracker.h |
| +++ b/chrome/browser/services/gcm/gcm_account_tracker.h |
| @@ -14,12 +14,21 @@ |
| #include "google_apis/gaia/account_tracker.h" |
| #include "google_apis/gaia/oauth2_token_service.h" |
| +namespace base { |
| +class Time; |
| +} |
| + |
| namespace gcm { |
| class GCMDriver; |
| // Class for reporting back which accounts are signed into. It is only meant to |
| // be used when the user is signed into sync. |
| +// |
| +// This class makes a check for tokens periodically, to make sure the user is |
| +// still logged into the profile, so that in the case that the user is not, we |
| +// can immediately report that to the GCM and stop messages addressed to that |
| +// user from ever reaching Chrome. |
| class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| public OAuth2TokenService::Consumer, |
| public GCMConnectionObserver { |
| @@ -76,6 +85,8 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| } |
| private: |
| + friend class GCMAccountTrackerTest; |
| + |
| // Maps account keys to account states. Keyed by account_ids as used by |
| // OAuth2TokenService. |
| typedef std::map<std::string, AccountInfo> AccountInfos; |
| @@ -97,13 +108,22 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| void OnConnected(const net::IPEndPoint& ip_endpoint) override; |
| void OnDisconnected() override; |
| + // Schedules fetching tokens at the time when they are needed to be reported. |
|
Nicolas Zea
2014/11/07 22:19:25
nit: "at the time when they are needed to be repor
fgorski
2014/11/07 22:57:02
Done. Restructured and renamed the GetTimeTo... as
|
| + 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(); |
| + void SanitizeTokens(); |
| + // Indicates whether token reporting is required, either because it is due, or |
| + // some of the accounts were removed. |
| + bool IsTokenReportingRequired() const; |
| + // Indicates whether there are tokens that still need fetching. |
| + bool IsTokenFetchingRequired() const; |
| + // Gets the time until next token fetching. |
| + base::TimeDelta GetTimeToNextTokenFetching() const; |
| // Deletes a token request. Should be called from OnGetTokenSuccess(..) or |
| // OnGetTokenFailure(..). |
| void DeleteTokenRequest(const OAuth2TokenService::Request* request); |
| @@ -133,6 +153,8 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer, |
| ScopedVector<OAuth2TokenService::Request> pending_token_requests_; |
| + base::WeakPtrFactory<GCMAccountTracker> reporting_weak_ptr_factory_; |
|
Nicolas Zea
2014/11/07 22:19:25
nit: comment that this is for ReportTokens usage.
fgorski
2014/11/07 22:57:02
Done.
Nicolas Zea
2014/11/07 23:03:23
Looks like this didn't make it into the patch?
fgorski
2014/11/07 23:29:07
didn't :w it. Updated.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(GCMAccountTracker); |
| }; |