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

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

Issue 2748213003: Service Worker event dispatcher for Background Fetch (Closed)
Patch Set: uma fix 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 24 matching lines...) Expand all
35 #include "bindings/core/v8/SourceLocation.h" 35 #include "bindings/core/v8/SourceLocation.h"
36 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 36 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
37 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
38 #include "core/dom/ExecutionContext.h" 38 #include "core/dom/ExecutionContext.h"
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"
46 #include "modules/background_fetch/BackgroundFetchClickEventInit.h"
47 #include "modules/background_fetch/BackgroundFetchEvent.h"
48 #include "modules/background_fetch/BackgroundFetchEventInit.h"
45 #include "modules/background_sync/SyncEvent.h" 49 #include "modules/background_sync/SyncEvent.h"
46 #include "modules/fetch/Headers.h" 50 #include "modules/fetch/Headers.h"
47 #include "modules/notifications/Notification.h" 51 #include "modules/notifications/Notification.h"
48 #include "modules/notifications/NotificationEvent.h" 52 #include "modules/notifications/NotificationEvent.h"
49 #include "modules/notifications/NotificationEventInit.h" 53 #include "modules/notifications/NotificationEventInit.h"
50 #include "modules/payments/PaymentAppRequest.h" 54 #include "modules/payments/PaymentAppRequest.h"
51 #include "modules/payments/PaymentAppRequestConversion.h" 55 #include "modules/payments/PaymentAppRequestConversion.h"
52 #include "modules/payments/PaymentRequestEvent.h" 56 #include "modules/payments/PaymentRequestEvent.h"
53 #include "modules/push_messaging/PushEvent.h" 57 #include "modules/push_messaging/PushEvent.h"
54 #include "modules/push_messaging/PushMessageData.h" 58 #include "modules/push_messaging/PushMessageData.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 visitor->trace(m_document); 95 visitor->trace(m_document);
92 visitor->trace(m_parentFrameTaskRunners); 96 visitor->trace(m_parentFrameTaskRunners);
93 visitor->trace(m_pendingPreloadFetchEvents); 97 visitor->trace(m_pendingPreloadFetchEvents);
94 } 98 }
95 99
96 void ServiceWorkerGlobalScopeProxy::setRegistration( 100 void ServiceWorkerGlobalScopeProxy::setRegistration(
97 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) { 101 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) {
98 workerGlobalScope()->setRegistration(std::move(handle)); 102 workerGlobalScope()->setRegistration(std::move(handle));
99 } 103 }
100 104
105 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchAbortEvent(
106 int eventID,
107 const WebString& tag) {
108 WaitUntilObserver* observer = WaitUntilObserver::create(
109 workerGlobalScope(), WaitUntilObserver::BackgroundFetchAbort, eventID);
110
111 BackgroundFetchClickEventInit init;
112 init.setTag(tag);
113
114 BackgroundFetchEvent* event = BackgroundFetchEvent::create(
115 EventTypeNames::backgroundfetchabort, init, observer);
116
117 workerGlobalScope()->dispatchExtendableEvent(event, observer);
118 }
119
120 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchClickEvent(
121 int eventID,
122 const WebString& tag,
123 BackgroundFetchState status) {
124 WaitUntilObserver* observer = WaitUntilObserver::create(
125 workerGlobalScope(), WaitUntilObserver::BackgroundFetchClick, eventID);
126
127 BackgroundFetchClickEventInit init;
128 init.setTag(tag);
129
130 switch (status) {
131 case BackgroundFetchState::Pending:
132 init.setState("pending");
133 break;
134 case BackgroundFetchState::Succeeded:
135 init.setState("succeeded");
136 break;
137 case BackgroundFetchState::Failed:
138 init.setState("failed");
139 break;
140 }
141
142 BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create(
143 EventTypeNames::backgroundfetchclick, init, observer);
144
145 workerGlobalScope()->dispatchExtendableEvent(event, observer);
146 }
147
101 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) { 148 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) {
102 WaitUntilObserver* observer = WaitUntilObserver::create( 149 WaitUntilObserver* observer = WaitUntilObserver::create(
103 workerGlobalScope(), WaitUntilObserver::Activate, eventID); 150 workerGlobalScope(), WaitUntilObserver::Activate, eventID);
104 Event* event = ExtendableEvent::create(EventTypeNames::activate, 151 Event* event = ExtendableEvent::create(EventTypeNames::activate,
105 ExtendableEventInit(), observer); 152 ExtendableEventInit(), observer);
106 workerGlobalScope()->dispatchExtendableEvent(event, observer); 153 workerGlobalScope()->dispatchExtendableEvent(event, observer);
107 } 154 }
108 155
109 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( 156 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(
110 int eventID, 157 int eventID,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return *m_document; 531 return *m_document;
485 } 532 }
486 533
487 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() 534 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope()
488 const { 535 const {
489 DCHECK(m_workerGlobalScope); 536 DCHECK(m_workerGlobalScope);
490 return m_workerGlobalScope; 537 return m_workerGlobalScope;
491 } 538 }
492 539
493 } // namespace blink 540 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698