| 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..a7abb80ad3b15fe229eb39765613b0ed2b79998d 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::Load() {
|
| + 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) {
|
| + DLOG_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) {
|
| @@ -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:
|
|
|