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..2d55abeb6d185fd5a19b9910f408ef2a2df39f23 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 GCMClient::MessageReceiptCallback& callback) { |
encryption_provider_.DecryptMessage( |
- app_id, message, base::Bind(&GCMDriver::DispatchMessageInternal, |
- weak_ptr_factory_.GetWeakPtr(), app_id)); |
+ app_id, message, |
+ base::Bind(&GCMDriver::DispatchMessageInternal, |
+ weak_ptr_factory_.GetWeakPtr(), app_id, callback)); |
} |
void GCMDriver::DispatchMessageInternal( |
const std::string& app_id, |
+ const GCMClient::MessageReceiptCallback& 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: |
+ callback.Run(GCM_ENCRYPTION_FAILURE); |
RecordDecryptionFailure(app_id, result); |
return; |
} |