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

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

Issue 2569993002: [ServiceWorker] Mojofy PushEvent of Service Worker. (Closed)
Patch Set: Address comments from Peter and shimazu 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
Index: content/renderer/service_worker/service_worker_context_client.h
diff --git a/content/renderer/service_worker/service_worker_context_client.h b/content/renderer/service_worker/service_worker_context_client.h
index 2686e316ac8aed153985e388c6c2c446880e96ed..4e2752018ec39a7524c02a9b259286b2d8307572 100644
--- a/content/renderer/service_worker/service_worker_context_client.h
+++ b/content/renderer/service_worker/service_worker_context_client.h
@@ -220,6 +220,8 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
const ServiceWorkerFetchRequest& request,
mojom::FetchEventPreloadHandlePtr preload_handle,
const DispatchFetchEventCallback& callback) override;
+ void DispatchPushEvent(const PushEventPayload& payload,
+ const DispatchPushEventCallback& callback) override;
void DispatchSyncEvent(
const std::string& tag,
blink::mojom::BackgroundSyncEventLastChance last_chance,
@@ -233,7 +235,6 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
const PlatformNotificationData& notification_data,
int action_index,
const base::NullableString16& reply);
- void OnPushEvent(int request_id, const PushEventPayload& payload);
void OnNotificationCloseEvent(
int request_id,
const std::string& notification_id,
@@ -291,6 +292,15 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
// destructed on the worker thread in willDestroyWorkerContext.
std::unique_ptr<WorkerContextData> context_;
+ // Use this template in willDestroyWorkerContext to abort all the pending
+ // events callbacks.
+ template <typename T>
+ void AbortPendingEventCallbacks(T& x) {
+ for (typename T::iterator it(&x); !it.IsAtEnd(); it.Advance()) {
Peter Beverloo 2016/12/15 17:35:40 nit: s/x/callbacks/
xiaofengzhang 2016/12/16 02:15:49 Acknowledged.
+ it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now());
+ }
+ }
+
Peter Beverloo 2016/12/15 17:35:39 nit: I'd move this to service_worker_context_clien
xiaofengzhang 2016/12/16 02:15:49 Acknowledged.
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient);
};

Powered by Google App Engine
This is Rietveld 408576698