| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 void GCMDriver::DispatchMessageInternal( | 282 void GCMDriver::DispatchMessageInternal( |
| 283 const std::string& app_id, | 283 const std::string& app_id, |
| 284 GCMEncryptionProvider::DecryptionResult result, | 284 GCMEncryptionProvider::DecryptionResult result, |
| 285 const IncomingMessage& message) { | 285 const IncomingMessage& message) { |
| 286 UMA_HISTOGRAM_ENUMERATION("GCM.Crypto.DecryptMessageResult", result, | 286 UMA_HISTOGRAM_ENUMERATION("GCM.Crypto.DecryptMessageResult", result, |
| 287 GCMEncryptionProvider::DECRYPTION_RESULT_LAST + 1); | 287 GCMEncryptionProvider::DECRYPTION_RESULT_LAST + 1); |
| 288 | 288 |
| 289 switch (result) { | 289 switch (result) { |
| 290 case GCMEncryptionProvider::DECRYPTION_RESULT_UNENCRYPTED: | 290 case GCMEncryptionProvider::DECRYPTION_RESULT_UNENCRYPTED: |
| 291 case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED: { | 291 case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED_DRAFT_03: |
| 292 case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED_DRAFT_08: { |
| 292 GCMAppHandler* handler = GetAppHandler(app_id); | 293 GCMAppHandler* handler = GetAppHandler(app_id); |
| 293 if (handler) | 294 if (handler) |
| 294 handler->OnMessage(app_id, message); | 295 handler->OnMessage(app_id, message); |
| 295 | 296 |
| 296 // TODO(peter/harkness): Surface unavailable app handlers on | 297 // TODO(peter/harkness): Surface unavailable app handlers on |
| 297 // chrome://gcm-internals and send a delivery receipt. | 298 // chrome://gcm-internals and send a delivery receipt. |
| 298 return; | 299 return; |
| 299 } | 300 } |
| 300 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_ENCRYPTION_HEADER: | 301 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_ENCRYPTION_HEADER: |
| 301 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_CRYPTO_KEY_HEADER: | 302 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_CRYPTO_KEY_HEADER: |
| 302 case GCMEncryptionProvider::DECRYPTION_RESULT_NO_KEYS: | 303 case GCMEncryptionProvider::DECRYPTION_RESULT_NO_KEYS: |
| 303 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_SHARED_SECRET: | 304 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_SHARED_SECRET: |
| 304 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD: | 305 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD: |
| 306 case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_BINARY_HEADER: |
| 305 RecordDecryptionFailure(app_id, result); | 307 RecordDecryptionFailure(app_id, result); |
| 306 return; | 308 return; |
| 307 } | 309 } |
| 308 | 310 |
| 309 NOTREACHED(); | 311 NOTREACHED(); |
| 310 } | 312 } |
| 311 | 313 |
| 312 void GCMDriver::RegisterAfterUnregister( | 314 void GCMDriver::RegisterAfterUnregister( |
| 313 const std::string& app_id, | 315 const std::string& app_id, |
| 314 const std::vector<std::string>& normalized_sender_ids, | 316 const std::vector<std::string>& normalized_sender_ids, |
| 315 const UnregisterCallback& unregister_callback, | 317 const UnregisterCallback& unregister_callback, |
| 316 GCMClient::Result result) { | 318 GCMClient::Result result) { |
| 317 // Invoke the original unregister callback. | 319 // Invoke the original unregister callback. |
| 318 unregister_callback.Run(result); | 320 unregister_callback.Run(result); |
| 319 | 321 |
| 320 // Trigger the pending registration. | 322 // Trigger the pending registration. |
| 321 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); | 323 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); |
| 322 RegisterImpl(app_id, normalized_sender_ids); | 324 RegisterImpl(app_id, normalized_sender_ids); |
| 323 } | 325 } |
| 324 | 326 |
| 325 } // namespace gcm | 327 } // namespace gcm |
| OLD | NEW |