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

Unified Diff: chrome/browser/services/gcm/gcm_client_mock.h

Issue 165993005: [GCM] Make sure GCM checkout logic is invoked when the profile is signed out (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
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..99c3ba6eeb35893958d6578915840cb7d6d24271 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,
+ CHECKED_IN,
+ CHECKED_OUT
+ };
+
+ enum CheckinDelay {
+ NO_CHECKIN_DELAY,
+ CHECKIN_DELAY,
};
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.
+ // |checkin_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(CheckinDelay checkin_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 CheckIn() 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 checkin that has been delayed.
+ // Called on UI thread.
+ void PerformDelayedCheckIn();
// 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_;
+ CheckinDelay checkin_delay_;
ErrorSimulation error_simulation_;
DISALLOW_COPY_AND_ASSIGN(GCMClientMock);

Powered by Google App Engine
This is Rietveld 408576698