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

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

Issue 184273011: Merge 253787 "[GCM] Make sure GCM checkout logic is invoked when..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: 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
===================================================================
--- chrome/browser/services/gcm/gcm_client_mock.h (revision 255183)
+++ chrome/browser/services/gcm/gcm_client_mock.h (working copy)
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_
#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "google_apis/gcm/gcm_client.h"
namespace gcm {
@@ -13,18 +14,24 @@
class GCMClientMock : public GCMClient {
public:
enum Status {
- NOT_READY,
- READY
+ UNINITIALIZED,
+ LOADED,
+ CHECKED_OUT
};
+ enum LoadingDelay {
+ NO_DELAY_LOADING,
+ DELAY_LOADING,
+ };
+
enum ErrorSimulation {
ALWAYS_SUCCEED,
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 +43,7 @@
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,22 +52,26 @@
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.
void ReceiveMessage(const std::string& app_id,
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 DoLoading();
+ 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,11 +80,12 @@
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_;
+ base::WeakPtrFactory<GCMClientMock> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(GCMClientMock);
};
« no previous file with comments | « chrome/browser/services/gcm/fake_gcm_profile_service.cc ('k') | chrome/browser/services/gcm/gcm_client_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698