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 COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 virtual base::Time GetLastTokenFetchTime() = 0; | 162 virtual base::Time GetLastTokenFetchTime() = 0; |
163 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; | 163 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; |
164 | 164 |
165 // Sets whether or not GCM should try to wake the system from suspend in order | 165 // Sets whether or not GCM should try to wake the system from suspend in order |
166 // to send a heartbeat message. | 166 // to send a heartbeat message. |
167 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; | 167 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; |
168 | 168 |
169 // Supports saving the Instance ID data in the GCM store. | 169 // Supports saving the Instance ID data in the GCM store. |
170 virtual InstanceIDStore* GetInstanceIDStore() = 0; | 170 virtual InstanceIDStore* GetInstanceIDStore() = 0; |
171 | 171 |
| 172 // Adds or removes a custom client requested heartbeat interval. If multiple |
| 173 // components set that setting, the lowest setting will be used. If the |
| 174 // setting is outside of GetMax/MinClientHeartbeatIntervalMs() it will be |
| 175 // ignored. If a new setting is less than the currently used, the connection |
| 176 // will be reset with the new heartbeat. Client that no longer require |
| 177 // aggressive heartbeats, should remove their requested interval. Heartbeats |
| 178 // set this way survive connection/Chrome restart. |
| 179 // |
| 180 // GCM Driver can decide to postpone the action until Client is properly |
| 181 // initialized, hence this setting can be called at any time. |
| 182 // |
| 183 // Server can overwrite the setting to a different value. |
| 184 // |
| 185 // |scope| is used to identify the component that requests a custom interval |
| 186 // to be set, and allows that component to later revoke the setting. |
| 187 // |interval_ms| should be between 2 minues and 15 minues (28 minues on |
| 188 // cellular networks). For details check |
| 189 // GetMin/MaxClientHeartbeatItnervalMs() in HeartbeatManager. |
| 190 virtual void AddHeartbeatInterval(const std::string& scope, |
| 191 int interval_ms) = 0; |
| 192 virtual void RemoveHeartbeatInterval(const std::string& scope) = 0; |
| 193 |
172 protected: | 194 protected: |
173 // Ensures that the GCM service starts (if necessary conditions are met). | 195 // Ensures that the GCM service starts (if necessary conditions are met). |
174 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; | 196 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; |
175 | 197 |
176 // Platform-specific implementation of Register. | 198 // Platform-specific implementation of Register. |
177 virtual void RegisterImpl(const std::string& app_id, | 199 virtual void RegisterImpl(const std::string& app_id, |
178 const std::vector<std::string>& sender_ids) = 0; | 200 const std::vector<std::string>& sender_ids) = 0; |
179 | 201 |
180 // Platform-specific implementation of Unregister. | 202 // Platform-specific implementation of Unregister. |
181 virtual void UnregisterImpl(const std::string& app_id) = 0; | 203 virtual void UnregisterImpl(const std::string& app_id) = 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 DefaultGCMAppHandler default_app_handler_; | 260 DefaultGCMAppHandler default_app_handler_; |
239 | 261 |
240 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 262 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
241 | 263 |
242 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 264 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
243 }; | 265 }; |
244 | 266 |
245 } // namespace gcm | 267 } // namespace gcm |
246 | 268 |
247 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 269 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
OLD | NEW |