| 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 #ifndef GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/power_monitor/power_observer.h" | 14 #include "base/power_monitor/power_observer.h" |
| 14 #include "google_apis/gcm/base/gcm_export.h" | 15 #include "google_apis/gcm/base/gcm_export.h" |
| 15 #include "google_apis/gcm/engine/connection_factory.h" | 16 #include "google_apis/gcm/engine/connection_factory.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class Timer; | 19 class Timer; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace mcs_proto { | 22 namespace mcs_proto { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 // Updates the current heartbeat interval. | 53 // Updates the current heartbeat interval. |
| 53 void UpdateHeartbeatConfig(const mcs_proto::HeartbeatConfig& config); | 54 void UpdateHeartbeatConfig(const mcs_proto::HeartbeatConfig& config); |
| 54 | 55 |
| 55 // Returns the next scheduled heartbeat time. A null time means | 56 // Returns the next scheduled heartbeat time. A null time means |
| 56 // no heartbeat is pending. If non-null and less than the | 57 // no heartbeat is pending. If non-null and less than the |
| 57 // current time (in ticks), the heartbeat has been triggered and an ack is | 58 // current time (in ticks), the heartbeat has been triggered and an ack is |
| 58 // pending. | 59 // pending. |
| 59 base::TimeTicks GetNextHeartbeatTime() const; | 60 base::TimeTicks GetNextHeartbeatTime() const; |
| 60 | 61 |
| 61 // Updates the timer used for scheduling heartbeats. | 62 // Updates the timer used for scheduling heartbeats. |
| 62 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer); | 63 void UpdateHeartbeatTimer(std::unique_ptr<base::Timer> timer); |
| 63 | 64 |
| 64 // base::PowerObserver override. | 65 // base::PowerObserver override. |
| 65 void OnSuspend() override; | 66 void OnSuspend() override; |
| 66 void OnResume() override; | 67 void OnResume() override; |
| 67 | 68 |
| 68 // Maximum and minimum of the custom client interval that can be requested, | 69 // Maximum and minimum of the custom client interval that can be requested, |
| 69 // calculated based on the network conditions. | 70 // calculated based on the network conditions. |
| 70 int GetMaxClientHeartbeatIntervalMs(); | 71 int GetMaxClientHeartbeatIntervalMs(); |
| 71 int GetMinClientHeartbeatIntervalMs(); | 72 int GetMinClientHeartbeatIntervalMs(); |
| 72 | 73 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // The current heartbeat interval. | 111 // The current heartbeat interval. |
| 111 int heartbeat_interval_ms_; | 112 int heartbeat_interval_ms_; |
| 112 // The most recent server-provided heartbeat interval (0 if none has been | 113 // The most recent server-provided heartbeat interval (0 if none has been |
| 113 // provided). | 114 // provided). |
| 114 int server_interval_ms_; | 115 int server_interval_ms_; |
| 115 | 116 |
| 116 // Custom interval requested by the client. | 117 // Custom interval requested by the client. |
| 117 int client_interval_ms_; | 118 int client_interval_ms_; |
| 118 | 119 |
| 119 // Timer for triggering heartbeats. | 120 // Timer for triggering heartbeats. |
| 120 scoped_ptr<base::Timer> heartbeat_timer_; | 121 std::unique_ptr<base::Timer> heartbeat_timer_; |
| 121 | 122 |
| 122 // Time at which the machine was last suspended. | 123 // Time at which the machine was last suspended. |
| 123 base::Time suspend_time_; | 124 base::Time suspend_time_; |
| 124 | 125 |
| 125 // Callbacks for interacting with the the connection. | 126 // Callbacks for interacting with the the connection. |
| 126 base::Closure send_heartbeat_callback_; | 127 base::Closure send_heartbeat_callback_; |
| 127 ReconnectCallback trigger_reconnect_callback_; | 128 ReconnectCallback trigger_reconnect_callback_; |
| 128 | 129 |
| 129 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; | 130 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; |
| 130 | 131 |
| 131 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); | 132 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); |
| 132 }; | 133 }; |
| 133 | 134 |
| 134 } // namespace gcm | 135 } // namespace gcm |
| 135 | 136 |
| 136 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 137 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| OLD | NEW |