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

Unified Diff: google_apis/gcm/engine/mcs_client.cc

Issue 1124783002: [GCM] Wiring heartbeat interval calls to GCMDriver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@store-heartbeat-gcm
Patch Set: Addressing final feedback and fixing formatting Created 5 years, 7 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
« no previous file with comments | « google_apis/gcm/engine/mcs_client.h ('k') | google_apis/gcm/engine/mcs_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/engine/mcs_client.cc
diff --git a/google_apis/gcm/engine/mcs_client.cc b/google_apis/gcm/engine/mcs_client.cc
index 3b1016dc2e2b25693a7fb59396fd665471ea9341..9b4607d7b6768183a8d456d2dcb13aa749ad993e 100644
--- a/google_apis/gcm/engine/mcs_client.cc
+++ b/google_apis/gcm/engine/mcs_client.cc
@@ -276,6 +276,12 @@ void MCSClient::Initialize(
collapse_key_map_[collapse_key] = packet_info;
}
}
+
+ // Establish if there is any custom client interval persisted from the last
+ // run and set it on the heartbeat manager.
+ custom_heartbeat_intervals_.swap(load_result->heartbeat_intervals);
+ int min_interval_ms = GetMinHeartbeatIntervalMs();
+ heartbeat_manager_.SetClientHeartbeatIntervalMs(min_interval_ms);
}
void MCSClient::Login(uint64 android_id, uint64 security_token) {
@@ -380,19 +386,25 @@ void MCSClient::AddHeartbeatInterval(const std::string& scope,
return;
custom_heartbeat_intervals_[scope] = interval_ms;
- // TODO(fgorski): Save in the gcm store as well.
+ gcm_store_->AddHeartbeatInterval(scope, interval_ms,
+ base::Bind(&MCSClient::OnGCMUpdateFinished,
+ weak_ptr_factory_.GetWeakPtr()));
- int min_interval_ms = GetMinCustomHeartbeatInterval();
+ int min_interval_ms = GetMinHeartbeatIntervalMs();
heartbeat_manager_.SetClientHeartbeatIntervalMs(min_interval_ms);
}
void MCSClient::RemoveHeartbeatInterval(const std::string& scope) {
custom_heartbeat_intervals_.erase(scope);
- int min_interval = GetMinCustomHeartbeatInterval();
+ gcm_store_->RemoveHeartbeatInterval(
+ scope, base::Bind(&MCSClient::OnGCMUpdateFinished,
+ weak_ptr_factory_.GetWeakPtr()));
+
+ int min_interval = GetMinHeartbeatIntervalMs();
heartbeat_manager_.SetClientHeartbeatIntervalMs(min_interval);
}
-int MCSClient::GetMinCustomHeartbeatInterval() {
+int MCSClient::GetMinHeartbeatIntervalMs() {
if (custom_heartbeat_intervals_.empty())
return kNoCustomHeartbeat;
« no previous file with comments | « google_apis/gcm/engine/mcs_client.h ('k') | google_apis/gcm/engine/mcs_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698