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

Unified Diff: components/gcm_driver/gcm_driver_desktop.cc

Issue 618003002: [GCM] Handling connection events in GCMAccountTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to Jian Li's patch and addressing unit tests failures Created 6 years, 2 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: 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();
}

Powered by Google App Engine
This is Rietveld 408576698