| 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 DCHECK(fetchEvent); | 229 DCHECK(fetchEvent); |
| 216 fetchEvent->onNavigationPreloadError( | 230 fetchEvent->onNavigationPreloadError( |
| 217 workerGlobalScope()->scriptController()->getScriptState(), | 231 workerGlobalScope()->scriptController()->getScriptState(), |
| 218 std::move(error)); | 232 std::move(error)); |
| 219 } | 233 } |
| 220 | 234 |
| 235 void ServiceWorkerGlobalScopeProxy::onNavigationPreloadCompleted( |
| 236 int fetchEventID) { |
| 237 InspectorInstrumentation::didCompleteNavigationPreload(workerGlobalScope(), |
| 238 fetchEventID); |
| 239 } |
| 240 |
| 221 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent( | 241 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent( |
| 222 int fetchEventID, | 242 int fetchEventID, |
| 223 const WebServiceWorkerRequest& webRequest) { | 243 const WebServiceWorkerRequest& webRequest) { |
| 224 if (!OriginTrials::foreignFetchEnabled(workerGlobalScope())) { | 244 if (!OriginTrials::foreignFetchEnabled(workerGlobalScope())) { |
| 225 // If origin trial tokens have expired, or are otherwise no longer valid | 245 // If origin trial tokens have expired, or are otherwise no longer valid |
| 226 // no events should be dispatched. | 246 // no events should be dispatched. |
| 227 // TODO(mek): Ideally the browser wouldn't even start the service worker | 247 // TODO(mek): Ideally the browser wouldn't even start the service worker |
| 228 // if its tokens have expired. | 248 // if its tokens have expired. |
| 229 ServiceWorkerGlobalScopeClient::from(workerGlobalScope()) | 249 ServiceWorkerGlobalScopeClient::from(workerGlobalScope()) |
| 230 ->respondToFetchEvent(fetchEventID, WTF::currentTime()); | 250 ->respondToFetchEvent(fetchEventID, WTF::currentTime()); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 return *m_document; | 506 return *m_document; |
| 487 } | 507 } |
| 488 | 508 |
| 489 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() | 509 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() |
| 490 const { | 510 const { |
| 491 DCHECK(m_workerGlobalScope); | 511 DCHECK(m_workerGlobalScope); |
| 492 return m_workerGlobalScope; | 512 return m_workerGlobalScope; |
| 493 } | 513 } |
| 494 | 514 |
| 495 } // namespace blink | 515 } // namespace blink |
| OLD | NEW |