| 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 CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // Registers |sender_id| for an app. A registration ID will be returned by | 66 // Registers |sender_id| for an app. A registration ID will be returned by |
| 67 // the GCM server. | 67 // the GCM server. |
| 68 // |app_id|: application ID. | 68 // |app_id|: application ID. |
| 69 // |sender_ids|: list of IDs of the servers that are allowed to send the | 69 // |sender_ids|: list of IDs of the servers that are allowed to send the |
| 70 // messages to the application. These IDs are assigned by the | 70 // messages to the application. These IDs are assigned by the |
| 71 // Google API Console. | 71 // Google API Console. |
| 72 // |callback|: to be called once the asynchronous operation is done. | 72 // |callback|: to be called once the asynchronous operation is done. |
| 73 virtual void Register(const std::string& app_id, | 73 virtual void Register(const std::string& app_id, |
| 74 const std::vector<std::string>& sender_ids, | 74 const std::vector<std::string>& sender_ids, |
| 75 RegisterCallback callback); | 75 const RegisterCallback& callback); |
| 76 | 76 |
| 77 // Unregisters an app from using GCM. | 77 // Unregisters an app from using GCM. |
| 78 // |app_id|: application ID. | 78 // |app_id|: application ID. |
| 79 // |callback|: to be called once the asynchronous operation is done. | 79 // |callback|: to be called once the asynchronous operation is done. |
| 80 virtual void Unregister(const std::string& app_id, | 80 virtual void Unregister(const std::string& app_id, |
| 81 UnregisterCallback callback); | 81 const UnregisterCallback& callback); |
| 82 | 82 |
| 83 // Sends a message to a given receiver. | 83 // Sends a message to a given receiver. |
| 84 // |app_id|: application ID. | 84 // |app_id|: application ID. |
| 85 // |receiver_id|: registration ID of the receiver party. | 85 // |receiver_id|: registration ID of the receiver party. |
| 86 // |message|: message to be sent. | 86 // |message|: message to be sent. |
| 87 // |callback|: to be called once the asynchronous operation is done. | 87 // |callback|: to be called once the asynchronous operation is done. |
| 88 virtual void Send(const std::string& app_id, | 88 virtual void Send(const std::string& app_id, |
| 89 const std::string& receiver_id, | 89 const std::string& receiver_id, |
| 90 const GCMClient::OutgoingMessage& message, | 90 const GCMClient::OutgoingMessage& message, |
| 91 SendCallback callback); | 91 const SendCallback& callback); |
| 92 | 92 |
| 93 // For testing purpose. | 93 // For testing purpose. |
| 94 GCMClient* GetGCMClientForTesting() const; | 94 GCMClient* GetGCMClientForTesting() const; |
| 95 | 95 |
| 96 // Returns true if the service was started. | 96 // Returns true if the service was started. |
| 97 bool IsStarted() const; | 97 bool IsStarted() const; |
| 98 | 98 |
| 99 // Returns true if the gcm client is ready. | 99 // Returns true if the gcm client is ready. |
| 100 bool IsGCMClientReady() const; | 100 bool IsGCMClientReady() const; |
| 101 | 101 |
| 102 // Get GCM client internal states and statistics. | 102 // Get GCM client internal states and statistics. |
| 103 // If clear_logs is true then activity logs will be cleared before the stats | 103 // If clear_logs is true then activity logs will be cleared before the stats |
| 104 // are returned. | 104 // are returned. |
| 105 void GetGCMStatistics(GetGCMStatisticsCallback callback, bool clear_logs); | 105 void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
| 106 bool clear_logs); |
| 106 | 107 |
| 107 // Enables/disables GCM activity recording, and then returns the stats. | 108 // Enables/disables GCM activity recording, and then returns the stats. |
| 108 void SetGCMRecording(GetGCMStatisticsCallback callback, bool recording); | 109 void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
| 110 bool recording); |
| 109 | 111 |
| 110 // IdentityProvider::Observer: | 112 // IdentityProvider::Observer: |
| 111 virtual void OnActiveAccountLogin() OVERRIDE; | 113 virtual void OnActiveAccountLogin() OVERRIDE; |
| 112 virtual void OnActiveAccountLogout() OVERRIDE; | 114 virtual void OnActiveAccountLogout() OVERRIDE; |
| 113 | 115 |
| 114 protected: | 116 protected: |
| 115 virtual bool ShouldStartAutomatically() const = 0; | 117 virtual bool ShouldStartAutomatically() const = 0; |
| 116 | 118 |
| 117 virtual base::FilePath GetStorePath() const = 0; | 119 virtual base::FilePath GetStorePath() const = 0; |
| 118 | 120 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 210 |
| 209 // Used to pass a weak pointer to the IO worker. | 211 // Used to pass a weak pointer to the IO worker. |
| 210 base::WeakPtrFactory<GCMService> weak_ptr_factory_; | 212 base::WeakPtrFactory<GCMService> weak_ptr_factory_; |
| 211 | 213 |
| 212 DISALLOW_COPY_AND_ASSIGN(GCMService); | 214 DISALLOW_COPY_AND_ASSIGN(GCMService); |
| 213 }; | 215 }; |
| 214 | 216 |
| 215 } // namespace gcm | 217 } // namespace gcm |
| 216 | 218 |
| 217 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ | 219 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ |
| OLD | NEW |