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

Unified Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2600863002: Revert of [ServiceWorker] Mojofy PushEvent of Service Worker. (Closed)
Patch Set: Created 4 years 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 | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/service_worker/service_worker_context_client.cc
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc
index 4e54c503a0a56a51ca7307f1756744371145e6c7..c4b51fb99a0920dfd06c7cd1fb8d61bc40513075 100644
--- a/content/renderer/service_worker/service_worker_context_client.cc
+++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -165,15 +165,6 @@
return web_client_info;
}
-// Use this template in willDestroyWorkerContext to abort all the pending
-// events callbacks.
-template <typename T>
-void AbortPendingEventCallbacks(T& callbacks) {
- for (typename T::iterator it(&callbacks); !it.IsAtEnd(); it.Advance()) {
- it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now());
- }
-}
-
} // namespace
// Holding data that needs to be bound to the worker context on the
@@ -188,8 +179,6 @@
using SkipWaitingCallbacksMap =
IDMap<std::unique_ptr<blink::WebServiceWorkerSkipWaitingCallbacks>>;
using SyncEventCallbacksMap = IDMap<std::unique_ptr<const SyncCallback>>;
- using PushEventCallbacksMap =
- IDMap<std::unique_ptr<const DispatchPushEventCallback>>;
using FetchEventCallbacksMap = IDMap<std::unique_ptr<const FetchCallback>>;
using ExtendableMessageEventCallbacksMap =
IDMap<std::unique_ptr<const DispatchExtendableMessageEventCallback>>;
@@ -221,9 +210,6 @@
// Pending callbacks for Background Sync Events.
SyncEventCallbacksMap sync_event_callbacks;
-
- // Pending callbacks for Push Events.
- PushEventCallbacksMap push_event_callbacks;
// Pending callbacks for Fetch Events.
FetchEventCallbacksMap fetch_event_callbacks;
@@ -420,6 +406,7 @@
OnNotificationClickEvent)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationCloseEvent,
OnNotificationCloseEvent)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClient, OnDidGetClient)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClients, OnDidGetClients)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse,
@@ -581,11 +568,24 @@
// (while we're still on the worker thread).
proxy_ = NULL;
- // Aborts all the pending events callbacks.
- AbortPendingEventCallbacks(context_->sync_event_callbacks);
- AbortPendingEventCallbacks(context_->push_event_callbacks);
- AbortPendingEventCallbacks(context_->fetch_event_callbacks);
- AbortPendingEventCallbacks(context_->message_event_callbacks);
+ // Aborts the all pending sync event callbacks.
+ for (WorkerContextData::SyncEventCallbacksMap::iterator it(
+ &context_->sync_event_callbacks);
+ !it.IsAtEnd(); it.Advance()) {
+ it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now());
+ }
+ // Aborts the all pending fetch event callbacks.
+ for (WorkerContextData::FetchEventCallbacksMap::iterator it(
+ &context_->fetch_event_callbacks);
+ !it.IsAtEnd(); it.Advance()) {
+ it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now());
+ }
+ // Aborts the all pending extendable message event callbacks.
+ for (WorkerContextData::ExtendableMessageEventCallbacksMap::iterator it(
+ &context_->message_event_callbacks);
+ !it.IsAtEnd(); it.Advance()) {
+ it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now());
+ }
// We have to clear callbacks now, as they need to be freed on the
// same thread.
@@ -761,14 +761,9 @@
int request_id,
blink::WebServiceWorkerEventResult result,
double event_dispatch_time) {
- const DispatchPushEventCallback* callback =
- context_->push_event_callbacks.Lookup(request_id);
- DCHECK(callback);
- callback->Run(result == blink::WebServiceWorkerEventResultCompleted
- ? SERVICE_WORKER_OK
- : SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED,
- base::Time::FromDoubleT(event_dispatch_time));
- context_->push_event_callbacks.Remove(request_id);
+ Send(new ServiceWorkerHostMsg_PushEventFinished(
+ GetRoutingID(), request_id, result,
+ base::Time::FromDoubleT(event_dispatch_time)));
}
void ServiceWorkerContextClient::didHandleSyncEvent(
@@ -1061,14 +1056,10 @@
ToWebNotificationData(notification_data));
}
-void ServiceWorkerContextClient::DispatchPushEvent(
- const PushEventPayload& payload,
- const DispatchPushEventCallback& callback) {
- TRACE_EVENT0("ServiceWorker",
- "ServiceWorkerContextClient::DispatchPushEvent");
- int request_id = context_->push_event_callbacks.Add(
- base::MakeUnique<DispatchPushEventCallback>(callback));
-
+void ServiceWorkerContextClient::OnPushEvent(int request_id,
+ const PushEventPayload& payload) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerContextClient::OnPushEvent");
// Only set data to be a valid string if the payload had decrypted data.
blink::WebString data;
if (!payload.is_null)
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698