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

Unified Diff: components/gcm_driver/gcm_driver.cc

Issue 1243563002: Teach the GCM Driver how to decrypt incoming messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-push-keys
Patch Set: address comment Created 5 years, 2 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.cc » ('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 4e17801f33539a8a781a0a444656b10e2f3dd7f6..eed7244e730b400fac06691adc1d0fb2c9865442 100644
--- a/components/gcm_driver/gcm_driver.cc
+++ b/components/gcm_driver/gcm_driver.cc
@@ -13,8 +13,17 @@
namespace gcm {
+namespace {
+
const size_t kMaxSenders = 100;
+// TODO(peter): Implement an event for GCMAppHandlers that should be called
+// when decryption of an incoming message has failed.
+void DecryptionFailedCallback(
+ GCMEncryptionProvider::DecryptionFailure reason) {}
+
+} // namespace
+
InstanceIDHandler::InstanceIDHandler() {
}
@@ -258,6 +267,20 @@ void GCMDriver::ClearCallbacks() {
send_callbacks_.clear();
}
+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::DispatchMessage,
+ weak_ptr_factory_.GetWeakPtr(), app_id),
+ base::Bind(&DecryptionFailedCallback));
+}
+
void GCMDriver::RegisterAfterUnregister(
const std::string& app_id,
const std::vector<std::string>& normalized_sender_ids,
« no previous file with comments | « components/gcm_driver/gcm_driver.h ('k') | components/gcm_driver/gcm_driver_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698