| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 CHROME_BROWSER_CHROMEOS_POLICY_HEARTBEAT_SCHEDULER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_HEARTBEAT_SCHEDULER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_HEARTBEAT_SCHEDULER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_HEARTBEAT_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 // True if heartbeats are enabled. Kept cached in this object because | 118 // True if heartbeats are enabled. Kept cached in this object because |
| 119 // CrosSettings can switch to an untrusted state temporarily, and we want | 119 // CrosSettings can switch to an untrusted state temporarily, and we want |
| 120 // to use the last-known trusted values. | 120 // to use the last-known trusted values. |
| 121 bool heartbeat_enabled_; | 121 bool heartbeat_enabled_; |
| 122 | 122 |
| 123 // Cached copy of the current heartbeat interval, in milliseconds. | 123 // Cached copy of the current heartbeat interval, in milliseconds. |
| 124 base::TimeDelta heartbeat_interval_; | 124 base::TimeDelta heartbeat_interval_; |
| 125 | 125 |
| 126 // Observers to changes in the heartbeat settings. | 126 // Observers to changes in the heartbeat settings. |
| 127 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 127 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 128 heartbeat_frequency_observer_; | 128 heartbeat_frequency_observer_; |
| 129 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 129 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 130 heartbeat_enabled_observer_; | 130 heartbeat_enabled_observer_; |
| 131 | 131 |
| 132 // The time the last heartbeat was sent. | 132 // The time the last heartbeat was sent. |
| 133 base::Time last_heartbeat_; | 133 base::Time last_heartbeat_; |
| 134 | 134 |
| 135 // Callback invoked via a delay to send a heartbeat. | 135 // Callback invoked via a delay to send a heartbeat. |
| 136 base::CancelableClosure heartbeat_callback_; | 136 base::CancelableClosure heartbeat_callback_; |
| 137 | 137 |
| 138 policy::CloudPolicyClient* cloud_policy_client_; | 138 policy::CloudPolicyClient* cloud_policy_client_; |
| 139 | 139 |
| 140 // The GCMDriver used to send heartbeat messages. | 140 // The GCMDriver used to send heartbeat messages. |
| 141 gcm::GCMDriver* const gcm_driver_; | 141 gcm::GCMDriver* const gcm_driver_; |
| 142 | 142 |
| 143 // The GCM registration ID - if empty, we are not registered yet. | 143 // The GCM registration ID - if empty, we are not registered yet. |
| 144 std::string registration_id_; | 144 std::string registration_id_; |
| 145 | 145 |
| 146 // If true, we are already registered with GCM and should unregister when | 146 // If true, we are already registered with GCM and should unregister when |
| 147 // destroyed. | 147 // destroyed. |
| 148 bool registered_app_handler_ = false; | 148 bool registered_app_handler_ = false; |
| 149 | 149 |
| 150 // Helper class to manage registering with the GCM server, including | 150 // Helper class to manage registering with the GCM server, including |
| 151 // retries, etc. | 151 // retries, etc. |
| 152 scoped_ptr<HeartbeatRegistrationHelper> registration_helper_; | 152 std::unique_ptr<HeartbeatRegistrationHelper> registration_helper_; |
| 153 | 153 |
| 154 // Note: This should remain the last member so it'll be destroyed and | 154 // Note: This should remain the last member so it'll be destroyed and |
| 155 // invalidate the weak pointers before any other members are destroyed. | 155 // invalidate the weak pointers before any other members are destroyed. |
| 156 base::WeakPtrFactory<HeartbeatScheduler> weak_factory_; | 156 base::WeakPtrFactory<HeartbeatScheduler> weak_factory_; |
| 157 | 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(HeartbeatScheduler); | 158 DISALLOW_COPY_AND_ASSIGN(HeartbeatScheduler); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 } // namespace policy | 161 } // namespace policy |
| 162 | 162 |
| 163 #endif // CHROME_BROWSER_CHROMEOS_POLICY_HEARTBEAT_SCHEDULER_H_ | 163 #endif // CHROME_BROWSER_CHROMEOS_POLICY_HEARTBEAT_SCHEDULER_H_ |
| OLD | NEW |