| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_PROFILE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 70 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 71 | 71 |
| 72 explicit GCMProfileService(Profile* profile); | 72 explicit GCMProfileService(Profile* profile); |
| 73 virtual ~GCMProfileService(); | 73 virtual ~GCMProfileService(); |
| 74 | 74 |
| 75 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory); | 75 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory); |
| 76 | 76 |
| 77 // Registers |sender_id| for an app. A registration ID will be returned by | 77 // Registers |sender_id| for an app. A registration ID will be returned by |
| 78 // the GCM server. | 78 // the GCM server. |
| 79 // |app_id|: application ID. | 79 // |app_id|: application ID. |
| 80 // |cert|: SHA-1 of public key of the application, in base16 format. | |
| 81 // |sender_ids|: list of IDs of the servers that are allowed to send the | 80 // |sender_ids|: list of IDs of the servers that are allowed to send the |
| 82 // messages to the application. These IDs are assigned by the | 81 // messages to the application. These IDs are assigned by the |
| 83 // Google API Console. | 82 // Google API Console. |
| 84 // |callback|: to be called once the asynchronous operation is done. | 83 // |callback|: to be called once the asynchronous operation is done. |
| 85 virtual void Register(const std::string& app_id, | 84 virtual void Register(const std::string& app_id, |
| 86 const std::vector<std::string>& sender_ids, | 85 const std::vector<std::string>& sender_ids, |
| 87 const std::string& cert, | |
| 88 RegisterCallback callback); | 86 RegisterCallback callback); |
| 89 | 87 |
| 90 // Sends a message to a given receiver. | 88 // Sends a message to a given receiver. |
| 91 // |app_id|: application ID. | 89 // |app_id|: application ID. |
| 92 // |receiver_id|: registration ID of the receiver party. | 90 // |receiver_id|: registration ID of the receiver party. |
| 93 // |message|: message to be sent. | 91 // |message|: message to be sent. |
| 94 // |callback|: to be called once the asynchronous operation is done. | 92 // |callback|: to be called once the asynchronous operation is done. |
| 95 virtual void Send(const std::string& app_id, | 93 virtual void Send(const std::string& app_id, |
| 96 const std::string& receiver_id, | 94 const std::string& receiver_id, |
| 97 const GCMClient::OutgoingMessage& message, | 95 const GCMClient::OutgoingMessage& message, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // destroyed. | 134 // destroyed. |
| 137 void ResetGCMClient(); | 135 void ResetGCMClient(); |
| 138 | 136 |
| 139 // Ensures that the app is ready for GCM functions and events. | 137 // Ensures that the app is ready for GCM functions and events. |
| 140 void EnsureAppReady(const std::string& app_id); | 138 void EnsureAppReady(const std::string& app_id); |
| 141 | 139 |
| 142 // Unregisters an app from using the GCM after it has been uninstalled. | 140 // Unregisters an app from using the GCM after it has been uninstalled. |
| 143 void Unregister(const std::string& app_id); | 141 void Unregister(const std::string& app_id); |
| 144 | 142 |
| 145 void DoRegister(const std::string& app_id, | 143 void DoRegister(const std::string& app_id, |
| 146 const std::vector<std::string>& sender_ids, | 144 const std::vector<std::string>& sender_ids); |
| 147 const std::string& cert); | |
| 148 void DoSend(const std::string& app_id, | 145 void DoSend(const std::string& app_id, |
| 149 const std::string& receiver_id, | 146 const std::string& receiver_id, |
| 150 const GCMClient::OutgoingMessage& message); | 147 const GCMClient::OutgoingMessage& message); |
| 151 | 148 |
| 152 // Callbacks posted from IO thread to UI thread. | 149 // Callbacks posted from IO thread to UI thread. |
| 153 void RegisterFinished(const std::string& app_id, | 150 void RegisterFinished(const std::string& app_id, |
| 154 const std::string& registration_id, | 151 const std::string& registration_id, |
| 155 GCMClient::Result result); | 152 GCMClient::Result result); |
| 156 void SendFinished(const std::string& app_id, | 153 void SendFinished(const std::string& app_id, |
| 157 const std::string& message_id, | 154 const std::string& message_id, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 217 |
| 221 // Used to pass a weak pointer to the IO worker. | 218 // Used to pass a weak pointer to the IO worker. |
| 222 base::WeakPtrFactory<GCMProfileService> weak_ptr_factory_; | 219 base::WeakPtrFactory<GCMProfileService> weak_ptr_factory_; |
| 223 | 220 |
| 224 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); | 221 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); |
| 225 }; | 222 }; |
| 226 | 223 |
| 227 } // namespace gcm | 224 } // namespace gcm |
| 228 | 225 |
| 229 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 226 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| OLD | NEW |