| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "google_apis/gcm/engine/heartbeat_manager.h" | 5 #include "google_apis/gcm/engine/heartbeat_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 UpdateHeartbeatInterval(); | 115 UpdateHeartbeatInterval(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 base::TimeTicks HeartbeatManager::GetNextHeartbeatTime() const { | 118 base::TimeTicks HeartbeatManager::GetNextHeartbeatTime() const { |
| 119 if (heartbeat_timer_->IsRunning()) | 119 if (heartbeat_timer_->IsRunning()) |
| 120 return heartbeat_timer_->desired_run_time(); | 120 return heartbeat_timer_->desired_run_time(); |
| 121 else | 121 else |
| 122 return base::TimeTicks(); | 122 return base::TimeTicks(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void HeartbeatManager::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) { | 125 void HeartbeatManager::UpdateHeartbeatTimer( |
| 126 std::unique_ptr<base::Timer> timer) { |
| 126 bool was_running = heartbeat_timer_->IsRunning(); | 127 bool was_running = heartbeat_timer_->IsRunning(); |
| 127 base::TimeDelta remaining_delay = | 128 base::TimeDelta remaining_delay = |
| 128 heartbeat_timer_->desired_run_time() - base::TimeTicks::Now(); | 129 heartbeat_timer_->desired_run_time() - base::TimeTicks::Now(); |
| 129 base::Closure timer_task(heartbeat_timer_->user_task()); | 130 base::Closure timer_task(heartbeat_timer_->user_task()); |
| 130 | 131 |
| 131 heartbeat_timer_->Stop(); | 132 heartbeat_timer_->Stop(); |
| 132 heartbeat_timer_ = std::move(timer); | 133 heartbeat_timer_ = std::move(timer); |
| 133 | 134 |
| 134 if (was_running) | 135 if (was_running) |
| 135 heartbeat_timer_->Start(FROM_HERE, remaining_delay, timer_task); | 136 heartbeat_timer_->Start(FROM_HERE, remaining_delay, timer_task); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 interval <= max_heartbeat_interval; | 294 interval <= max_heartbeat_interval; |
| 294 } | 295 } |
| 295 | 296 |
| 296 void HeartbeatManager::ResetConnection( | 297 void HeartbeatManager::ResetConnection( |
| 297 ConnectionFactory::ConnectionResetReason reason) { | 298 ConnectionFactory::ConnectionResetReason reason) { |
| 298 Stop(); | 299 Stop(); |
| 299 trigger_reconnect_callback_.Run(reason); | 300 trigger_reconnect_callback_.Run(reason); |
| 300 } | 301 } |
| 301 | 302 |
| 302 } // namespace gcm | 303 } // namespace gcm |
| OLD | NEW |