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

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: Adding MCS client tests for storing heartbeat interval 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
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..65f5c3a3661d41ffa8761b215b5c62ccf4566c7a 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 = GetMinHeartbeatInterval();
+ 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 = GetMinHeartbeatInterval();
heartbeat_manager_.SetClientHeartbeatIntervalMs(min_interval_ms);
Nicolas Zea 2015/05/07 18:13:52 Will this ever trigger a connection reset before w
fgorski 2015/05/10 06:44:34 This is not going to trigger before the initial co
}
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 = GetMinHeartbeatInterval();
heartbeat_manager_.SetClientHeartbeatIntervalMs(min_interval);
}
-int MCSClient::GetMinCustomHeartbeatInterval() {
+int MCSClient::GetMinHeartbeatInterval() {
if (custom_heartbeat_intervals_.empty())
return kNoCustomHeartbeat;

Powered by Google App Engine
This is Rietveld 408576698