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

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: 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: 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 491599c7b11a08fc9633158df048fc2ae0712317..50cd0ace12abcc6927bc5126bdc7aadbc4f7bc1a 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;
@@ -162,6 +161,15 @@ void GCMClientImpl::Initialize(
gcm_store_.get()));
}
+ state_ = INITIALIZED;
+}
+
+void GCMClientImpl::CheckIn() {
+ DCHECK_EQ(INITIALIZED, state_);
+
+ // Once the loading is completed, the check-in will be initiated.
+ gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted,
+ weak_ptr_factory_.GetWeakPtr()));
state_ = LOADING;
}
@@ -278,8 +286,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();
}
@@ -368,6 +377,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!";
Alexei Svitkine (slow) 2014/02/21 18:55:40 I think non-debug build log messages are discourag
jianli 2014/02/21 20:24:06 Done.
+ UMA_HISTOGRAM_BOOLEAN("GCM.StoreDestroySucceeded", success);
+}
+
void GCMClientImpl::Send(const std::string& app_id,
const std::string& receiver_id,
const OutgoingMessage& message) {
@@ -395,10 +409,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