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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Updates the current heartbeat interval. | 46 // Updates the current heartbeat interval. |
47 void UpdateHeartbeatConfig(const mcs_proto::HeartbeatConfig& config); | 47 void UpdateHeartbeatConfig(const mcs_proto::HeartbeatConfig& config); |
48 | 48 |
49 // Returns the next scheduled heartbeat time. A null time means | 49 // Returns the next scheduled heartbeat time. A null time means |
50 // no heartbeat is pending. If non-null and less than the | 50 // no heartbeat is pending. If non-null and less than the |
51 // current time (in ticks), the heartbeat has been triggered and an ack is | 51 // current time (in ticks), the heartbeat has been triggered and an ack is |
52 // pending. | 52 // pending. |
53 base::TimeTicks GetNextHeartbeatTime() const; | 53 base::TimeTicks GetNextHeartbeatTime() const; |
54 | 54 |
| 55 // Updates the timer used for scheduling heartbeats. |
| 56 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer); |
| 57 |
55 protected: | 58 protected: |
56 // Helper method to send heartbeat on timer trigger. | 59 // Helper method to send heartbeat on timer trigger. |
57 void OnHeartbeatTriggered(); | 60 void OnHeartbeatTriggered(); |
58 | 61 |
59 // Periodic check to see if the heartbeat has been missed due to some system | 62 // Periodic check to see if the heartbeat has been missed due to some system |
60 // issue (e.g. the machine was suspended and the timer did not account for | 63 // issue (e.g. the machine was suspended and the timer did not account for |
61 // that). | 64 // that). |
62 void CheckForMissedHeartbeat(); | 65 void CheckForMissedHeartbeat(); |
63 | 66 |
64 private: | 67 private: |
(...skipping 21 matching lines...) Expand all Loading... |
86 base::Closure trigger_reconnect_callback_; | 89 base::Closure trigger_reconnect_callback_; |
87 | 90 |
88 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; | 91 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); | 93 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace gcm | 96 } // namespace gcm |
94 | 97 |
95 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 98 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
OLD | NEW |