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

Unified Diff: google_apis/gcm/gcm_client_impl.cc

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: Fix trybots 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: google_apis/gcm/gcm_client_impl.cc
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index b0160d6665d2e1781e3c22dfa69f6de7e7cb652f..339f73f5d6a68ae9b719b588c61279ad0ddf8dc5 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
#include "base/time/default_clock.h"
#include "google_apis/gcm/base/mcs_message.h"
@@ -138,8 +139,6 @@ void GCMClientImpl::Initialize(
url_request_context_getter_ = url_request_context_getter;
gcm_store_.reset(new GCMStoreImpl(false, path, blocking_task_runner));
- gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted,
- weak_ptr_factory_.GetWeakPtr()));
delegate_ = delegate;
@@ -160,7 +159,12 @@ void GCMClientImpl::Initialize(
connection_factory_.get(),
gcm_store_.get()));
}
fgorski 2014/02/20 22:18:40 Add a INITIALIZED to the State enum in the header
jianli 2014/02/21 18:25:11 Done.
+}
+void GCMClientImpl::CheckIn() {
fgorski 2014/02/20 22:18:40 Add a DCHECK_EQ(state_, INITIALIZED);
jianli 2014/02/21 18:25:11 Done.
+ // Once the loading is completed, the check-in will be initiated.
+ gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted,
+ weak_ptr_factory_.GetWeakPtr()));
state_ = LOADING;
}
@@ -277,8 +281,9 @@ void GCMClientImpl::SetDeviceCredentialsCallback(bool success) {
void GCMClientImpl::CheckOut() {
delegate_ = NULL;
device_checkin_info_.Reset();
- mcs_client_->Destroy(); // This will also destroy GCM store.
mcs_client_.reset();
+ gcm_store_->Destroy(base::Bind(&GCMClientImpl::OnGCMStoreDestroyed,
+ weak_ptr_factory_.GetWeakPtr()));
checkin_request_.reset();
pending_registrations_.clear();
}
@@ -367,6 +372,11 @@ void GCMClientImpl::OnUnregisterCompleted(const std::string& app_id,
pending_unregistrations_.erase(iter);
}
+void GCMClientImpl::OnGCMStoreDestroyed(bool success) {
+ LOG_IF(ERROR, !success) << "GCM store failed to be destroyed!";
+ UMA_HISTOGRAM_BOOLEAN("GCM.StoreDestroySucceeded", success);
+}
+
void GCMClientImpl::Send(const std::string& app_id,
const std::string& receiver_id,
const OutgoingMessage& message) {
@@ -394,10 +404,6 @@ void GCMClientImpl::Send(const std::string& app_id,
mcs_client_->SendMessage(mcs_message);
}
-bool GCMClientImpl::IsReady() const {
- return state_ == READY;
-}
-
void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) {
switch (message.tag()) {
case kLoginResponseTag:

Powered by Google App Engine
This is Rietveld 408576698