Chromium Code Reviews| 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. |