OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "web/ServiceWorkerGlobalScopeProxy.h" | 31 #include "web/ServiceWorkerGlobalScopeProxy.h" |
32 | 32 |
33 #include "bindings/core/v8/SourceLocation.h" | 33 #include "bindings/core/v8/SourceLocation.h" |
34 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 34 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/dom/ExecutionContextTask.h" | 37 #include "core/dom/ExecutionContextTask.h" |
38 #include "core/dom/MessagePort.h" | 38 #include "core/dom/MessagePort.h" |
39 #include "core/inspector/ConsoleMessage.h" | 39 #include "core/inspector/ConsoleMessage.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" |
40 #include "core/origin_trials/OriginTrials.h" | 41 #include "core/origin_trials/OriginTrials.h" |
41 #include "core/workers/ParentFrameTaskRunners.h" | 42 #include "core/workers/ParentFrameTaskRunners.h" |
42 #include "core/workers/WorkerGlobalScope.h" | 43 #include "core/workers/WorkerGlobalScope.h" |
43 #include "core/workers/WorkerThread.h" | 44 #include "core/workers/WorkerThread.h" |
44 #include "modules/background_sync/SyncEvent.h" | 45 #include "modules/background_sync/SyncEvent.h" |
45 #include "modules/fetch/Headers.h" | 46 #include "modules/fetch/Headers.h" |
46 #include "modules/notifications/Notification.h" | 47 #include "modules/notifications/Notification.h" |
47 #include "modules/notifications/NotificationEvent.h" | 48 #include "modules/notifications/NotificationEvent.h" |
48 #include "modules/notifications/NotificationEventInit.h" | 49 #include "modules/notifications/NotificationEventInit.h" |
49 #include "modules/payments/PaymentAppRequestData.h" | 50 #include "modules/payments/PaymentAppRequestData.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 waitUntilObserver->willDispatchEvent(); | 191 waitUntilObserver->willDispatchEvent(); |
191 respondWithObserver->willDispatchEvent(); | 192 respondWithObserver->willDispatchEvent(); |
192 DispatchEventResult dispatchResult = | 193 DispatchEventResult dispatchResult = |
193 workerGlobalScope()->dispatchEvent(fetchEvent); | 194 workerGlobalScope()->dispatchEvent(fetchEvent); |
194 respondWithObserver->didDispatchEvent(dispatchResult); | 195 respondWithObserver->didDispatchEvent(dispatchResult); |
195 // false is okay because waitUntil for fetch event doesn't care about the | 196 // false is okay because waitUntil for fetch event doesn't care about the |
196 // promise rejection or an uncaught runtime script error. | 197 // promise rejection or an uncaught runtime script error. |
197 waitUntilObserver->didDispatchEvent(false /* errorOccurred */); | 198 waitUntilObserver->didDispatchEvent(false /* errorOccurred */); |
198 } | 199 } |
199 | 200 |
| 201 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadSent( |
| 202 int fetchEventID, |
| 203 const WebURL& url, |
| 204 double sentTimestamp, |
| 205 double sentWallTime) { |
| 206 InspectorInstrumentation::didSendNavigationPreload( |
| 207 workerGlobalScope(), fetchEventID, url, sentTimestamp, sentWallTime); |
| 208 } |
| 209 |
200 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadResponse( | 210 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadResponse( |
201 int fetchEventID, | 211 int fetchEventID, |
202 std::unique_ptr<WebURLResponse> response, | 212 std::unique_ptr<WebURLResponse> response, |
203 std::unique_ptr<WebDataConsumerHandle> dataConsumeHandle) { | 213 std::unique_ptr<WebDataConsumerHandle> dataConsumeHandle) { |
| 214 InspectorInstrumentation::didReceiveNavigationPreloadResponse( |
| 215 workerGlobalScope(), fetchEventID, response->toResourceResponse()); |
204 FetchEvent* fetchEvent = m_pendingPreloadFetchEvents.take(fetchEventID); | 216 FetchEvent* fetchEvent = m_pendingPreloadFetchEvents.take(fetchEventID); |
205 DCHECK(fetchEvent); | 217 DCHECK(fetchEvent); |
206 fetchEvent->onNavigationPreloadResponse( | 218 fetchEvent->onNavigationPreloadResponse( |
207 workerGlobalScope()->scriptController()->getScriptState(), | 219 workerGlobalScope()->scriptController()->getScriptState(), |
208 std::move(response), std::move(dataConsumeHandle)); | 220 std::move(response), std::move(dataConsumeHandle)); |
209 } | 221 } |
210 | 222 |
211 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadError( | 223 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadError( |
212 int fetchEventID, | 224 int fetchEventID, |
213 std::unique_ptr<WebServiceWorkerError> error) { | 225 std::unique_ptr<WebServiceWorkerError> error) { |
| 226 InspectorInstrumentation::didReceiveNavigationPreloadError( |
| 227 workerGlobalScope(), fetchEventID, error->message); |
214 FetchEvent* fetchEvent = m_pendingPreloadFetchEvents.take(fetchEventID); | 228 FetchEvent* fetchEvent = m_pendingPreloadFetchEvents.take(fetchEventID); |
215 // This method may be called after onNavigationPreloadResponse() was called. | 229 // This method may be called after onNavigationPreloadResponse() was called. |
216 if (!fetchEvent) | 230 if (!fetchEvent) |
217 return; | 231 return; |
218 fetchEvent->onNavigationPreloadError( | 232 fetchEvent->onNavigationPreloadError( |
219 workerGlobalScope()->scriptController()->getScriptState(), | 233 workerGlobalScope()->scriptController()->getScriptState(), |
220 std::move(error)); | 234 std::move(error)); |
221 } | 235 } |
222 | 236 |
| 237 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadCompleted( |
| 238 int fetchEventID) { |
| 239 InspectorInstrumentation::didCompleteNavigationPreload(workerGlobalScope(), |
| 240 fetchEventID); |
| 241 } |
| 242 |
223 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent( | 243 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent( |
224 int fetchEventID, | 244 int fetchEventID, |
225 const WebServiceWorkerRequest& webRequest) { | 245 const WebServiceWorkerRequest& webRequest) { |
226 if (!OriginTrials::foreignFetchEnabled(workerGlobalScope())) { | 246 if (!OriginTrials::foreignFetchEnabled(workerGlobalScope())) { |
227 // If origin trial tokens have expired, or are otherwise no longer valid | 247 // If origin trial tokens have expired, or are otherwise no longer valid |
228 // no events should be dispatched. | 248 // no events should be dispatched. |
229 // TODO(mek): Ideally the browser wouldn't even start the service worker | 249 // TODO(mek): Ideally the browser wouldn't even start the service worker |
230 // if its tokens have expired. | 250 // if its tokens have expired. |
231 ServiceWorkerGlobalScopeClient::from(workerGlobalScope()) | 251 ServiceWorkerGlobalScopeClient::from(workerGlobalScope()) |
232 ->respondToFetchEvent(fetchEventID, WTF::currentTime()); | 252 ->respondToFetchEvent(fetchEventID, WTF::currentTime()); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 return *m_document; | 508 return *m_document; |
489 } | 509 } |
490 | 510 |
491 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() | 511 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() |
492 const { | 512 const { |
493 DCHECK(m_workerGlobalScope); | 513 DCHECK(m_workerGlobalScope); |
494 return m_workerGlobalScope; | 514 return m_workerGlobalScope; |
495 } | 515 } |
496 | 516 |
497 } // namespace blink | 517 } // namespace blink |
OLD | NEW |