Index: chrome/browser/services/gcm/gcm_driver.cc |
diff --git a/chrome/browser/services/gcm/gcm_driver.cc b/chrome/browser/services/gcm/gcm_driver.cc |
index 59860c01a787ff6c2864652392293705e62c5cdf..96c21f45201fe1991ddaa33265ba1ecfc5235671 100644 |
--- a/chrome/browser/services/gcm/gcm_driver.cc |
+++ b/chrome/browser/services/gcm/gcm_driver.cc |
@@ -475,6 +475,10 @@ void GCMDriver::RemoveAppHandler(const std::string& app_id) { |
DCHECK(!app_id.empty()); |
app_handlers_.erase(app_id); |
+ |
+ // Stops the GCM service when no app intends to consume it. |
+ if (app_handlers_.empty()) |
+ Stop(); |
} |
void GCMDriver::Register(const std::string& app_id, |
@@ -681,6 +685,10 @@ GCMClient::Result GCMDriver::EnsureStarted() { |
if (!gcm_enabled_) |
return GCMClient::GCM_DISABLED; |
+ // Have any app requested the service? |
+ if (app_handlers_.empty()) |
+ return GCMClient::UNKNOWN_ERROR; |
+ |
// Is the user signed in? |
const std::string account_id = identity_provider_->GetActiveAccountId(); |
if (account_id.empty()) |