summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-10 05:41:56 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-10 05:41:56 +0000
commit2abca5b9e4882e98dcec6f4c474f08b62624306a (patch)
treeb3de2ea1dffe7f78c0074d9cccbf12b78d6b61f3 /google_apis
parent8a8929a614b78a6c33a3bd9b42a68286237f21de (diff)
downloadchromium_src-2abca5b9e4882e98dcec6f4c474f08b62624306a.zip
chromium_src-2abca5b9e4882e98dcec6f4c474f08b62624306a.tar.gz
chromium_src-2abca5b9e4882e98dcec6f4c474f08b62624306a.tar.bz2
[GCM] Delay running register/send operations when loading is in progress
When GCMProfileService and GCMClient are loading from persistent stores, we need to delay register/send operations until the loading is all done. A new inner class DelayedTaskController has been added to GCMProfileService. Also, GCMClient interface has been updated to add a new method SetDelegate that should be called to passs the delegate for a given user. We used to rely on passing delegate in CheckIn. But it is not always called because the check-in info could be loaded directly from the prefs store. BUG=284553 TEST=existing tests plus new tests added Review URL: https://codereview.chromium.org/103933004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gcm/gcm_client.h11
-rw-r--r--google_apis/gcm/gcm_client_impl.cc7
-rw-r--r--google_apis/gcm/gcm_client_impl.h5
3 files changed, 16 insertions, 7 deletions
diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h
index 66e17a0..dbbf65e 100644
--- a/google_apis/gcm/gcm_client.h
+++ b/google_apis/gcm/gcm_client.h
@@ -142,12 +142,17 @@ class GCM_EXPORT GCMClient {
// Passes a mocked instance for testing purpose.
static void SetForTesting(GCMClient* client);
- // Checks in the user to use GCM. If the device has not been checked in, it
- // will be done first.
+ // Sets the delegate to interact with related to a specific user.
// |username|: the username (email address) used to check in with the server.
// |delegate|: the delegate whose methods will be called asynchronously in
// response to events and messages.
- virtual void CheckIn(const std::string& username, Delegate* delegate) = 0;
+ virtual void SetUserDelegate(const std::string& username,
+ Delegate* delegate) = 0;
+
+ // Checks in the user to use GCM. If the device has not been checked in, it
+ // will be done first.
+ // |username|: the username (email address) used to check in with the server.
+ virtual void CheckIn(const std::string& username) = 0;
// Registers the application for GCM. Delegate::OnRegisterFinished will be
// called asynchronously upon completion.
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index 76900cd..86da9d5 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -12,8 +12,11 @@ GCMClientImpl::GCMClientImpl() {
GCMClientImpl::~GCMClientImpl() {
}
-void GCMClientImpl::CheckIn(const std::string& username,
- Delegate* delegate) {
+void GCMClientImpl::SetUserDelegate(const std::string& username,
+ Delegate* delegate) {
+}
+
+void GCMClientImpl::CheckIn(const std::string& username) {
}
void GCMClientImpl::Register(const std::string& username,
diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h
index 46f910e..797c325 100644
--- a/google_apis/gcm/gcm_client_impl.h
+++ b/google_apis/gcm/gcm_client_impl.h
@@ -16,8 +16,9 @@ class GCMClientImpl : public GCMClient {
virtual ~GCMClientImpl();
// Overridden from GCMClient:
- virtual void CheckIn(const std::string& username,
- Delegate* delegate) OVERRIDE;
+ virtual void SetUserDelegate(const std::string& username,
+ Delegate* delegate) OVERRIDE;
+ virtual void CheckIn(const std::string& username) OVERRIDE;
virtual void Register(const std::string& username,
const std::string& app_id,
const std::string& cert,