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

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: Added a callback entry point to GCMDriver, moved MessageReceiptCallback to gcm_message_status. Created 3 years, 10 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..c28dd2d82d344fd22a34c7fec808497ff38612fc 100644
--- a/components/gcm_driver/gcm_driver.cc
+++ b/components/gcm_driver/gcm_driver.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "components/gcm_driver/gcm_app_handler.h"
+#include "components/gcm_driver/gcm_message_status.h"
Peter Beverloo 2017/02/08 17:09:09 nit: this is already included in the header
harkness 2017/02/09 16:27:30 Done.
namespace gcm {
@@ -279,14 +280,17 @@ void GCMDriver::ClearCallbacks() {
}
void GCMDriver::DispatchMessage(const std::string& app_id,
- const IncomingMessage& message) {
+ const IncomingMessage& message,
+ const 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 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:
+ DoSendMessageReceipt(callback, GCMMessageStatus::GCM_ENCRYPTION_FAILURE);
Peter Beverloo 2017/02/08 17:09:09 I'd argue that this should just be SendMessageRece
harkness 2017/02/09 16:27:30 Now it just invokes the callback.
RecordDecryptionFailure(app_id, result);
return;
}

Powered by Google App Engine
This is Rietveld 408576698