| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "components/gcm_driver/default_gcm_app_handler.h" | 16 #include "components/gcm_driver/default_gcm_app_handler.h" |
| 17 #include "components/gcm_driver/gcm_client.h" | 17 #include "components/gcm_driver/gcm_client.h" |
| 18 | 18 |
| 19 namespace gcm { | 19 namespace gcm { |
| 20 | 20 |
| 21 class GCMAppHandler; | 21 class GCMAppHandler; |
| 22 class GCMConnectionObserver; | 22 class GCMConnectionObserver; |
| 23 struct AccountMapping; | 23 struct AccountMapping; |
| 24 | 24 |
| 25 // Provides the capability to set/get InstanceID data in the GCM store. |
| 26 class InstanceIDStore { |
| 27 public: |
| 28 typedef base::Callback<void(const std::string& instance_id_data)> |
| 29 GetInstanceIDDataCallback; |
| 30 |
| 31 InstanceIDStore(); |
| 32 virtual ~InstanceIDStore(); |
| 33 |
| 34 virtual void AddInstanceIDData(const std::string& app_id, |
| 35 const std::string& instance_id_data) = 0; |
| 36 virtual void RemoveInstanceIDData(const std::string& app_id) = 0; |
| 37 virtual void GetInstanceIDData( |
| 38 const std::string& app_id, |
| 39 const GetInstanceIDDataCallback& callback) = 0; |
| 40 |
| 41 private: |
| 42 DISALLOW_COPY_AND_ASSIGN(InstanceIDStore); |
| 43 }; |
| 44 |
| 25 // Bridge between GCM users in Chrome and the platform-specific implementation. | 45 // Bridge between GCM users in Chrome and the platform-specific implementation. |
| 26 class GCMDriver { | 46 class GCMDriver { |
| 27 public: | 47 public: |
| 28 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; | 48 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; |
| 29 typedef base::Callback<void(const std::string& registration_id, | 49 typedef base::Callback<void(const std::string& registration_id, |
| 30 GCMClient::Result result)> RegisterCallback; | 50 GCMClient::Result result)> RegisterCallback; |
| 31 typedef base::Callback<void(const std::string& message_id, | 51 typedef base::Callback<void(const std::string& message_id, |
| 32 GCMClient::Result result)> SendCallback; | 52 GCMClient::Result result)> SendCallback; |
| 33 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; | 53 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; |
| 34 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> | 54 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 virtual void RemoveAccountMapping(const std::string& account_id) = 0; | 159 virtual void RemoveAccountMapping(const std::string& account_id) = 0; |
| 140 | 160 |
| 141 // Getter and setter of last token fetch time. | 161 // Getter and setter of last token fetch time. |
| 142 virtual base::Time GetLastTokenFetchTime() = 0; | 162 virtual base::Time GetLastTokenFetchTime() = 0; |
| 143 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; | 163 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; |
| 144 | 164 |
| 145 // 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 |
| 146 // to send a heartbeat message. | 166 // to send a heartbeat message. |
| 147 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; | 167 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; |
| 148 | 168 |
| 169 // Supports saving the Instance ID data in the GCM store. |
| 170 virtual InstanceIDStore* GetInstanceIDStore() = 0; |
| 171 |
| 149 protected: | 172 protected: |
| 150 // Ensures that the GCM service starts (if necessary conditions are met). | 173 // Ensures that the GCM service starts (if necessary conditions are met). |
| 151 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; | 174 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; |
| 152 | 175 |
| 153 // Platform-specific implementation of Register. | 176 // Platform-specific implementation of Register. |
| 154 virtual void RegisterImpl(const std::string& app_id, | 177 virtual void RegisterImpl(const std::string& app_id, |
| 155 const std::vector<std::string>& sender_ids) = 0; | 178 const std::vector<std::string>& sender_ids) = 0; |
| 156 | 179 |
| 157 // Platform-specific implementation of Unregister. | 180 // Platform-specific implementation of Unregister. |
| 158 virtual void UnregisterImpl(const std::string& app_id) = 0; | 181 virtual void UnregisterImpl(const std::string& app_id) = 0; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 DefaultGCMAppHandler default_app_handler_; | 238 DefaultGCMAppHandler default_app_handler_; |
| 216 | 239 |
| 217 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 240 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
| 218 | 241 |
| 219 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 242 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
| 220 }; | 243 }; |
| 221 | 244 |
| 222 } // namespace gcm | 245 } // namespace gcm |
| 223 | 246 |
| 224 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 247 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| OLD | NEW |