Index: components/gcm_driver/gcm_driver_desktop.cc |
diff --git a/components/gcm_driver/gcm_driver_desktop.cc b/components/gcm_driver/gcm_driver_desktop.cc |
index b82f340b19cd3662327622b7248faec97e701cc1..6661ceee35c81a6e4a3e2fd7970d9e4eef789753 100644 |
--- a/components/gcm_driver/gcm_driver_desktop.cc |
+++ b/components/gcm_driver/gcm_driver_desktop.cc |
@@ -347,6 +347,7 @@ GCMDriverDesktop::GCMDriverDesktop( |
gcm_started_(false), |
gcm_enabled_(true), |
connected_(false), |
+ account_mapper_(new GCMAccountMapper(this)), |
ui_thread_(ui_thread), |
io_thread_(io_thread), |
weak_ptr_factory_(this) { |
@@ -391,8 +392,9 @@ void GCMDriverDesktop::OnSignedOut() { |
// When sign-in enforcement is not dropped, we will stop the GCM connection |
// when the user signs out. |
- if (!GCMDriver::IsAllowedForAllUsers()) |
+ if (!GCMDriver::IsAllowedForAllUsers()) { |
Stop(); |
+ } |
} |
void GCMDriverDesktop::Purge() { |
@@ -418,9 +420,11 @@ void GCMDriverDesktop::RemoveAppHandler(const std::string& app_id) { |
DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
GCMDriver::RemoveAppHandler(app_id); |
- // Stops the GCM service when no app intends to consume it. |
- if (app_handlers().empty()) |
+ // Stops the GCM service when no app intends to consume it. Stop function will |
+ // remove the last app handler - account mapper. |
+ if (app_handlers().size() == 1) { |
Stop(); |
+ } |
} |
void GCMDriverDesktop::AddConnectionObserver(GCMConnectionObserver* observer) { |
@@ -461,6 +465,9 @@ void GCMDriverDesktop::Stop() { |
gcm_channel_status_syncer_->Stop(); |
+ account_mapper_->ShutdownHandler(); |
+ GCMDriver::RemoveAppHandler(kGCMAccountMapperAppId); |
+ |
RemoveCachedData(); |
io_thread_->PostTask( |
@@ -620,6 +627,8 @@ void GCMDriverDesktop::SetAccountTokens( |
const std::vector<GCMClient::AccountTokenInfo>& account_tokens) { |
DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
+ account_mapper_->SetAccountTokens(account_tokens); |
+ |
io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriverDesktop::IOWorker::SetAccountTokens, |
@@ -726,6 +735,8 @@ void GCMDriverDesktop::GCMClientReady( |
const std::vector<AccountMapping>& account_mappings) { |
DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
+ account_mapper_->Initialize(account_mappings); |
+ |
delayed_task_controller_->SetReady(); |
} |