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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // |sender_ids|: list of IDs of the servers that are allowed to send the | 43 // |sender_ids|: list of IDs of the servers that are allowed to send the |
44 // messages to the application. These IDs are assigned by the | 44 // messages to the application. These IDs are assigned by the |
45 // Google API Console. | 45 // Google API Console. |
46 // |callback|: to be called once the asynchronous operation is done. | 46 // |callback|: to be called once the asynchronous operation is done. |
47 void Register(const std::string& app_id, | 47 void Register(const std::string& app_id, |
48 const std::vector<std::string>& sender_ids, | 48 const std::vector<std::string>& sender_ids, |
49 const RegisterCallback& callback); | 49 const RegisterCallback& callback); |
50 | 50 |
51 // Unregisters an app from using GCM. | 51 // Unregisters an app from using GCM. |
52 // |app_id|: application ID. | 52 // |app_id|: application ID. |
| 53 // |sender_ids|: list of IDs of the sender IDs that were passed when |
| 54 // registering. On desktop these are ignored. |
53 // |callback|: to be called once the asynchronous operation is done. | 55 // |callback|: to be called once the asynchronous operation is done. |
54 void Unregister(const std::string& app_id, | 56 void Unregister(const std::string& app_id, |
| 57 const std::vector<std::string>& sender_ids, |
55 const UnregisterCallback& callback); | 58 const UnregisterCallback& callback); |
56 | 59 |
57 // Sends a message to a given receiver. | 60 // Sends a message to a given receiver. |
58 // |app_id|: application ID. | 61 // |app_id|: application ID. |
59 // |receiver_id|: registration ID of the receiver party. | 62 // |receiver_id|: registration ID of the receiver party. |
60 // |message|: message to be sent. | 63 // |message|: message to be sent. |
61 // |callback|: to be called once the asynchronous operation is done. | 64 // |callback|: to be called once the asynchronous operation is done. |
62 void Send(const std::string& app_id, | 65 void Send(const std::string& app_id, |
63 const std::string& receiver_id, | 66 const std::string& receiver_id, |
64 const GCMClient::OutgoingMessage& message, | 67 const GCMClient::OutgoingMessage& message, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 140 |
138 protected: | 141 protected: |
139 // Ensures that the GCM service starts (if necessary conditions are met). | 142 // Ensures that the GCM service starts (if necessary conditions are met). |
140 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; | 143 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; |
141 | 144 |
142 // Platform-specific implementation of Register. | 145 // Platform-specific implementation of Register. |
143 virtual void RegisterImpl(const std::string& app_id, | 146 virtual void RegisterImpl(const std::string& app_id, |
144 const std::vector<std::string>& sender_ids) = 0; | 147 const std::vector<std::string>& sender_ids) = 0; |
145 | 148 |
146 // Platform-specific implementation of Unregister. | 149 // Platform-specific implementation of Unregister. |
147 virtual void UnregisterImpl(const std::string& app_id) = 0; | 150 virtual void UnregisterImpl(const std::string& app_id, |
| 151 const std::vector<std::string>& sender_ids) = 0; |
148 | 152 |
149 // Platform-specific implementation of Send. | 153 // Platform-specific implementation of Send. |
150 virtual void SendImpl(const std::string& app_id, | 154 virtual void SendImpl(const std::string& app_id, |
151 const std::string& receiver_id, | 155 const std::string& receiver_id, |
152 const GCMClient::OutgoingMessage& message) = 0; | 156 const GCMClient::OutgoingMessage& message) = 0; |
153 | 157 |
154 // Runs the Register callback. | 158 // Runs the Register callback. |
155 void RegisterFinished(const std::string& app_id, | 159 void RegisterFinished(const std::string& app_id, |
156 const std::string& registration_id, | 160 const std::string& registration_id, |
157 GCMClient::Result result); | 161 GCMClient::Result result); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 DefaultGCMAppHandler default_app_handler_; | 199 DefaultGCMAppHandler default_app_handler_; |
196 | 200 |
197 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 201 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
198 | 202 |
199 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 203 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
200 }; | 204 }; |
201 | 205 |
202 } // namespace gcm | 206 } // namespace gcm |
203 | 207 |
204 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 208 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
OLD | NEW |