Delete the DefaultGCMAppHandler
It's often useful to know (for debugging reasons) whether an event could
be forwarded to its associated GCMAppHandler or not, which we today
don't have a good handle on since it's a silent error case.
By enabling GCMDriver::GetAppHandler() to return a nullptr, we can
remove the DefaultGCMAppHandler and handle it appropriately in the
OnMessage dispatching place, as well as elsewhere.
BUG=
Review-Url: https://codereview.chromium.org/2684283002
Cr-Commit-Position: refs/heads/master@{#452483}
diff --git a/components/gcm_driver/gcm_driver.cc b/components/gcm_driver/gcm_driver.cc
index 21d30549..73c7450 100644
--- a/components/gcm_driver/gcm_driver.cc
+++ b/components/gcm_driver/gcm_driver.cc
@@ -261,7 +261,7 @@
return iter->second;
}
- return &default_app_handler_;
+ return nullptr;
}
GCMEncryptionProvider* GCMDriver::GetEncryptionProviderInternal() {
@@ -294,9 +294,15 @@
switch (result) {
case GCMEncryptionProvider::DECRYPTION_RESULT_UNENCRYPTED:
- case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED:
- GetAppHandler(app_id)->OnMessage(app_id, message);
+ case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED: {
+ GCMAppHandler* handler = GetAppHandler(app_id);
+ if (handler)
+ handler->OnMessage(app_id, message);
+
+ // TODO(peter/harkness): Surface unavailable app handlers on
+ // chrome://gcm-internals and send a delivery receipt.
return;
+ }
case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_ENCRYPTION_HEADER:
case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_CRYPTO_KEY_HEADER:
case GCMEncryptionProvider::DECRYPTION_RESULT_NO_KEYS: