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 #include "components/gcm_driver/gcm_driver.h" | 5 #include "components/gcm_driver/gcm_driver.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 send_callbacks_[key] = callback; | 160 send_callbacks_[key] = callback; |
161 | 161 |
162 SendImpl(app_id, receiver_id, message); | 162 SendImpl(app_id, receiver_id, message); |
163 } | 163 } |
164 | 164 |
165 void GCMDriver::GetEncryptionInfo( | 165 void GCMDriver::GetEncryptionInfo( |
166 const std::string& app_id, | 166 const std::string& app_id, |
167 const GetEncryptionInfoCallback& callback) { | 167 const GetEncryptionInfoCallback& callback) { |
168 encryption_provider_.GetEncryptionInfo(app_id, callback); | 168 encryption_provider_.GetEncryptionInfo(app_id, "" /* authorized_entity */, |
| 169 callback); |
169 } | 170 } |
170 | 171 |
171 void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id, | 172 void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id, |
172 const std::string& sender_id) { | 173 const std::string& sender_id) { |
173 NOTREACHED(); | 174 NOTREACHED(); |
174 } | 175 } |
175 | 176 |
176 void GCMDriver::RegisterFinished(const std::string& app_id, | 177 void GCMDriver::RegisterFinished(const std::string& app_id, |
177 const std::string& registration_id, | 178 const std::string& registration_id, |
178 GCMClient::Result result) { | 179 GCMClient::Result result) { |
179 std::map<std::string, RegisterCallback>::iterator callback_iter = | 180 std::map<std::string, RegisterCallback>::iterator callback_iter = |
180 register_callbacks_.find(app_id); | 181 register_callbacks_.find(app_id); |
181 if (callback_iter == register_callbacks_.end()) { | 182 if (callback_iter == register_callbacks_.end()) { |
182 // The callback could have been removed when the app is uninstalled. | 183 // The callback could have been removed when the app is uninstalled. |
183 return; | 184 return; |
184 } | 185 } |
185 | 186 |
186 RegisterCallback callback = callback_iter->second; | 187 RegisterCallback callback = callback_iter->second; |
187 register_callbacks_.erase(callback_iter); | 188 register_callbacks_.erase(callback_iter); |
188 callback.Run(registration_id, result); | 189 callback.Run(registration_id, result); |
189 } | 190 } |
190 | 191 |
191 void GCMDriver::RemoveEncryptionInfoAfterUnregister(const std::string& app_id, | 192 void GCMDriver::RemoveEncryptionInfoAfterUnregister(const std::string& app_id, |
192 GCMClient::Result result) { | 193 GCMClient::Result result) { |
193 encryption_provider_.RemoveEncryptionInfo( | 194 encryption_provider_.RemoveEncryptionInfo( |
194 app_id, base::Bind(&GCMDriver::UnregisterFinished, | 195 app_id, "" /* authorized_entity */, |
195 weak_ptr_factory_.GetWeakPtr(), app_id, result)); | 196 base::Bind(&GCMDriver::UnregisterFinished, weak_ptr_factory_.GetWeakPtr(), |
| 197 app_id, result)); |
196 } | 198 } |
197 | 199 |
198 void GCMDriver::UnregisterFinished(const std::string& app_id, | 200 void GCMDriver::UnregisterFinished(const std::string& app_id, |
199 GCMClient::Result result) { | 201 GCMClient::Result result) { |
200 std::map<std::string, UnregisterCallback>::iterator callback_iter = | 202 std::map<std::string, UnregisterCallback>::iterator callback_iter = |
201 unregister_callbacks_.find(app_id); | 203 unregister_callbacks_.find(app_id); |
202 if (callback_iter == unregister_callbacks_.end()) | 204 if (callback_iter == unregister_callbacks_.end()) |
203 return; | 205 return; |
204 | 206 |
205 UnregisterCallback callback = callback_iter->second; | 207 UnregisterCallback callback = callback_iter->second; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 GCMClient::Result result) { | 312 GCMClient::Result result) { |
311 // Invoke the original unregister callback. | 313 // Invoke the original unregister callback. |
312 unregister_callback.Run(result); | 314 unregister_callback.Run(result); |
313 | 315 |
314 // Trigger the pending registration. | 316 // Trigger the pending registration. |
315 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); | 317 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); |
316 RegisterImpl(app_id, normalized_sender_ids); | 318 RegisterImpl(app_id, normalized_sender_ids); |
317 } | 319 } |
318 | 320 |
319 } // namespace gcm | 321 } // namespace gcm |
OLD | NEW |