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 "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Returns the next scheduled heartbeat time. A null time means | 54 // Returns the next scheduled heartbeat time. A null time means |
55 // no heartbeat is pending. If non-null and less than the | 55 // no heartbeat is pending. If non-null and less than the |
56 // current time (in ticks), the heartbeat has been triggered and an ack is | 56 // current time (in ticks), the heartbeat has been triggered and an ack is |
57 // pending. | 57 // pending. |
58 base::TimeTicks GetNextHeartbeatTime() const; | 58 base::TimeTicks GetNextHeartbeatTime() const; |
59 | 59 |
60 // Updates the timer used for scheduling heartbeats. | 60 // Updates the timer used for scheduling heartbeats. |
61 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer); | 61 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer); |
62 | 62 |
63 // base::PowerObserver override. | 63 // base::PowerObserver override. |
| 64 void OnSuspend() override; |
64 void OnResume() override; | 65 void OnResume() override; |
65 | 66 |
66 // Maximum and minimum of the custom client interval that can be requested, | 67 // Maximum and minimum of the custom client interval that can be requested, |
67 // calculated based on the network conditions. | 68 // calculated based on the network conditions. |
68 int GetMaxClientHeartbeatIntervalMs(); | 69 int GetMaxClientHeartbeatIntervalMs(); |
69 int GetMinClientHeartbeatIntervalMs(); | 70 int GetMinClientHeartbeatIntervalMs(); |
70 | 71 |
71 // Sets, gets and validates the custom client interval. If the interval is | 72 // Sets, gets and validates the custom client interval. If the interval is |
72 // less than the current custom heartbeat interval, the connection will be | 73 // less than the current custom heartbeat interval, the connection will be |
73 // reset to update the receiving server. | 74 // reset to update the receiving server. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // The most recent server-provided heartbeat interval (0 if none has been | 108 // The most recent server-provided heartbeat interval (0 if none has been |
108 // provided). | 109 // provided). |
109 int server_interval_ms_; | 110 int server_interval_ms_; |
110 | 111 |
111 // Custom interval requested by the client. | 112 // Custom interval requested by the client. |
112 int client_interval_ms_; | 113 int client_interval_ms_; |
113 | 114 |
114 // Timer for triggering heartbeats. | 115 // Timer for triggering heartbeats. |
115 scoped_ptr<base::Timer> heartbeat_timer_; | 116 scoped_ptr<base::Timer> heartbeat_timer_; |
116 | 117 |
| 118 // Time at which the machine was last suspended. |
| 119 base::Time suspend_time_; |
| 120 |
117 // Callbacks for interacting with the the connection. | 121 // Callbacks for interacting with the the connection. |
118 base::Closure send_heartbeat_callback_; | 122 base::Closure send_heartbeat_callback_; |
119 ReconnectCallback trigger_reconnect_callback_; | 123 ReconnectCallback trigger_reconnect_callback_; |
120 | 124 |
121 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; | 125 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; |
122 | 126 |
123 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); | 127 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); |
124 }; | 128 }; |
125 | 129 |
126 } // namespace gcm | 130 } // namespace gcm |
127 | 131 |
128 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 132 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
OLD | NEW |