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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "components/gcm_driver/gcm_app_handler.h" | 14 #include "components/gcm_driver/gcm_app_handler.h" |
15 | 15 |
16 namespace gcm { | 16 namespace gcm { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const size_t kMaxSenders = 100; | 20 const size_t kMaxSenders = 100; |
21 | 21 |
22 // TODO(peter): Implement an event for GCMAppHandlers that should be called | |
23 // when decryption of an incoming message has failed. | |
24 void DecryptionFailedCallback( | |
25 GCMEncryptionProvider::DecryptionFailure reason) {} | |
26 | |
27 } // namespace | 22 } // namespace |
28 | 23 |
29 InstanceIDHandler::InstanceIDHandler() { | 24 InstanceIDHandler::InstanceIDHandler() { |
30 } | 25 } |
31 | 26 |
32 InstanceIDHandler::~InstanceIDHandler() { | 27 InstanceIDHandler::~InstanceIDHandler() { |
33 } | 28 } |
34 | 29 |
35 void InstanceIDHandler::DeleteAllTokensForApp( | 30 void InstanceIDHandler::DeleteAllTokensForApp( |
36 const std::string& app_id, const DeleteTokenCallback& callback) { | 31 const std::string& app_id, const DeleteTokenCallback& callback) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 const IncomingMessage& message) { | 268 const IncomingMessage& message) { |
274 if (!encryption_provider_.IsEncryptedMessage(message)) { | 269 if (!encryption_provider_.IsEncryptedMessage(message)) { |
275 GetAppHandler(app_id)->OnMessage(app_id, message); | 270 GetAppHandler(app_id)->OnMessage(app_id, message); |
276 return; | 271 return; |
277 } | 272 } |
278 | 273 |
279 encryption_provider_.DecryptMessage( | 274 encryption_provider_.DecryptMessage( |
280 app_id, message, | 275 app_id, message, |
281 base::Bind(&GCMDriver::DispatchMessage, | 276 base::Bind(&GCMDriver::DispatchMessage, |
282 weak_ptr_factory_.GetWeakPtr(), app_id), | 277 weak_ptr_factory_.GetWeakPtr(), app_id), |
283 base::Bind(&DecryptionFailedCallback)); | 278 base::Bind(&GCMDriver::RecordDecryptionFailure, |
| 279 weak_ptr_factory_.GetWeakPtr(), app_id)); |
284 } | 280 } |
285 | 281 |
286 void GCMDriver::RegisterAfterUnregister( | 282 void GCMDriver::RegisterAfterUnregister( |
287 const std::string& app_id, | 283 const std::string& app_id, |
288 const std::vector<std::string>& normalized_sender_ids, | 284 const std::vector<std::string>& normalized_sender_ids, |
289 const UnregisterCallback& unregister_callback, | 285 const UnregisterCallback& unregister_callback, |
290 GCMClient::Result result) { | 286 GCMClient::Result result) { |
291 // Invoke the original unregister callback. | 287 // Invoke the original unregister callback. |
292 unregister_callback.Run(result); | 288 unregister_callback.Run(result); |
293 | 289 |
294 // Trigger the pending registration. | 290 // Trigger the pending registration. |
295 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); | 291 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); |
296 RegisterImpl(app_id, normalized_sender_ids); | 292 RegisterImpl(app_id, normalized_sender_ids); |
297 } | 293 } |
298 | 294 |
299 } // namespace gcm | 295 } // namespace gcm |
OLD | NEW |