Chromium Code Reviews| Index: chrome/browser/services/gcm/gcm_client_mock.h |
| diff --git a/chrome/browser/services/gcm/gcm_client_mock.h b/chrome/browser/services/gcm/gcm_client_mock.h |
| index 485a6a8938d3b62be4efeba2e1b6518041b58ddb..abcb369a395ce892b8e6202ebf8a277c24a20ae0 100644 |
| --- a/chrome/browser/services/gcm/gcm_client_mock.h |
| +++ b/chrome/browser/services/gcm/gcm_client_mock.h |
| @@ -13,8 +13,14 @@ namespace gcm { |
| class GCMClientMock : public GCMClient { |
| public: |
| enum Status { |
| - NOT_READY, |
| - READY |
| + UNINITIALIZED, |
| + LOADED, |
| + CHECKED_OUT |
| + }; |
| + |
| + enum LoadingDelay { |
| + NO_LOADING_DELAY, |
| + LOADING_DELAY, |
|
Nicolas Zea
2014/02/21 20:58:58
nit: loading_delay -> delay_load (make it an actio
jianli
2014/02/22 00:03:06
Done.
|
| }; |
| enum ErrorSimulation { |
| @@ -22,9 +28,9 @@ class GCMClientMock : public GCMClient { |
| FORCE_ERROR |
| }; |
| - // |status| denotes if the fake client is ready or not at the beginning. |
| + // |loading_delay| denotes if the check-in should be delayed. |
| // |error_simulation| denotes if we should simulate server error. |
| - GCMClientMock(Status status, ErrorSimulation error_simulation); |
| + GCMClientMock(LoadingDelay loading_delay, ErrorSimulation error_simulation); |
| virtual ~GCMClientMock(); |
| // Overridden from GCMClient: |
| @@ -36,6 +42,7 @@ class GCMClientMock : public GCMClient { |
| const scoped_refptr<net::URLRequestContextGetter>& |
| url_request_context_getter, |
| Delegate* delegate) OVERRIDE; |
| + virtual void Load() OVERRIDE; |
| virtual void CheckOut() OVERRIDE; |
| virtual void Register(const std::string& app_id, |
| const std::string& cert, |
| @@ -44,7 +51,10 @@ class GCMClientMock : public GCMClient { |
| virtual void Send(const std::string& app_id, |
| const std::string& receiver_id, |
| const OutgoingMessage& message) OVERRIDE; |
| - virtual bool IsReady() const OVERRIDE; |
| + |
| + // Initiate the loading that has been delayed. |
| + // Called on UI thread. |
| + void PerformDelayedLoading(); |
| // Simulate receiving something from the server. |
| // Called on UI thread. |
| @@ -52,14 +62,14 @@ class GCMClientMock : public GCMClient { |
| const IncomingMessage& message); |
| void DeleteMessages(const std::string& app_id); |
| - // Can only transition from non-ready to ready. |
| - void SetReady(); |
| - |
| static std::string GetRegistrationIdFromSenderIds( |
| const std::vector<std::string>& sender_ids); |
| + Status status() const { return status_; } |
| + |
| private: |
| // Called on IO thread. |
| + void CheckinFinished(); |
| void RegisterFinished(const std::string& app_id, |
| const std::string& registrion_id); |
| void SendFinished(const std::string& app_id, const std::string& message_id); |
| @@ -68,10 +78,10 @@ class GCMClientMock : public GCMClient { |
| void MessagesDeleted(const std::string& app_id); |
| void MessageSendError(const std::string& app_id, |
| const std::string& message_id); |
| - void SetReadyOnIO(); |
| Delegate* delegate_; |
| Status status_; |
| + LoadingDelay loading_delay_; |
| ErrorSimulation error_simulation_; |
| DISALLOW_COPY_AND_ASSIGN(GCMClientMock); |