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

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 2767093004: Implement the BackgroundFetch{Fail,ed} Service Worker events (Closed)
Patch Set: forward declare the data view Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 #include "core/dom/MessagePort.h" 39 #include "core/dom/MessagePort.h"
40 #include "core/inspector/ConsoleMessage.h" 40 #include "core/inspector/ConsoleMessage.h"
41 #include "core/origin_trials/OriginTrials.h" 41 #include "core/origin_trials/OriginTrials.h"
42 #include "core/workers/ParentFrameTaskRunners.h" 42 #include "core/workers/ParentFrameTaskRunners.h"
43 #include "core/workers/WorkerGlobalScope.h" 43 #include "core/workers/WorkerGlobalScope.h"
44 #include "core/workers/WorkerThread.h" 44 #include "core/workers/WorkerThread.h"
45 #include "modules/background_fetch/BackgroundFetchClickEvent.h" 45 #include "modules/background_fetch/BackgroundFetchClickEvent.h"
46 #include "modules/background_fetch/BackgroundFetchClickEventInit.h" 46 #include "modules/background_fetch/BackgroundFetchClickEventInit.h"
47 #include "modules/background_fetch/BackgroundFetchEvent.h" 47 #include "modules/background_fetch/BackgroundFetchEvent.h"
48 #include "modules/background_fetch/BackgroundFetchEventInit.h" 48 #include "modules/background_fetch/BackgroundFetchEventInit.h"
49 #include "modules/background_fetch/BackgroundFetchFailEvent.h"
50 #include "modules/background_fetch/BackgroundFetchFailEventInit.h"
51 #include "modules/background_fetch/BackgroundFetchedEvent.h"
52 #include "modules/background_fetch/BackgroundFetchedEventInit.h"
49 #include "modules/background_sync/SyncEvent.h" 53 #include "modules/background_sync/SyncEvent.h"
50 #include "modules/fetch/Headers.h" 54 #include "modules/fetch/Headers.h"
51 #include "modules/notifications/Notification.h" 55 #include "modules/notifications/Notification.h"
52 #include "modules/notifications/NotificationEvent.h" 56 #include "modules/notifications/NotificationEvent.h"
53 #include "modules/notifications/NotificationEventInit.h" 57 #include "modules/notifications/NotificationEventInit.h"
54 #include "modules/payments/PaymentAppRequest.h" 58 #include "modules/payments/PaymentAppRequest.h"
55 #include "modules/payments/PaymentAppRequestConversion.h" 59 #include "modules/payments/PaymentAppRequestConversion.h"
56 #include "modules/payments/PaymentRequestEvent.h" 60 #include "modules/payments/PaymentRequestEvent.h"
57 #include "modules/payments/PaymentRequestRespondWithObserver.h" 61 #include "modules/payments/PaymentRequestRespondWithObserver.h"
58 #include "modules/push_messaging/PushEvent.h" 62 #include "modules/push_messaging/PushEvent.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 init.setState("failed"); 142 init.setState("failed");
139 break; 143 break;
140 } 144 }
141 145
142 BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create( 146 BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create(
143 EventTypeNames::backgroundfetchclick, init, observer); 147 EventTypeNames::backgroundfetchclick, init, observer);
144 148
145 workerGlobalScope()->dispatchExtendableEvent(event, observer); 149 workerGlobalScope()->dispatchExtendableEvent(event, observer);
146 } 150 }
147 151
152 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchFailEvent(
153 int eventID,
154 const WebString& tag,
155 const WebVector<WebBackgroundFetchSettledFetch>& fetches) {
156 WaitUntilObserver* observer = WaitUntilObserver::create(
157 workerGlobalScope(), WaitUntilObserver::BackgroundFetchFail, eventID);
158
159 BackgroundFetchFailEventInit init;
160 init.setTag(tag);
161
162 ScriptState* scriptState =
163 workerGlobalScope()->scriptController()->getScriptState();
164 ScriptState::Scope scope(scriptState);
165
166 BackgroundFetchFailEvent* event =
167 BackgroundFetchFailEvent::create(EventTypeNames::backgroundfetchfail,
168 init, fetches, scriptState, observer);
169
170 workerGlobalScope()->dispatchExtendableEvent(event, observer);
171 }
172
173 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchedEvent(
174 int eventID,
175 const WebString& tag,
176 const WebVector<WebBackgroundFetchSettledFetch>& fetches) {
177 WaitUntilObserver* observer = WaitUntilObserver::create(
178 workerGlobalScope(), WaitUntilObserver::BackgroundFetched, eventID);
179
180 BackgroundFetchedEventInit init;
181 init.setTag(tag);
182
183 ScriptState* scriptState =
184 workerGlobalScope()->scriptController()->getScriptState();
185 ScriptState::Scope scope(scriptState);
186
187 BackgroundFetchedEvent* event = BackgroundFetchedEvent::create(
188 EventTypeNames::backgroundfetched, init, fetches, scriptState, observer,
189 m_workerGlobalScope->registration());
190
191 workerGlobalScope()->dispatchExtendableEvent(event, observer);
192 }
193
148 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) { 194 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) {
149 WaitUntilObserver* observer = WaitUntilObserver::create( 195 WaitUntilObserver* observer = WaitUntilObserver::create(
150 workerGlobalScope(), WaitUntilObserver::Activate, eventID); 196 workerGlobalScope(), WaitUntilObserver::Activate, eventID);
151 Event* event = ExtendableEvent::create(EventTypeNames::activate, 197 Event* event = ExtendableEvent::create(EventTypeNames::activate,
152 ExtendableEventInit(), observer); 198 ExtendableEventInit(), observer);
153 workerGlobalScope()->dispatchExtendableEvent(event, observer); 199 workerGlobalScope()->dispatchExtendableEvent(event, observer);
154 } 200 }
155 201
156 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( 202 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(
157 int eventID, 203 int eventID,
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return *m_document; 589 return *m_document;
544 } 590 }
545 591
546 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() 592 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope()
547 const { 593 const {
548 DCHECK(m_workerGlobalScope); 594 DCHECK(m_workerGlobalScope);
549 return m_workerGlobalScope; 595 return m_workerGlobalScope;
550 } 596 }
551 597
552 } // namespace blink 598 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698