Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: components/gcm_driver/gcm_driver.cc

Issue 2578583002: Provide a mechanism for the GCM driver to send message receipts to GCM.
Patch Set: Adding new file I missed previously. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698