Index: components/gcm_driver/gcm_client_impl.cc |
diff --git a/components/gcm_driver/gcm_client_impl.cc b/components/gcm_driver/gcm_client_impl.cc |
index 1c3f8bfe7444738f4948f5a9cf4380d671552b47..4c1c77c57ca5ebc9bf0cd5703c642207e9377b2a 100644 |
--- a/components/gcm_driver/gcm_client_impl.cc |
+++ b/components/gcm_driver/gcm_client_impl.cc |
@@ -361,8 +361,14 @@ void GCMClientImpl::Start(StartMode start_mode) { |
return; |
// Once the loading is completed, the check-in will be initiated. |
- gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, |
- weak_ptr_factory_.GetWeakPtr())); |
+ // If we're in lazy start mode, don't create a new store since none is really |
+ // using GCM functionality yet. |
+ gcm_store_->Load( |
+ (start_mode == IMMEDIATE_START) ? |
+ GCMStore::CREATE_NEW_STORE_IF_NOT_EXISTS : |
+ GCMStore::DO_NOT_CREATE_NEW_STORE, |
+ base::Bind(&GCMClientImpl::OnLoadCompleted, |
+ weak_ptr_factory_.GetWeakPtr())); |
state_ = LOADING; |
} |
@@ -370,7 +376,15 @@ void GCMClientImpl::OnLoadCompleted(scoped_ptr<GCMStore::LoadResult> result) { |
DCHECK_EQ(LOADING, state_); |
if (!result->success) { |
- ResetStore(); |
+ if (result->store_does_not_exist) { |
+ // In the case that the store does not exist, setting |state| back to |
Nicolas Zea
2015/06/15 17:58:37
nit: settings -> set
jianli
2015/06/15 20:50:23
Done.
|
+ // INITIALIZED such that store loading could be triggered again when |
+ // Start() is called with IMMEDIATE_START. |
+ state_ = INITIALIZED; |
+ } else { |
+ // Otherwise, destroy the store to try again. |
+ ResetStore(); |
+ } |
return; |
} |
gcm_store_reset_ = false; |