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

Unified Diff: chrome/browser/services/gcm/push_messaging_service_impl.cc

Issue 340773006: Dispatch push event to worker from PushServiceImpl#OnMessage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get registration from storage if necessary. Created 6 years, 5 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: chrome/browser/services/gcm/push_messaging_service_impl.cc
diff --git a/chrome/browser/services/gcm/push_messaging_service_impl.cc b/chrome/browser/services/gcm/push_messaging_service_impl.cc
index c52b5d2af3353c0a6afab6991ae184a2886993f2..5c4be27acf9e38ead130154d4779d69058b4d259 100644
--- a/chrome/browser/services/gcm/push_messaging_service_impl.cc
+++ b/chrome/browser/services/gcm/push_messaging_service_impl.cc
@@ -21,6 +21,7 @@
#include "components/gcm_driver/gcm_driver.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/push_messaging_application_id.h"
+#include "content/public/browser/push_messaging_router.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@@ -73,6 +74,7 @@ PushMessagingServiceImpl::PushMessagingServiceImpl(
: gcm_profile_service_(gcm_profile_service),
profile_(profile),
weak_factory_(this) {
+ push_messaging_router_ = content::PushMessagingRouter::Create(profile);
johnme 2014/07/23 14:25:23 Nit: I guess this could be in the initializer list
Michael van Ouwerkerk 2014/07/23 16:57:51 Done.
}
PushMessagingServiceImpl::~PushMessagingServiceImpl() {
@@ -109,9 +111,14 @@ void PushMessagingServiceImpl::OnMessage(
DCHECK(application_id.is_valid());
GCMClient::MessageData::const_iterator it = message.data.find("data");
if (application_id.is_valid() && it != message.data.end()) {
- const std::string& data ALLOW_UNUSED = it->second;
- // TODO(mvanouwerkerk): Fire push event with data on the Service Worker
- // corresponding to app_id (and remove ALLOW_UNUSED above).
+ const std::string& data = it->second;
+ push_messaging_router_->SendMessage(
+ application_id,
+ data,
+ base::Bind(&PushMessagingServiceImpl::SendMessageCallback,
+ weak_factory_.GetWeakPtr(),
+ application_id,
+ message));
} else {
// Drop the message, as it is invalid.
// TODO(mvanouwerkerk): Show a warning in the developer console of the
@@ -121,6 +128,14 @@ void PushMessagingServiceImpl::OnMessage(
}
}
+void PushMessagingServiceImpl::SendMessageCallback(
+ const content::PushMessagingApplicationId& application_id,
+ const GCMClient::IncomingMessage& message,
+ content::PushMessagingStatus status) {
+ // TODO(mvanouwerkerk): UMA logging.
+ // TODO(mvanouwerkerk): Is there a way to recover from failure?
+}
+
void PushMessagingServiceImpl::OnMessagesDeleted(const std::string& app_id) {
// TODO(mvanouwerkerk): Fire push error event on the Service Worker
// corresponding to app_id.

Powered by Google App Engine
This is Rietveld 408576698