| 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);
|
| }
|
|
|
| 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;
|
|
|
|
|