Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 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/origin_trials/OriginTrials.h" | 40 #include "core/origin_trials/OriginTrials.h" |
| 41 #include "core/workers/WorkerGlobalScope.h" | 41 #include "core/workers/WorkerGlobalScope.h" |
| 42 #include "core/workers/WorkerThread.h" | 42 #include "core/workers/WorkerThread.h" |
| 43 #include "modules/background_sync/BackgroundSyncClientImpl.h" | |
| 43 #include "modules/background_sync/SyncEvent.h" | 44 #include "modules/background_sync/SyncEvent.h" |
|
jbroman
2016/11/21 21:36:01
The include of SyncEvent here can probably go away
| |
| 44 #include "modules/fetch/Headers.h" | 45 #include "modules/fetch/Headers.h" |
| 45 #include "modules/notifications/Notification.h" | 46 #include "modules/notifications/Notification.h" |
| 46 #include "modules/notifications/NotificationEvent.h" | 47 #include "modules/notifications/NotificationEvent.h" |
| 47 #include "modules/notifications/NotificationEventInit.h" | 48 #include "modules/notifications/NotificationEventInit.h" |
| 48 #include "modules/push_messaging/PushEvent.h" | 49 #include "modules/push_messaging/PushEvent.h" |
| 49 #include "modules/push_messaging/PushMessageData.h" | 50 #include "modules/push_messaging/PushMessageData.h" |
| 50 #include "modules/serviceworkers/ExtendableEvent.h" | 51 #include "modules/serviceworkers/ExtendableEvent.h" |
| 51 #include "modules/serviceworkers/ExtendableMessageEvent.h" | 52 #include "modules/serviceworkers/ExtendableMessageEvent.h" |
| 52 #include "modules/serviceworkers/FetchEvent.h" | 53 #include "modules/serviceworkers/FetchEvent.h" |
| 53 #include "modules/serviceworkers/ForeignFetchEvent.h" | 54 #include "modules/serviceworkers/ForeignFetchEvent.h" |
| 54 #include "modules/serviceworkers/InstallEvent.h" | 55 #include "modules/serviceworkers/InstallEvent.h" |
| 55 #include "modules/serviceworkers/ServiceWorkerClient.h" | 56 #include "modules/serviceworkers/ServiceWorkerClient.h" |
| 56 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" |
| 57 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 58 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
| 58 #include "modules/serviceworkers/WaitUntilObserver.h" | 59 #include "modules/serviceworkers/WaitUntilObserver.h" |
| 59 #include "platform/RuntimeEnabledFeatures.h" | 60 #include "platform/RuntimeEnabledFeatures.h" |
| 61 #include "public/platform/InterfaceRegistry.h" | |
| 60 #include "public/platform/modules/notifications/WebNotificationData.h" | 62 #include "public/platform/modules/notifications/WebNotificationData.h" |
| 61 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" | 63 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" |
| 62 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 64 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" |
| 63 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" | 65 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" |
| 64 #include "public/web/WebSerializedScriptValue.h" | 66 #include "public/web/WebSerializedScriptValue.h" |
| 65 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" | 67 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" |
| 66 #include "web/WebEmbeddedWorkerImpl.h" | 68 #include "web/WebEmbeddedWorkerImpl.h" |
| 67 #include "wtf/Assertions.h" | 69 #include "wtf/Assertions.h" |
| 68 #include "wtf/Functional.h" | 70 #include "wtf/Functional.h" |
| 69 #include "wtf/PtrUtil.h" | 71 #include "wtf/PtrUtil.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 | 304 |
| 303 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, | 305 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, |
| 304 const WebString& data) { | 306 const WebString& data) { |
| 305 WaitUntilObserver* observer = WaitUntilObserver::create( | 307 WaitUntilObserver* observer = WaitUntilObserver::create( |
| 306 workerGlobalScope(), WaitUntilObserver::Push, eventID); | 308 workerGlobalScope(), WaitUntilObserver::Push, eventID); |
| 307 Event* event = PushEvent::create(EventTypeNames::push, | 309 Event* event = PushEvent::create(EventTypeNames::push, |
| 308 PushMessageData::create(data), observer); | 310 PushMessageData::create(data), observer); |
| 309 workerGlobalScope()->dispatchExtendableEvent(event, observer); | 311 workerGlobalScope()->dispatchExtendableEvent(event, observer); |
| 310 } | 312 } |
| 311 | 313 |
| 312 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent( | |
| 313 int eventID, | |
| 314 const WebString& tag, | |
| 315 LastChanceOption lastChance) { | |
| 316 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { | |
| 317 ServiceWorkerGlobalScopeClient::from(workerGlobalScope()) | |
| 318 ->didHandleSyncEvent(eventID, WebServiceWorkerEventResultCompleted, | |
| 319 WTF::currentTime()); | |
| 320 return; | |
| 321 } | |
| 322 WaitUntilObserver* observer = WaitUntilObserver::create( | |
| 323 workerGlobalScope(), WaitUntilObserver::Sync, eventID); | |
| 324 Event* event = SyncEvent::create(EventTypeNames::sync, tag, | |
| 325 lastChance == IsLastChance, observer); | |
| 326 workerGlobalScope()->dispatchExtendableEvent(event, observer); | |
| 327 } | |
| 328 | |
| 329 bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() { | 314 bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() { |
| 330 DCHECK(m_workerGlobalScope); | 315 DCHECK(m_workerGlobalScope); |
| 331 return m_workerGlobalScope->hasEventListeners(EventTypeNames::fetch); | 316 return m_workerGlobalScope->hasEventListeners(EventTypeNames::fetch); |
| 332 } | 317 } |
| 333 | 318 |
| 334 void ServiceWorkerGlobalScopeProxy::reportException( | 319 void ServiceWorkerGlobalScopeProxy::reportException( |
| 335 const String& errorMessage, | 320 const String& errorMessage, |
| 336 std::unique_ptr<SourceLocation> location, | 321 std::unique_ptr<SourceLocation> location, |
| 337 int exceptionId) { | 322 int exceptionId) { |
| 338 client().reportException(errorMessage, location->lineNumber(), | 323 client().reportException(errorMessage, location->lineNumber(), |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 356 createCrossThreadTask(&WebEmbeddedWorkerImpl::postMessageToPageInspector, | 341 createCrossThreadTask(&WebEmbeddedWorkerImpl::postMessageToPageInspector, |
| 357 crossThreadUnretained(m_embeddedWorker), message)); | 342 crossThreadUnretained(m_embeddedWorker), message)); |
| 358 } | 343 } |
| 359 | 344 |
| 360 void ServiceWorkerGlobalScopeProxy::didCreateWorkerGlobalScope( | 345 void ServiceWorkerGlobalScopeProxy::didCreateWorkerGlobalScope( |
| 361 WorkerOrWorkletGlobalScope* workerGlobalScope) { | 346 WorkerOrWorkletGlobalScope* workerGlobalScope) { |
| 362 DCHECK(!m_workerGlobalScope); | 347 DCHECK(!m_workerGlobalScope); |
| 363 m_workerGlobalScope = | 348 m_workerGlobalScope = |
| 364 static_cast<ServiceWorkerGlobalScope*>(workerGlobalScope); | 349 static_cast<ServiceWorkerGlobalScope*>(workerGlobalScope); |
| 365 client().workerContextStarted(this); | 350 client().workerContextStarted(this); |
| 351 client().interfaceRegistry()->addInterface( | |
| 352 WTF::bind(&BackgroundSyncClientImpl::Create, m_workerGlobalScope)); | |
| 366 } | 353 } |
| 367 | 354 |
| 368 void ServiceWorkerGlobalScopeProxy::didInitializeWorkerContext() { | 355 void ServiceWorkerGlobalScopeProxy::didInitializeWorkerContext() { |
| 369 ScriptState::Scope scope( | 356 ScriptState::Scope scope( |
| 370 workerGlobalScope()->scriptController()->getScriptState()); | 357 workerGlobalScope()->scriptController()->getScriptState()); |
| 371 client().didInitializeWorkerContext( | 358 client().didInitializeWorkerContext( |
| 372 workerGlobalScope()->scriptController()->context()); | 359 workerGlobalScope()->scriptController()->context()); |
| 373 } | 360 } |
| 374 | 361 |
| 375 void ServiceWorkerGlobalScopeProxy::willEvaluateWorkerScript( | 362 void ServiceWorkerGlobalScopeProxy::willEvaluateWorkerScript( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 return *m_document; | 422 return *m_document; |
| 436 } | 423 } |
| 437 | 424 |
| 438 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() | 425 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() |
| 439 const { | 426 const { |
| 440 DCHECK(m_workerGlobalScope); | 427 DCHECK(m_workerGlobalScope); |
| 441 return m_workerGlobalScope; | 428 return m_workerGlobalScope; |
| 442 } | 429 } |
| 443 | 430 |
| 444 } // namespace blink | 431 } // namespace blink |
| OLD | NEW |