| 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/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "components/gcm_driver/default_gcm_app_handler.h" | 15 #include "components/gcm_driver/default_gcm_app_handler.h" |
| 16 #include "components/gcm_driver/gcm_client.h" | 16 #include "components/gcm_driver/gcm_client.h" |
| 17 | 17 |
| 18 namespace gcm { | 18 namespace gcm { |
| 19 | 19 |
| 20 class GCMAppHandler; | 20 class GCMAppHandler; |
| 21 class GCMConnectionObserver; |
| 21 struct AccountMapping; | 22 struct AccountMapping; |
| 22 | 23 |
| 23 // Bridge between GCM users in Chrome and the platform-specific implementation. | 24 // Bridge between GCM users in Chrome and the platform-specific implementation. |
| 24 class GCMDriver { | 25 class GCMDriver { |
| 25 public: | 26 public: |
| 26 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; | 27 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; |
| 27 typedef base::Callback<void(const std::string& registration_id, | 28 typedef base::Callback<void(const std::string& registration_id, |
| 28 GCMClient::Result result)> RegisterCallback; | 29 GCMClient::Result result)> RegisterCallback; |
| 29 typedef base::Callback<void(const std::string& message_id, | 30 typedef base::Callback<void(const std::string& message_id, |
| 30 GCMClient::Result result)> SendCallback; | 31 GCMClient::Result result)> SendCallback; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 // Adds a handler for a given app. | 83 // Adds a handler for a given app. |
| 83 virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler); | 84 virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler); |
| 84 | 85 |
| 85 // Remove the handler for a given app. | 86 // Remove the handler for a given app. |
| 86 virtual void RemoveAppHandler(const std::string& app_id); | 87 virtual void RemoveAppHandler(const std::string& app_id); |
| 87 | 88 |
| 88 // Returns the handler for the given app. | 89 // Returns the handler for the given app. |
| 89 GCMAppHandler* GetAppHandler(const std::string& app_id); | 90 GCMAppHandler* GetAppHandler(const std::string& app_id); |
| 90 | 91 |
| 92 // Adds a connection state observer. |
| 93 virtual void AddConnectionObserver(GCMConnectionObserver* observer); |
| 94 |
| 95 // Removes a connection state observer. |
| 96 virtual void RemoveConnectionObserver(GCMConnectionObserver* observer); |
| 97 |
| 91 // Enables/disables GCM service. | 98 // Enables/disables GCM service. |
| 92 virtual void Enable() = 0; | 99 virtual void Enable() = 0; |
| 93 virtual void Disable() = 0; | 100 virtual void Disable() = 0; |
| 94 | 101 |
| 95 // For testing purpose. Always NULL on Android. | 102 // For testing purpose. Always NULL on Android. |
| 96 virtual GCMClient* GetGCMClientForTesting() const = 0; | 103 virtual GCMClient* GetGCMClientForTesting() const = 0; |
| 97 | 104 |
| 98 // Returns true if the service was started. | 105 // Returns true if the service was started. |
| 99 virtual bool IsStarted() const = 0; | 106 virtual bool IsStarted() const = 0; |
| 100 | 107 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 179 |
| 173 // The default handler when no app handler can be found in the map. | 180 // The default handler when no app handler can be found in the map. |
| 174 DefaultGCMAppHandler default_app_handler_; | 181 DefaultGCMAppHandler default_app_handler_; |
| 175 | 182 |
| 176 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 183 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
| 177 }; | 184 }; |
| 178 | 185 |
| 179 } // namespace gcm | 186 } // namespace gcm |
| 180 | 187 |
| 181 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 188 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| OLD | NEW |