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

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: Cleanup. Created 6 years, 4 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 | « chrome/browser/services/gcm/push_messaging_service_impl.h ('k') | content/browser/browser_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 351ca81d3dc05d2d2b77c178bf269d7bf6fcbb31..e8299780d66862392320864f2090f8bea2d207b0 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 "chrome/common/pref_names.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/pref_registry/pref_registry_syncable.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@@ -109,9 +110,16 @@ void PushMessagingServiceImpl::OnMessage(
DCHECK(application_id.IsValid());
GCMClient::MessageData::const_iterator it = message.data.find("data");
if (application_id.IsValid() && 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;
+ content::BrowserContext::DeliverPushMessage(
+ profile_,
+ application_id.origin,
+ application_id.service_worker_registration_id,
+ data,
+ base::Bind(&PushMessagingServiceImpl::DeliverMessageCallback,
+ 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 +129,14 @@ void PushMessagingServiceImpl::OnMessage(
}
}
+void PushMessagingServiceImpl::DeliverMessageCallback(
+ const 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.
« no previous file with comments | « chrome/browser/services/gcm/push_messaging_service_impl.h ('k') | content/browser/browser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698