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

Unified Diff: components/gcm_driver/gcm_driver.cc

Issue 1707513002: Add various UMA histograms for measuring GCM crypto performance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-remove-info
Patch Set: android fix Created 4 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
« no previous file with comments | « components/gcm_driver/gcm_driver.h ('k') | components/gcm_driver/gcm_driver_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/gcm_driver.cc
diff --git a/components/gcm_driver/gcm_driver.cc b/components/gcm_driver/gcm_driver.cc
index 9594492da8fb63fcc7746cbfd0f307f0f3e086d5..5232c0d819f1d38ef3e68841404b52a8b4ace8f1 100644
--- a/components/gcm_driver/gcm_driver.cc
+++ b/components/gcm_driver/gcm_driver.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
#include "components/gcm_driver/gcm_app_handler.h"
namespace gcm {
@@ -273,17 +274,33 @@ void GCMDriver::ClearCallbacks() {
void GCMDriver::DispatchMessage(const std::string& app_id,
const IncomingMessage& message) {
- if (!encryption_provider_.IsEncryptedMessage(message)) {
- GetAppHandler(app_id)->OnMessage(app_id, message);
- return;
+ encryption_provider_.DecryptMessage(
+ app_id, message, base::Bind(&GCMDriver::DispatchMessageInternal,
+ weak_ptr_factory_.GetWeakPtr(), app_id));
+}
+
+void GCMDriver::DispatchMessageInternal(
+ const std::string& app_id,
+ GCMEncryptionProvider::DecryptionResult result,
+ const IncomingMessage& message) {
+ UMA_HISTOGRAM_ENUMERATION("GCM.Crypto.DecryptMessageResult", result,
+ GCMEncryptionProvider::DECRYPTION_RESULT_LAST + 1);
+
+ switch (result) {
+ case GCMEncryptionProvider::DECRYPTION_RESULT_UNENCRYPTED:
+ case GCMEncryptionProvider::DECRYPTION_RESULT_DECRYPTED:
+ GetAppHandler(app_id)->OnMessage(app_id, message);
+ return;
+ case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_ENCRYPTION_HEADER:
+ case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_CRYPTO_KEY_HEADER:
+ case GCMEncryptionProvider::DECRYPTION_RESULT_NO_KEYS:
+ case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_SHARED_SECRET:
+ case GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD:
+ RecordDecryptionFailure(app_id, result);
+ return;
}
- encryption_provider_.DecryptMessage(
- app_id, message,
- base::Bind(&GCMDriver::DispatchMessage,
- weak_ptr_factory_.GetWeakPtr(), app_id),
- base::Bind(&GCMDriver::RecordDecryptionFailure,
- weak_ptr_factory_.GetWeakPtr(), app_id));
+ NOTREACHED();
}
void GCMDriver::RegisterAfterUnregister(
« no previous file with comments | « components/gcm_driver/gcm_driver.h ('k') | components/gcm_driver/gcm_driver_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698