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 a855a18eeb09066ada4fe2961226ec6ca1a21c29..c1ba9437bf7726a716d69a6efdcb246a29ce1c85 100644 |
--- a/chrome/browser/services/gcm/gcm_driver.cc |
+++ b/chrome/browser/services/gcm/gcm_driver.cc |
@@ -489,6 +489,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, |
@@ -700,6 +704,10 @@ GCMClient::Result GCMDriver::EnsureStarted() { |
if (!gcm_enabled_) |
return GCMClient::GCM_DISABLED; |
+ // Has any app requested the service? |
Nicolas Zea
2014/05/22 17:06:31
nit: has -> Have
jianli
2014/05/22 18:09:26
Done.
|
+ 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()) |