| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 // Periodic check to see if the heartbeat has been missed due to some system | 85 // Periodic check to see if the heartbeat has been missed due to some system |
| 86 // issue (e.g. the machine was suspended and the timer did not account for | 86 // issue (e.g. the machine was suspended and the timer did not account for |
| 87 // that). | 87 // that). |
| 88 void CheckForMissedHeartbeat(); | 88 void CheckForMissedHeartbeat(); |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 // Restarts the heartbeat timer. | 91 // Restarts the heartbeat timer. |
| 92 void RestartTimer(); | 92 void RestartTimer(); |
| 93 | 93 |
| 94 // Calculates and sets the current heartbeat interval. |
| 95 void UpdateHeartbeatInterval(); |
| 96 |
| 94 // Calculates default heartbeat interval, depending on current network. | 97 // Calculates default heartbeat interval, depending on current network. |
| 95 int GetDefaultHeartbeatInterval(); | 98 int GetDefaultHeartbeatInterval(); |
| 96 | 99 |
| 97 // Stops the heartbeat and triggers connection reset with a |reason|. | 100 // Stops the heartbeat and triggers connection reset with a |reason|. |
| 98 void ResetConnection(ConnectionFactory::ConnectionResetReason reason); | 101 void ResetConnection(ConnectionFactory::ConnectionResetReason reason); |
| 99 | 102 |
| 100 // The base::Time at which the heartbeat timer is expected to fire. Used to | 103 // The base::Time at which the heartbeat timer is expected to fire. Used to |
| 101 // check if a heartbeat was somehow lost/delayed. | 104 // check if a heartbeat was somehow lost/delayed. |
| 102 base::Time heartbeat_expected_time_; | 105 base::Time heartbeat_expected_time_; |
| 103 | 106 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 ReconnectCallback trigger_reconnect_callback_; | 127 ReconnectCallback trigger_reconnect_callback_; |
| 125 | 128 |
| 126 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; | 129 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; |
| 127 | 130 |
| 128 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); | 131 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); |
| 129 }; | 132 }; |
| 130 | 133 |
| 131 } // namespace gcm | 134 } // namespace gcm |
| 132 | 135 |
| 133 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 136 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| OLD | NEW |