Index: components/gcm_driver/gcm_driver.cc |
diff --git a/components/gcm_driver/gcm_driver.cc b/components/gcm_driver/gcm_driver.cc |
index 21d30549d07030b043adfa405f0ab45eb6b94931..db6ad414a394ba91b5b5f471005e2a4ee0574a11 100644 |
--- a/components/gcm_driver/gcm_driver.cc |
+++ b/components/gcm_driver/gcm_driver.cc |
@@ -278,15 +278,19 @@ void GCMDriver::ClearCallbacks() { |
send_callbacks_.clear(); |
} |
-void GCMDriver::DispatchMessage(const std::string& app_id, |
- const IncomingMessage& message) { |
+void GCMDriver::DispatchMessage( |
+ const std::string& app_id, |
+ const IncomingMessage& message, |
+ const MessageReceiptCallback& optional_receipt_callback) { |
encryption_provider_.DecryptMessage( |
app_id, message, base::Bind(&GCMDriver::DispatchMessageInternal, |
- weak_ptr_factory_.GetWeakPtr(), app_id)); |
+ weak_ptr_factory_.GetWeakPtr(), app_id, |
+ optional_receipt_callback)); |
} |
void GCMDriver::DispatchMessageInternal( |
const std::string& app_id, |
+ const MessageReceiptCallback& optional_receipt_callback, |
GCMEncryptionProvider::DecryptionResult result, |
const IncomingMessage& message) { |
UMA_HISTOGRAM_ENUMERATION("GCM.Crypto.DecryptMessageResult", result, |
@@ -295,6 +299,8 @@ void GCMDriver::DispatchMessageInternal( |
switch (result) { |
case GCMEncryptionProvider::DECRYPTION_RESULT_UNENCRYPTED: |
case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED: |
+ // TODO(beverloo): When the DefaultAppHandler is gone, call |
+ // SendMessageReceipt here if there isn't a valid app handler. |
GetAppHandler(app_id)->OnMessage(app_id, message); |
return; |
case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_ENCRYPTION_HEADER: |
@@ -302,6 +308,7 @@ void GCMDriver::DispatchMessageInternal( |
case GCMEncryptionProvider::DECRYPTION_RESULT_NO_KEYS: |
case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_SHARED_SECRET: |
case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD: |
+ optional_receipt_callback.Run(GCMMessageStatus::GCM_DECRYPTION_FAILURE); |
RecordDecryptionFailure(app_id, result); |
return; |
} |