Changeset 223981 in webkit
- Timestamp:
- Oct 25, 2017 2:17:46 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 35 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223974 r223981 1 2017-10-25 Youenn Fablet <youenn@apple.com> 2 3 Enable ServiceWorker to fetch resources 4 https://bugs.webkit.org/show_bug.cgi?id=178673 5 6 Reviewed by Brady Eidson. 7 8 * http/tests/workers/service/resources/service-worker-fetch-worker.js: Added. 9 * http/tests/workers/service/resources/service-worker-fetch.js: Added. 10 * http/tests/workers/service/service-worker-fetch-expected.txt: Added. 11 * http/tests/workers/service/service-worker-fetch.html: Added. 12 1 13 2017-10-25 Jer Noble <jer.noble@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r223974 r223981 1 2017-10-25 Youenn Fablet <youenn@apple.com> 2 3 Enable ServiceWorker to fetch resources 4 https://bugs.webkit.org/show_bug.cgi?id=178673 5 6 Reviewed by Brady Eidson. 7 8 Test: http/tests/workers/service/service-worker-fetch.html 9 10 Allow reusing of EmptyFrameLoaderClient for network loading in WebKit Service Worker environment. 11 Allow overriding the creation of a document loader, pageID, frameID and sessionID getters. 12 13 Allow the possibility to create synthetic documents for all ports. 14 15 Beefing up ServiceWorkerThreadProxy as it owns a Document and a Page that do nothing but server 16 the purpose of loading resources for a service worker thread. 17 18 * WebCore.xcodeproj/project.pbxproj: 19 * loader/DocumentLoader.h: 20 (WebCore::DocumentLoader::setResponse): 21 * loader/EmptyClients.cpp: 22 (WebCore::EmptyFrameLoaderClient::sessionID const): 23 (WebCore::EmptyFrameLoaderClient::createNetworkingContext): 24 (WebCore::createEmptyFrameNetworkingContext): 25 * loader/EmptyClients.h: 26 * loader/EmptyFrameLoaderClient.h: Added. 27 * loader/FrameLoader.cpp: 28 (WebCore::FrameLoader::initForSynthesizedDocument): 29 * loader/FrameLoader.h: 30 * loader/FrameLoaderClient.h: 31 * workers/service/context/ServiceWorkerThread.cpp: 32 (WebCore::ServiceWorkerThread::ServiceWorkerThread): 33 (WebCore::m_workerObjectProxy): 34 * workers/service/context/ServiceWorkerThread.h: 35 * workers/service/context/ServiceWorkerThreadProxy.cpp: 36 (WebCore::ServiceWorkerThreadProxy::create): 37 (WebCore::createPageForServiceWorker): 38 (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy): 39 (WebCore::ServiceWorkerThreadProxy::postTaskToLoader): 40 * workers/service/context/ServiceWorkerThreadProxy.h: 41 Test: http/tests/workers/service/service-worker-fetch.html 42 1 43 2017-10-25 Jer Noble <jer.noble@apple.com> 2 44 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r223973 r223981 1348 1348 414B82051D6DF0E50077EBE3 /* StructuredClone.h in Headers */ = {isa = PBXBuildFile; fileRef = 414B82031D6DF0D90077EBE3 /* StructuredClone.h */; }; 1349 1349 414C25D71E9EFEDE00BEE141 /* H264VideoToolBoxEncoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 414C25D61E9EF7C000BEE141 /* H264VideoToolBoxEncoder.mm */; }; 1350 414DEDE71F9FE91E0047C40D /* EmptyFrameLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 414DEDE51F9FE9150047C40D /* EmptyFrameLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1350 1351 415071581685067300C3C7B3 /* SelectorFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 415071561685067300C3C7B3 /* SelectorFilter.h */; }; 1351 1352 415080361E3F00AD0051D75D /* LibWebRTCAudioModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415080341E3F00AA0051D75D /* LibWebRTCAudioModule.cpp */; }; … … 4292 4293 B25599A30D00D8BA00BB825C /* SVGImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B255990B0D00D8B900BB825C /* SVGImage.cpp */; }; 4293 4294 B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990C0D00D8B900BB825C /* SVGImage.h */; }; 4294 B25599A50D00D8BA00BB825C /* EmptyClients.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990D0D00D8B900BB825C /* EmptyClients.h */; };4295 B25599A50D00D8BA00BB825C /* EmptyClients.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990D0D00D8B900BB825C /* EmptyClients.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4295 4296 B27535580B053814002CE64F /* TransformationMatrixCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B275352A0B053814002CE64F /* TransformationMatrixCG.cpp */; }; 4296 4297 B27535590B053814002CE64F /* FloatPointCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B275352B0B053814002CE64F /* FloatPointCG.cpp */; }; … … 8092 8093 414C25D51E9EF7C000BEE141 /* H264VideoToolBoxEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = H264VideoToolBoxEncoder.h; path = libwebrtc/H264VideoToolBoxEncoder.h; sourceTree = "<group>"; }; 8093 8094 414C25D61E9EF7C000BEE141 /* H264VideoToolBoxEncoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = H264VideoToolBoxEncoder.mm; path = libwebrtc/H264VideoToolBoxEncoder.mm; sourceTree = "<group>"; }; 8095 414DEDE51F9FE9150047C40D /* EmptyFrameLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmptyFrameLoaderClient.h; sourceTree = "<group>"; }; 8094 8096 415071551685067300C3C7B3 /* SelectorFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorFilter.cpp; sourceTree = "<group>"; }; 8095 8097 415071561685067300C3C7B3 /* SelectorFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorFilter.h; sourceTree = "<group>"; }; … … 23883 23885 F52AD5E31534245F0059FBE6 /* EmptyClients.cpp */, 23884 23886 B255990D0D00D8B900BB825C /* EmptyClients.h */, 23887 414DEDE51F9FE9150047C40D /* EmptyFrameLoaderClient.h */, 23885 23888 41AD75391CEF6BCE00A31486 /* FetchOptions.h */, 23886 23889 656D37230ADBA5DE00A4554D /* FormState.cpp */, … … 27293 27296 F55B3DBC1251F12D003EF269 /* EmailInputType.h in Headers */, 27294 27297 B25599A50D00D8BA00BB825C /* EmptyClients.h in Headers */, 27298 414DEDE71F9FE91E0047C40D /* EmptyFrameLoaderClient.h in Headers */, 27295 27299 515BE1901D54F5FB00DD7C68 /* EmptyGamepadProvider.h in Headers */, 27296 27300 FD31609312B026F700C1A359 /* EqualPowerPanner.h in Headers */, -
trunk/Source/WebCore/loader/DocumentLoader.h
r223451 r223981 145 145 146 146 const ResourceResponse& response() const { return m_response; } 147 #if PLATFORM(IOS) 147 148 148 // FIXME: This method seems to violate the encapsulation of this class. 149 149 void setResponse(const ResourceResponse& response) { m_response = response; } 150 #endif151 150 152 151 bool isClientRedirect() const { return m_isClientRedirect; } -
trunk/Source/WebCore/loader/EmptyClients.cpp
r222664 r223981 39 39 #include "DragClient.h" 40 40 #include "EditorClient.h" 41 #include "EmptyFrameLoaderClient.h" 41 42 #include "FileChooser.h" 42 43 #include "FormState.h" … … 272 273 }; 273 274 274 class EmptyFrameLoaderClient final : public FrameLoaderClient {275 void frameLoaderDestroyed() final { }276 277 bool hasWebView() const final { return true; } // mainly for assertions278 279 void makeRepresentation(DocumentLoader*) final { }280 #if PLATFORM(IOS)281 bool forceLayoutOnRestoreFromPageCache() final { return false; }282 #endif283 void forceLayoutForNonHTML() final { }284 285 void setCopiesOnScroll() final { }286 287 void detachedFromParent2() final { }288 void detachedFromParent3() final { }289 290 void convertMainResourceLoadToDownload(DocumentLoader*, PAL::SessionID, const ResourceRequest&, const ResourceResponse&) final { }291 292 void assignIdentifierToInitialRequest(unsigned long, DocumentLoader*, const ResourceRequest&) final { }293 bool shouldUseCredentialStorage(DocumentLoader*, unsigned long) final { return false; }294 void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) final { }295 void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) final { }296 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)297 bool canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace&) final { return false; }298 #endif299 300 #if PLATFORM(IOS)301 RetainPtr<CFDictionaryRef> connectionProperties(DocumentLoader*, unsigned long) final { return nullptr; }302 #endif303 304 void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&) final { }305 void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long, int) final { }306 void dispatchDidFinishLoading(DocumentLoader*, unsigned long) final { }307 #if ENABLE(DATA_DETECTION)308 void dispatchDidFinishDataDetection(NSArray *) final { }309 #endif310 void dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&) final { }311 bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int) final { return false; }312 313 void dispatchDidDispatchOnloadEvents() final { }314 void dispatchDidReceiveServerRedirectForProvisionalLoad() final { }315 void dispatchDidCancelClientRedirect() final { }316 void dispatchWillPerformClientRedirect(const URL&, double, double) final { }317 void dispatchDidChangeLocationWithinPage() final { }318 void dispatchDidPushStateWithinPage() final { }319 void dispatchDidReplaceStateWithinPage() final { }320 void dispatchDidPopStateWithinPage() final { }321 void dispatchWillClose() final { }322 void dispatchDidStartProvisionalLoad() final { }323 void dispatchDidReceiveTitle(const StringWithDirection&) final { }324 void dispatchDidCommitLoad(std::optional<HasInsecureContent>) final { }325 void dispatchDidFailProvisionalLoad(const ResourceError&) final { }326 void dispatchDidFailLoad(const ResourceError&) final { }327 void dispatchDidFinishDocumentLoad() final { }328 void dispatchDidFinishLoad() final { }329 void dispatchDidReachLayoutMilestone(LayoutMilestones) final { }330 331 Frame* dispatchCreatePage(const NavigationAction&) final { return nullptr; }332 void dispatchShow() final { }333 334 void dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, FramePolicyFunction&&) final { }335 void dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String&, FramePolicyFunction&&) final;336 void dispatchDecidePolicyForNavigationAction(const NavigationAction&, const ResourceRequest&, bool didReceiveRedirectResponse, FormState*, FramePolicyFunction&&) final;337 void cancelPolicyCheck() final { }338 339 void dispatchUnableToImplementPolicy(const ResourceError&) final { }340 341 void dispatchWillSendSubmitEvent(Ref<FormState>&&) final;342 void dispatchWillSubmitForm(FormState&, WTF::Function<void(void)>&&) final;343 344 void revertToProvisionalState(DocumentLoader*) final { }345 void setMainDocumentError(DocumentLoader*, const ResourceError&) final { }346 347 void setMainFrameDocumentReady(bool) final { }348 349 void startDownload(const ResourceRequest&, const String&) final { }350 351 void willChangeTitle(DocumentLoader*) final { }352 void didChangeTitle(DocumentLoader*) final { }353 354 void willReplaceMultipartContent() final { }355 void didReplaceMultipartContent() final { }356 357 void committedLoad(DocumentLoader*, const char*, int) final { }358 void finishedLoading(DocumentLoader*) final { }359 360 ResourceError cancelledError(const ResourceRequest&) final { return { ResourceError::Type::Cancellation }; }361 ResourceError blockedError(const ResourceRequest&) final { return { }; }362 ResourceError blockedByContentBlockerError(const ResourceRequest&) final { return { }; }363 ResourceError cannotShowURLError(const ResourceRequest&) final { return { }; }364 ResourceError interruptedForPolicyChangeError(const ResourceRequest&) final { return { }; }365 #if ENABLE(CONTENT_FILTERING)366 ResourceError blockedByContentFilterError(const ResourceRequest&) final { return { }; }367 #endif368 369 ResourceError cannotShowMIMETypeError(const ResourceResponse&) final { return { }; }370 ResourceError fileDoesNotExistError(const ResourceResponse&) final { return { }; }371 ResourceError pluginWillHandleLoadError(const ResourceResponse&) final { return { }; }372 373 bool shouldFallBack(const ResourceError&) final { return false; }374 375 bool canHandleRequest(const ResourceRequest&) const final { return false; }376 bool canShowMIMEType(const String&) const final { return false; }377 bool canShowMIMETypeAsHTML(const String&) const final { return false; }378 bool representationExistsForURLScheme(const String&) const final { return false; }379 String generatedMIMETypeForURLScheme(const String&) const final { return emptyString(); }380 381 void frameLoadCompleted() final { }382 void restoreViewState() final { }383 void provisionalLoadStarted() final { }384 void didFinishLoad() final { }385 void prepareForDataSourceReplacement() final { }386 387 Ref<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) final;388 void updateCachedDocumentLoader(DocumentLoader&) final { }389 void setTitle(const StringWithDirection&, const URL&) final { }390 391 String userAgent(const URL&) final { return emptyString(); }392 393 void savePlatformDataToCachedFrame(CachedFrame*) final { }394 void transitionToCommittedFromCachedFrame(CachedFrame*) final { }395 #if PLATFORM(IOS)396 void didRestoreFrameHierarchyForCachedFrame() final { }397 #endif398 void transitionToCommittedForNewPage() final { }399 400 void didSaveToPageCache() final { }401 void didRestoreFromPageCache() final { }402 403 void dispatchDidBecomeFrameset(bool) final { }404 405 void updateGlobalHistory() final { }406 void updateGlobalHistoryRedirectLinks() final { }407 bool shouldGoToHistoryItem(HistoryItem*) const final { return false; }408 void updateGlobalHistoryItemForPage() final { }409 void saveViewStateToItem(HistoryItem&) final { }410 bool canCachePage() const final { return false; }411 void didDisplayInsecureContent() final { }412 void didRunInsecureContent(SecurityOrigin&, const URL&) final { }413 void didDetectXSS(const URL&, bool) final { }414 RefPtr<Frame> createFrame(const URL&, const String&, HTMLFrameOwnerElement&, const String&, bool, int, int) final;415 RefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement&, const URL&, const Vector<String>&, const Vector<String>&, const String&, bool) final;416 void recreatePlugin(Widget*) final;417 RefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement&, const URL&, const Vector<String>&, const Vector<String>&) final;418 419 ObjectContentType objectContentType(const URL&, const String&) final { return ObjectContentType::None; }420 String overrideMediaType() const final { return { }; }421 422 void redirectDataToPlugin(Widget&) final { }423 void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&) final { }424 425 #if PLATFORM(COCOA)426 RemoteAXObjectRef accessibilityRemoteObject() final { return nullptr; }427 NSCachedURLResponse *willCacheResponse(DocumentLoader*, unsigned long, NSCachedURLResponse *response) const final { return response; }428 #endif429 430 #if PLATFORM(WIN) && USE(CFURLCONNECTION)431 bool shouldCacheResponse(DocumentLoader*, unsigned long, const ResourceResponse&, const unsigned char*, unsigned long long) final { return true; }432 #endif433 434 Ref<FrameNetworkingContext> createNetworkingContext() final;435 436 bool isEmptyFrameLoaderClient() final { return true; }437 void prefetchDNS(const String&) final { }438 439 #if USE(QUICK_LOOK)440 RefPtr<PreviewLoaderClient> createPreviewLoaderClient(const String&, const String&) final { return nullptr; }441 #endif442 };443 444 275 class EmptyFrameNetworkingContext final : public FrameNetworkingContext { 445 276 public: … … 595 426 } 596 427 428 PAL::SessionID EmptyFrameLoaderClient::sessionID() const 429 { 430 return PAL::SessionID::defaultSessionID(); 431 } 432 597 433 void EmptyFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String&, FramePolicyFunction&&) 598 434 { … … 641 477 642 478 Ref<FrameNetworkingContext> EmptyFrameLoaderClient::createNetworkingContext() 479 { 480 return EmptyFrameNetworkingContext::create(); 481 } 482 483 Ref<FrameNetworkingContext> createEmptyFrameNetworkingContext() 643 484 { 644 485 return EmptyFrameNetworkingContext::create(); -
trunk/Source/WebCore/loader/EmptyClients.h
r221028 r223981 204 204 }; 205 205 206 void fillWithEmptyClients(PageConfiguration&);207 UniqueRef<EditorClient> createEmptyEditorClient();206 WEBCORE_EXPORT void fillWithEmptyClients(PageConfiguration&); 207 WEBCORE_EXPORT UniqueRef<EditorClient> createEmptyEditorClient(); 208 208 DiagnosticLoggingClient& emptyDiagnosticLoggingClient(); 209 209 210 class EmptyFrameNetworkingContext; 211 WEBCORE_EXPORT Ref<FrameNetworkingContext> createEmptyFrameNetworkingContext(); 212 210 213 } -
trunk/Source/WebCore/loader/FrameLoader.cpp
r223708 r223981 314 314 } 315 315 316 #if PLATFORM(IOS)317 316 void FrameLoader::initForSynthesizedDocument(const URL&) 318 317 { … … 320 319 // FrameLoader::checkCompleted() will overwrite the URL of the document to be activeDocumentLoader()->documentURL(). 321 320 322 RefPtr<DocumentLoader>loader = m_client.createDocumentLoader(ResourceRequest(URL(ParsedURLString, emptyString())), SubstituteData());321 auto loader = m_client.createDocumentLoader(ResourceRequest(URL(ParsedURLString, emptyString())), SubstituteData()); 323 322 loader->attachToFrame(m_frame); 324 323 loader->setResponse(ResourceResponse(URL(), ASCIILiteral("text/html"), 0, String())); 325 324 loader->setCommitted(true); 326 setDocumentLoader(loader. get());325 setDocumentLoader(loader.ptr()); 327 326 328 327 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument); … … 339 338 m_progressTracker = std::make_unique<FrameProgressTracker>(m_frame); 340 339 } 341 #endif342 340 343 341 void FrameLoader::setDefersLoading(bool defers) -
trunk/Source/WebCore/loader/FrameLoader.h
r223708 r223981 94 94 95 95 WEBCORE_EXPORT void init(); 96 #if PLATFORM(IOS)97 96 void initForSynthesizedDocument(const URL&); 98 #endif99 97 100 98 Frame& frame() const { return m_frame; } -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r223728 r223981 117 117 118 118 virtual void makeRepresentation(DocumentLoader*) = 0; 119 119 120 virtual uint64_t pageID() const = 0; 121 virtual uint64_t frameID() const = 0; 122 virtual PAL::SessionID sessionID() const = 0; 123 120 124 #if PLATFORM(IOS) 121 125 // Returns true if the client forced the layout. -
trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp
r223839 r223981 70 70 } 71 71 client->didReceiveData(result.releaseReturnValue().releaseNonNull()); 72 client->didF ail();72 client->didFinish(); 73 73 }); 74 74 return; -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
r223935 r223981 62 62 }; 63 63 64 // FIXME: Use a valid WorkerLoaderProxy65 64 // FIXME: Use a valid WorkerReportingProxy 66 65 // FIXME: Use a valid WorkerObjectProxy -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h
r223935 r223981 39 39 class MessagePortChannel; 40 40 class SerializedScriptValue; 41 class WorkerLoaderProxy; 41 42 class WorkerObjectProxy; 42 43 struct ServiceWorkerContextData; -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
r223935 r223981 37 37 namespace WebCore { 38 38 39 Ref<ServiceWorkerThreadProxy> ServiceWorkerThreadProxy::create( uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData& data, PAL::SessionID sessionID, CacheStorageProvider& cacheStorageProvider)39 Ref<ServiceWorkerThreadProxy> ServiceWorkerThreadProxy::create(PageConfiguration&& pageConfiguration, uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData& data, PAL::SessionID sessionID, CacheStorageProvider& cacheStorageProvider) 40 40 { 41 auto serviceWorker = adoptRef(*new ServiceWorkerThreadProxy { serverConnectionIdentifier, data, sessionID, cacheStorageProvider });41 auto serviceWorker = adoptRef(*new ServiceWorkerThreadProxy { WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, cacheStorageProvider }); 42 42 serviceWorker->m_serviceWorkerThread->start(); 43 43 return serviceWorker; 44 44 } 45 45 46 ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData& data, PAL::SessionID sessionID, CacheStorageProvider& cacheStorageProvider) 47 : m_serviceWorkerThread(ServiceWorkerThread::create(serverConnectionIdentifier, data, sessionID, *this)) 46 static inline UniqueRef<Page> createPageForServiceWorker(PageConfiguration&& configuration, const URL& url) 47 { 48 auto page = makeUniqueRef<Page>(WTFMove(configuration)); 49 auto& mainFrame = page->mainFrame(); 50 mainFrame.loader().initForSynthesizedDocument({ }); 51 auto document = Document::createNonRenderedPlaceholder(&mainFrame, url); 52 document->createDOMWindow(); 53 mainFrame.setDocument(WTFMove(document)); 54 return page; 55 } 56 57 ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData& data, PAL::SessionID sessionID, CacheStorageProvider& cacheStorageProvider) 58 : m_page(createPageForServiceWorker(WTFMove(pageConfiguration), data.scriptURL)) 59 , m_document(*m_page->mainFrame().document()) 60 , m_serviceWorkerThread(ServiceWorkerThread::create(serverConnectionIdentifier, data, sessionID, *this)) 48 61 , m_cacheStorageProvider(cacheStorageProvider) 49 62 , m_sessionID(sessionID) … … 59 72 } 60 73 61 void ServiceWorkerThreadProxy::postTaskToLoader(ScriptExecutionContext::Task&& )74 void ServiceWorkerThreadProxy::postTaskToLoader(ScriptExecutionContext::Task&& task) 62 75 { 63 // Implement this. 76 RunLoop::main().dispatch([task = WTFMove(task), this, protectedThis = makeRef(*this)] () mutable { 77 task.performTask(m_document.get()); 78 }); 64 79 } 65 80 -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h
r223935 r223981 42 42 class ServiceWorkerThreadProxy final : public ThreadSafeRefCounted<ServiceWorkerThreadProxy>, public WorkerLoaderProxy { 43 43 public: 44 WEBCORE_EXPORT static Ref<ServiceWorkerThreadProxy> create( uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&);44 WEBCORE_EXPORT static Ref<ServiceWorkerThreadProxy> create(PageConfiguration&&, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&); 45 45 46 46 uint64_t identifier() const { return m_serviceWorkerThread->identifier(); } … … 48 48 49 49 private: 50 ServiceWorkerThreadProxy( uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&);50 ServiceWorkerThreadProxy(PageConfiguration&&, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&); 51 51 bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) final; 52 52 void postTaskToLoader(ScriptExecutionContext::Task&&) final; 53 53 Ref<CacheStorageConnection> createCacheStorageConnection() final; 54 54 55 UniqueRef<Page> m_page; 56 Ref<Document> m_document; 55 57 Ref<ServiceWorkerThread> m_serviceWorkerThread; 56 58 CacheStorageProvider& m_cacheStorageProvider; -
trunk/Source/WebKit/ChangeLog
r223966 r223981 1 2017-10-25 Youenn Fablet <youenn@apple.com> 2 3 Enable ServiceWorker to fetch resources 4 https://bugs.webkit.org/show_bug.cgi?id=178673 5 6 Reviewed by Brady Eidson. 7 8 ServiceWorkerContextManager makes use of the new ServiceWorkerThreadProxy. 9 It creates the necessary environment for the thread to make use of network loads, web sockets and cache storage. 10 Fetch is functional with these changes. 11 12 ServiceWorkerProcessProxy is introduced as a UIProcess proxy to the service worker process. 13 This process proxy is responsible to give the pageID used by all service worker thread instances for network loads. 14 ServiceWorkerContextManager is responsible to give a unique frameID for all service worker threads. 15 This is necessary as these two ids are currently needed for any network load. 16 17 ServiceWorkerThreadProxy creates its own FrameLoaderClient which is now used to get pageID, frameID and sessionID. 18 19 * UIProcess/ServiceWorkerProcessProxy.cpp: Added. 20 (WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy): 21 (WebKit::m_serviceWorkerPageID): 22 (WebKit::ServiceWorkerProcessProxy::~ServiceWorkerProcessProxy): 23 (WebKit::ServiceWorkerProcessProxy::start): 24 * UIProcess/ServiceWorkerProcessProxy.h: Added. 25 * UIProcess/WebProcessPool.cpp: 26 (WebKit::WebProcessPool::getWorkerContextProcessConnection): 27 (WebKit::WebProcessPool::createNewWebProcess): 28 (WebKit::WebProcessPool::initializeNewWebProcess): 29 (WebKit::WebProcessPool::disconnectProcess): 30 (WebKit::WebProcessPool::createNewWebProcessRespectingProcessCountLimit): 31 (WebKit::WebProcessPool::createWebPage): 32 * UIProcess/WebProcessPool.h: 33 * UIProcess/WebProcessProxy.cpp: 34 (WebKit::WebProcessProxy::generatePageID): 35 * UIProcess/WebProcessProxy.h: 36 * WebKit.xcodeproj/project.pbxproj: 37 * WebProcess/Network/WebLoaderStrategy.cpp: 38 (WebKit::WebLoaderStrategy::scheduleLoad): 39 (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): 40 (WebKit::WebLoaderStrategy::startPingLoad): 41 * WebProcess/Network/WebLoaderStrategy.h: 42 * WebProcess/Storage/ServiceWorkerContextManager.cpp: 43 (WebKit::ServiceWorkerContextManager::ServiceWorkerContextManager): 44 (WebKit::ServiceWorkerContextManager::startServiceWorker): 45 (WebKit::ServiceWorkerContextManager::startFetch): 46 * WebProcess/Storage/ServiceWorkerContextManager.h: 47 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 48 (WebKit::WebFrameLoaderClient::pageID const): 49 (WebKit::WebFrameLoaderClient::frameID const): 50 (WebKit::WebFrameLoaderClient::sessionID const): 51 * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: 52 * WebProcess/WebProcess.cpp: 53 (WebKit::WebProcess::getWorkerContextConnection): 54 * WebProcess/WebProcess.h: 55 * WebProcess/WebProcess.messages.in: 56 1 57 2017-10-25 Yousuke Kimoto <yousuke.kimoto@sony.com> 2 58 -
trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp
r223980 r223981 24 24 */ 25 25 26 #pragma once 26 #import "config.h" 27 #include "ServiceWorkerProcessProxy.h" 27 28 28 #if ENABLE(SERVICE_WORKER) 29 #include "WebPreferencesStore.h" 30 #include "WebProcessMessages.h" 29 31 30 #include "Connection.h" 31 #include "MessageReceiver.h" 32 #include <WebCore/ServiceWorkerThreadProxy.h> 33 #include <wtf/HashMap.h> 32 namespace WebKit { 34 33 35 namespace WebCore { 36 struct FetchOptions; 37 class ResourceRequest; 38 struct ServiceWorkerContextData; 34 ServiceWorkerProcessProxy::ServiceWorkerProcessProxy(WebProcessPool& pool, WebsiteDataStore& store) 35 : WebProcessProxy { pool, store } 36 , m_serviceWorkerPageID(generatePageID()) 37 { 39 38 } 40 39 41 namespace WebKit { 42 struct WebPreferencesStore; 40 ServiceWorkerProcessProxy::~ServiceWorkerProcessProxy() 41 { 42 } 43 43 44 class ServiceWorkerContextManager : public IPC::MessageReceiver { 45 public: 46 ServiceWorkerContextManager(Ref<IPC::Connection>&&, const WebPreferencesStore&); 47 48 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 49 50 private: 51 void updatePreferences(const WebPreferencesStore&); 52 53 void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&); 54 void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&); 55 void postMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin); 56 57 Ref<IPC::Connection> m_connectionToStorageProcess; 58 HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThreadProxy>> m_workerMap; 59 }; 44 void ServiceWorkerProcessProxy::start(const WebPreferencesStore& store) 45 { 46 send(Messages::WebProcess::GetWorkerContextConnection(m_serviceWorkerPageID, store), 0); 47 } 60 48 61 49 } // namespace WebKit 62 63 #endif // ENABLE(SERVICE_WORKER) -
trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h
r223980 r223981 26 26 #pragma once 27 27 28 #if ENABLE(SERVICE_WORKER) 29 30 #include "Connection.h" 31 #include "MessageReceiver.h" 32 #include <WebCore/ServiceWorkerThreadProxy.h> 33 #include <wtf/HashMap.h> 34 35 namespace WebCore { 36 struct FetchOptions; 37 class ResourceRequest; 38 struct ServiceWorkerContextData; 39 } 28 #include "WebProcessProxy.h" 40 29 41 30 namespace WebKit { 42 31 struct WebPreferencesStore; 43 32 44 class ServiceWorker ContextManager : public IPC::MessageReceiver{33 class ServiceWorkerProcessProxy final : public WebProcessProxy { 45 34 public: 46 ServiceWorkerContextManager(Ref<IPC::Connection>&&, const WebPreferencesStore&); 35 static Ref<ServiceWorkerProcessProxy> create(WebProcessPool& pool, WebsiteDataStore& store) 36 { 37 return adoptRef(*new ServiceWorkerProcessProxy { pool, store }); 38 } 39 ~ServiceWorkerProcessProxy(); 47 40 48 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;41 void start(const WebPreferencesStore&); 49 42 50 43 private: 51 void updatePreferences(const WebPreferencesStore&); 52 53 void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&); 54 void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&); 55 void postMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin); 56 57 Ref<IPC::Connection> m_connectionToStorageProcess; 58 HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThreadProxy>> m_workerMap; 44 ServiceWorkerProcessProxy(WebProcessPool&, WebsiteDataStore&); 45 uint64_t m_serviceWorkerPageID { 0 }; 59 46 }; 60 47 61 48 } // namespace WebKit 62 63 #endif // ENABLE(SERVICE_WORKER) -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r223935 r223981 47 47 #include "PerActivityStateCPUUsageSampler.h" 48 48 #include "SandboxExtension.h" 49 #include "ServiceWorkerProcessProxy.h" 49 50 #include "StatisticsData.h" 50 51 #include "StorageProcessCreationParameters.h" … … 589 590 { 590 591 ASSERT_UNUSED(proxy, &proxy == m_storageProcess); 591 592 if (m_ workerContextProcess)592 593 if (m_serviceWorkerProcess) 593 594 return; 594 595 595 596 if (!m_websiteDataStore) 596 597 m_websiteDataStore = API::WebsiteDataStore::defaultDataStore().ptr(); 597 auto& newProcess = createNewWebProcess(m_websiteDataStore->websiteDataStore()); 598 m_workerContextProcess = &newProcess; 599 m_workerContextProcess->send(Messages::WebProcess::GetWorkerContextConnection(m_defaultPageGroup->preferences().store()), 0); 598 599 auto serviceWorkerProcessProxy = ServiceWorkerProcessProxy::create(*this, m_websiteDataStore->websiteDataStore()); 600 m_serviceWorkerProcess = serviceWorkerProcessProxy.ptr(); 601 initializeNewWebProcess(serviceWorkerProcessProxy.get(), m_websiteDataStore->websiteDataStore()); 602 m_processes.append(WTFMove(serviceWorkerProcessProxy)); 603 m_serviceWorkerProcess->start(m_defaultPageGroup->preferences().store()); 600 604 } 601 605 … … 687 691 WebProcessProxy& WebProcessPool::createNewWebProcess(WebsiteDataStore& websiteDataStore) 688 692 { 693 auto processProxy = WebProcessProxy::create(*this, websiteDataStore); 694 auto& process = processProxy.get(); 695 initializeNewWebProcess(process, websiteDataStore); 696 m_processes.append(WTFMove(processProxy)); 697 return process; 698 } 699 700 void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDataStore& websiteDataStore) 701 { 689 702 ensureNetworkProcess(); 690 691 Ref<WebProcessProxy> process = WebProcessProxy::create(*this, websiteDataStore);692 703 693 704 WebProcessCreationParameters parameters; … … 812 823 if (!injectedBundleInitializationUserData) 813 824 injectedBundleInitializationUserData = m_injectedBundleInitializationUserData; 814 parameters.initializationUserData = UserData(process ->transformObjectsToHandles(injectedBundleInitializationUserData.get()));815 816 process ->send(Messages::WebProcess::InitializeWebProcess(parameters), 0);825 parameters.initializationUserData = UserData(process.transformObjectsToHandles(injectedBundleInitializationUserData.get())); 826 827 process.send(Messages::WebProcess::InitializeWebProcess(parameters), 0); 817 828 818 829 #if PLATFORM(COCOA) 819 process ->send(Messages::WebProcess::SetQOS(webProcessLatencyQOS(), webProcessThroughputQOS()), 0);830 process.send(Messages::WebProcess::SetQOS(webProcessLatencyQOS(), webProcessThroughputQOS()), 0); 820 831 #endif 821 832 822 833 if (WebPreferences::anyPagesAreUsingPrivateBrowsing()) 823 process ->send(Messages::WebProcess::EnsurePrivateBrowsingSession(PAL::SessionID::legacyPrivateSessionID()), 0);834 process.send(Messages::WebProcess::EnsurePrivateBrowsingSession(PAL::SessionID::legacyPrivateSessionID()), 0); 824 835 825 836 if (m_automationSession) 826 process->send(Messages::WebProcess::EnsureAutomationSessionProxy(m_automationSession->sessionIdentifier()), 0); 827 828 m_processes.append(process.ptr()); 837 process.send(Messages::WebProcess::EnsureAutomationSessionProxy(m_automationSession->sessionIdentifier()), 0); 829 838 830 839 ASSERT(m_messagesToInjectedBundlePostedToEmptyContext.isEmpty()); … … 834 843 Inspector::RemoteInspector::singleton(); 835 844 #endif 836 837 return process;838 845 } 839 846 … … 917 924 m_processWithPageCache = nullptr; 918 925 #if ENABLE(SERVICE_WORKER) 919 if (m_ workerContextProcess == process)920 m_ workerContextProcess = nullptr;926 if (m_serviceWorkerProcess == process) 927 m_serviceWorkerProcess = nullptr; 921 928 #endif 922 929 … … 950 957 continue; 951 958 #if ENABLE(SERVICE_WORKER) 952 if (process.get() == m_ workerContextProcess)959 if (process.get() == m_serviceWorkerProcess) 953 960 continue; 954 961 #endif … … 993 1000 994 1001 #if ENABLE(SERVICE_WORKER) 995 ASSERT(process.get() != m_ workerContextProcess);1002 ASSERT(process.get() != m_serviceWorkerProcess); 996 1003 #endif 997 1004 -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r223207 r223981 86 86 class UIGamepad; 87 87 class PerActivityStateCPUUsageSampler; 88 class ServiceWorkerProcessProxy; 88 89 class WebAutomationSession; 89 90 class WebContextSupplement; … … 426 427 427 428 WebProcessProxy& createNewWebProcess(WebsiteDataStore&); 429 void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore&); 428 430 429 431 void requestWebContentStatistics(StatisticsRequest*); … … 485 487 WebProcessProxy* m_processWithPageCache; 486 488 #if ENABLE(SERVICE_WORKER) 487 WebProcessProxy* m_workerContextProcess { nullptr };489 ServiceWorkerProcessProxy* m_serviceWorkerProcess { nullptr }; 488 490 bool m_waitingForWorkerContextProcessConnection { false }; 489 491 #endif -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r223436 r223981 78 78 namespace WebKit { 79 79 80 static uint64_tgeneratePageID()80 uint64_t WebProcessProxy::generatePageID() 81 81 { 82 82 static uint64_t uniquePageID; -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r223270 r223981 193 193 void didExceedInactiveMemoryLimit(); 194 194 195 protected: 196 static uint64_t generatePageID(); 197 explicit WebProcessProxy(WebProcessPool&, WebsiteDataStore&); 198 195 199 private: 196 explicit WebProcessProxy(WebProcessPool&, WebsiteDataStore&);197 198 200 // From ChildProcessProxy 199 201 void getLaunchOptions(ProcessLauncher::LaunchOptions&) override; -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r223958 r223981 896 896 4131F3E21F9880840059995A /* WebServiceWorkerFetchTaskClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3E01F98712C0059995A /* WebServiceWorkerFetchTaskClient.cpp */; }; 897 897 4135FBD11F4FB8090074C47B /* CacheStorageEngineCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */; }; 898 414DEDD71F9EDDE50047C40D /* ServiceWorkerProcessProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 414DEDD51F9EDDDF0047C40D /* ServiceWorkerProcessProxy.h */; }; 899 414DEDD81F9EDDE50047C40D /* ServiceWorkerProcessProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 414DEDD61F9EDDE00047C40D /* ServiceWorkerProcessProxy.cpp */; }; 898 900 41897ECF1F415D620016FA42 /* WebCacheStorageConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECE1F415D5C0016FA42 /* WebCacheStorageConnection.cpp */; }; 899 901 41897ED01F415D650016FA42 /* WebCacheStorageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */; }; … … 3197 3199 4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageEngineCaches.cpp; sourceTree = "<group>"; }; 3198 3200 4135FBD01F4FB7F20074C47B /* CacheStorageEngineCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineCaches.h; sourceTree = "<group>"; }; 3201 414DEDC41F9E4BEB0047C40D /* ServiceWorkerFrameLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFrameLoaderClient.h; sourceTree = "<group>"; }; 3202 414DEDC51F9E4BEC0047C40D /* ServiceWorkerFrameLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerFrameLoaderClient.cpp; sourceTree = "<group>"; }; 3203 414DEDD51F9EDDDF0047C40D /* ServiceWorkerProcessProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerProcessProxy.h; sourceTree = "<group>"; }; 3204 414DEDD61F9EDDE00047C40D /* ServiceWorkerProcessProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerProcessProxy.cpp; sourceTree = "<group>"; }; 3199 3205 41897ECB1F415D5C0016FA42 /* WebCacheStorageConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCacheStorageConnection.messages.in; sourceTree = "<group>"; }; 3200 3206 41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageProvider.cpp; sourceTree = "<group>"; }; … … 6207 6213 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */, 6208 6214 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */, 6215 414DEDC51F9E4BEC0047C40D /* ServiceWorkerFrameLoaderClient.cpp */, 6216 414DEDC41F9E4BEB0047C40D /* ServiceWorkerFrameLoaderClient.h */, 6209 6217 4131F3E01F98712C0059995A /* WebServiceWorkerFetchTaskClient.cpp */, 6210 6218 419ACF9B1F981D26009F1A83 /* WebServiceWorkerFetchTaskClient.h */, … … 7004 7012 BC111B08112F5E3C00337BAB /* ResponsivenessTimer.cpp */, 7005 7013 1A30066C1110F4F70031937C /* ResponsivenessTimer.h */, 7014 414DEDD61F9EDDE00047C40D /* ServiceWorkerProcessProxy.cpp */, 7015 414DEDD51F9EDDDF0047C40D /* ServiceWorkerProcessProxy.h */, 7006 7016 51A4D5A816CAC4FF000E615E /* StatisticsRequest.cpp */, 7007 7017 514BDED216C98EDD00E4E25E /* StatisticsRequest.h */, … … 8832 8842 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */, 8833 8843 460F48901F996F7100CF4B87 /* ServiceWorkerContextManagerMessages.h in Headers */, 8844 414DEDD71F9EDDE50047C40D /* ServiceWorkerProcessProxy.h in Headers */, 8834 8845 1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */, 8835 8846 1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */, … … 10426 10437 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */, 10427 10438 460F488F1F996F7100CF4B87 /* ServiceWorkerContextManagerMessageReceiver.cpp in Sources */, 10439 414DEDD81F9EDDE50047C40D /* ServiceWorkerProcessProxy.cpp in Sources */, 10428 10440 1AFDE6591954A42B00C48FFA /* SessionState.cpp in Sources */, 10429 10441 1A002D48196B345D00B9AD44 /* SessionStateCoding.mm in Sources */, -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
r223718 r223981 150 150 ASSERT(identifier); 151 151 152 // FIXME: Some entities in WebCore use WebCore's "EmptyFrameLoaderClient" instead of having a proper WebFrameLoaderClient. 153 // EmptyFrameLoaderClient shouldn't exist and everything should be using a WebFrameLoaderClient, 154 // but in the meantime we have to make sure not to mis-cast. 155 WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader.frameLoader()->client()); 156 WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr; 157 WebPage* webPage = webFrame ? webFrame->page() : nullptr; 152 auto& frameLoaderClient = resourceLoader.frameLoader()->client(); 158 153 159 154 WebResourceLoader::TrackingParameters trackingParameters; 160 trackingParameters.pageID = webPage ? webPage->pageID() : 0;161 trackingParameters.frameID = webFrame ? webFrame->frameID() : 0;155 trackingParameters.pageID = frameLoaderClient.pageID(); 156 trackingParameters.frameID = frameLoaderClient.frameID(); 162 157 trackingParameters.resourceID = identifier; 158 auto sessionID = frameLoaderClient.sessionID(); 163 159 164 160 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) … … 207 203 #endif 208 204 205 auto* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader.frameLoader()->client()); 206 auto* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr; 207 auto* webPage = webFrame ? webFrame->page() : nullptr; 209 208 if (webPage) { 210 209 if (auto* handler = webPage->urlSchemeHandlerForScheme(resourceLoader.request().url().protocol().toStringWithoutCopying())) { … … 218 217 219 218 #if ENABLE(SERVICE_WORKER) 220 WebServiceWorkerProvider::singleton().handleFetch(resourceLoader, resource, webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID(), [trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime = maximumBufferingTime(resource), resourceLoader = makeRef(resourceLoader)] (ServiceWorkerClientFetch::Result result) mutable {219 WebServiceWorkerProvider::singleton().handleFetch(resourceLoader, resource, sessionID, [trackingParameters, sessionID, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime = maximumBufferingTime(resource), resourceLoader = makeRef(resourceLoader)] (ServiceWorkerClientFetch::Result result) mutable { 221 220 if (result != ServiceWorkerClientFetch::Result::Unhandled) 222 221 return; 223 222 224 223 LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled through ServiceWorker handle fetch algorithm", resourceLoader->url().string().latin1().data()); 225 WebProcess::singleton().webLoaderStrategy().scheduleLoadFromNetworkProcess(resourceLoader.get(), resourceLoader->originalRequest(), WTFMove(trackingParameters), shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime);224 WebProcess::singleton().webLoaderStrategy().scheduleLoadFromNetworkProcess(resourceLoader.get(), resourceLoader->originalRequest(), trackingParameters, sessionID, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime); 226 225 }); 227 226 #else 228 227 LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled through ServiceWorker handle fetch algorithm", resourceLoader.url().string().latin1().data()); 229 scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, s houldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));230 #endif 231 } 232 233 void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceLoader, const ResourceRequest& request, const WebResourceLoader::TrackingParameters& trackingParameters, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime)228 scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, sessionID, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource)); 229 #endif 230 } 231 232 void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceLoader, const ResourceRequest& request, const WebResourceLoader::TrackingParameters& trackingParameters, PAL::SessionID sessionID, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime) 234 233 { 235 234 ResourceLoadIdentifier identifier = resourceLoader.identifier(); 236 235 ASSERT(identifier); 237 236 238 WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader.frameLoader()->client());239 WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;240 WebPage* webPage = webFrame ? webFrame->page() : nullptr;241 242 237 LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled with the NetworkProcess with priority %d", resourceLoader.url().string().latin1().data(), static_cast<int>(resourceLoader.request().priority())); 243 238 … … 247 242 NetworkResourceLoadParameters loadParameters; 248 243 loadParameters.identifier = identifier; 249 loadParameters.webPageID = webPage ? webPage->pageID() : 0;250 loadParameters.webFrameID = webFrame ? webFrame->frameID() : 0;251 loadParameters.sessionID = webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID();244 loadParameters.webPageID = trackingParameters.pageID; 245 loadParameters.webFrameID = trackingParameters.frameID; 246 loadParameters.sessionID = sessionID; 252 247 loadParameters.request = request; 253 248 loadParameters.contentSniffingPolicy = contentSniffingPolicy; 254 249 loadParameters.storedCredentialsPolicy = storedCredentialsPolicy; 255 250 // If there is no WebFrame then this resource cannot be authenticated with the client. 256 loadParameters.clientCredentialPolicy = ( webFrame && webPage&& resourceLoader.isAllowedToAskUserForCredentials()) ? ClientCredentialPolicy::MayAskClientForCredentials : ClientCredentialPolicy::CannotAskClientForCredentials;251 loadParameters.clientCredentialPolicy = (loadParameters.webFrameID && loadParameters.webPageID && resourceLoader.isAllowedToAskUserForCredentials()) ? ClientCredentialPolicy::MayAskClientForCredentials : ClientCredentialPolicy::CannotAskClientForCredentials; 257 252 loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect; 258 253 loadParameters.defersLoading = resourceLoader.defersLoading(); … … 442 437 WebFrameNetworkingContext* webContext = static_cast<WebFrameNetworkingContext*>(networkingContext); 443 438 WebFrameLoaderClient* webFrameLoaderClient = webContext->webFrameLoaderClient(); 444 WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;445 WebPage* webPage = webFrame ? webFrame->page() : nullptr;446 439 447 440 auto* document = frame.document(); … … 456 449 loadParameters.request = request; 457 450 loadParameters.sourceOrigin = &document->securityOrigin(); 458 loadParameters.sessionID = web Page ? webPage->sessionID() : PAL::SessionID::defaultSessionID();451 loadParameters.sessionID = webFrameLoaderClient ? webFrameLoaderClient->sessionID() : PAL::SessionID::defaultSessionID(); 459 452 loadParameters.storedCredentialsPolicy = options.credentials == FetchOptions::Credentials::Omit ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use; 460 453 loadParameters.mode = options.mode; -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
r223718 r223981 78 78 void removeURLSchemeTaskProxy(WebURLSchemeTaskProxy&); 79 79 80 void scheduleLoadFromNetworkProcess(WebCore::ResourceLoader&, const WebCore::ResourceRequest&, const WebResourceLoader::TrackingParameters&, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime);80 void scheduleLoadFromNetworkProcess(WebCore::ResourceLoader&, const WebCore::ResourceRequest&, const WebResourceLoader::TrackingParameters&, PAL::SessionID, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime); 81 81 82 82 private: -
trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp
r223935 r223981 34 34 #include "WebCacheStorageProvider.h" 35 35 #include "WebCoreArgumentCoders.h" 36 #include "WebDocumentLoader.h" 36 37 #include "WebPreferencesKeys.h" 37 38 #include "WebPreferencesStore.h" 38 39 #include "WebProcess.h" 39 40 #include "WebServiceWorkerFetchTaskClient.h" 41 #include "WebSocketProvider.h" 42 #include <WebCore/EditorClient.h> 43 #include <WebCore/EmptyClients.h> 44 #include <WebCore/EmptyFrameLoaderClient.h> 45 #include <WebCore/LibWebRTCProvider.h> 40 46 #include <WebCore/MessagePortChannel.h> 41 #include <WebCore/ResourceRequest.h> 42 #include <WebCore/ResourceResponse.h> 47 #include <WebCore/PageConfiguration.h> 43 48 #include <WebCore/RuntimeEnabledFeatures.h> 44 49 #include <WebCore/SerializedScriptValue.h> 45 50 #include <pal/SessionID.h> 51 52 #if USE(QUICK_LOOK) 53 #include <WebCore/PreviewLoaderClient.h> 54 #endif 46 55 47 56 using namespace PAL; … … 50 59 namespace WebKit { 51 60 52 ServiceWorkerContextManager::ServiceWorkerContextManager(Ref<IPC::Connection>&& connection, const WebPreferencesStore& store) 61 class ServiceWorkerFrameLoaderClient final : public EmptyFrameLoaderClient { 62 public: 63 ServiceWorkerFrameLoaderClient(PAL::SessionID sessionID, uint64_t pageID, uint64_t frameID) 64 : m_sessionID(sessionID) 65 , m_pageID(pageID) 66 , m_frameID(frameID) 67 { 68 } 69 70 private: 71 Ref<DocumentLoader> createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) final 72 { 73 return WebDocumentLoader::create(request, substituteData); 74 } 75 76 PAL::SessionID sessionID() const final { return m_sessionID; } 77 uint64_t pageID() const final { return m_pageID; } 78 uint64_t frameID() const final { return m_frameID; } 79 80 PAL::SessionID m_sessionID; 81 uint64_t m_pageID { 0 }; 82 uint64_t m_frameID { 0 }; 83 }; 84 85 ServiceWorkerContextManager::ServiceWorkerContextManager(Ref<IPC::Connection>&& connection, uint64_t pageID, const WebPreferencesStore& store) 53 86 : m_connectionToStorageProcess(WTFMove(connection)) 87 , m_pageID(pageID) 54 88 { 55 89 updatePreferences(store); … … 65 99 { 66 100 // FIXME: Provide a sensical session ID. 67 auto serviceWorker = ServiceWorkerThreadProxy::create(serverConnectionIdentifier, data, SessionID::defaultSessionID(), WebProcess::singleton().cacheStorageProvider()); 68 auto serviceWorkerIdentifier = serviceWorker->identifier(); 69 auto result = m_workerMap.add(serviceWorkerIdentifier, WTFMove(serviceWorker)); 101 auto sessionID = PAL::SessionID::defaultSessionID(); 102 103 PageConfiguration pageConfiguration { 104 createEmptyEditorClient(), 105 WebSocketProvider::create(), 106 WebCore::LibWebRTCProvider::create(), 107 WebProcess::singleton().cacheStorageProvider() 108 }; 109 fillWithEmptyClients(pageConfiguration); 110 auto frameLoaderClient = std::make_unique<ServiceWorkerFrameLoaderClient>(sessionID, m_pageID, ++m_previousServiceWorkerID); 111 pageConfiguration.loaderClientForMainFrame = frameLoaderClient.release(); 112 113 auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, WebProcess::singleton().cacheStorageProvider()); 114 auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier(); 115 auto result = m_workerMap.add(serviceWorkerIdentifier, WTFMove(serviceWorkerThreadProxy)); 70 116 ASSERT_UNUSED(result, result.isNewEntry); 71 117 … … 77 123 void ServiceWorkerContextManager::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options) 78 124 { 79 auto serviceWorker = m_workerMap.get(serviceWorkerIdentifier);80 if (!serviceWorker ) {125 auto serviceWorkerThreadProxy = serviceWorkerIdentifier ? m_workerMap.get(serviceWorkerIdentifier) : nullptr; 126 if (!serviceWorkerThreadProxy) { 81 127 m_connectionToStorageProcess->send(Messages::StorageProcess::DidNotHandleFetch(serverConnectionIdentifier, fetchIdentifier), 0); 82 128 return; … … 84 130 85 131 auto client = WebServiceWorkerFetchTaskClient::create(m_connectionToStorageProcess.copyRef(), serverConnectionIdentifier, fetchIdentifier); 86 serviceWorker ->thread().postFetchTask(WTFMove(client), WTFMove(request), WTFMove(options));132 serviceWorkerThreadProxy->thread().postFetchTask(WTFMove(client), WTFMove(request), WTFMove(options)); 87 133 } 88 134 -
trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h
r223935 r223981 44 44 class ServiceWorkerContextManager : public IPC::MessageReceiver { 45 45 public: 46 ServiceWorkerContextManager(Ref<IPC::Connection>&&, const WebPreferencesStore&);46 ServiceWorkerContextManager(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&); 47 47 48 48 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; … … 57 57 Ref<IPC::Connection> m_connectionToStorageProcess; 58 58 HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThreadProxy>> m_workerMap; 59 uint64_t m_pageID { 0 }; 60 uint64_t m_previousServiceWorkerID { 0 }; 59 61 }; 60 62 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r223451 r223981 106 106 { 107 107 } 108 108 109 uint64_t WebFrameLoaderClient::pageID() const 110 { 111 return m_frame && m_frame->page() ? m_frame->page()->pageID() : 0; 112 } 113 114 uint64_t WebFrameLoaderClient::frameID() const 115 { 116 return m_frame ? m_frame->frameID() : 0; 117 } 118 119 PAL::SessionID WebFrameLoaderClient::sessionID() const 120 { 121 return m_frame && m_frame->page() ? m_frame->page()->sessionID() : PAL::SessionID::defaultSessionID(); 122 } 123 109 124 void WebFrameLoaderClient::frameLoaderDestroyed() 110 125 { -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
r222714 r223981 52 52 void applyToDocumentLoader(const WebsitePolicies&); 53 53 54 uint64_t pageID() const final; 55 uint64_t frameID() const final; 56 PAL::SessionID sessionID() const final; 57 54 58 private: 55 59 void frameLoaderDestroyed() final; -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r223935 r223981 1641 1641 1642 1642 #if ENABLE(SERVICE_WORKER) 1643 void WebProcess::getWorkerContextConnection( const WebPreferencesStore& store)1643 void WebProcess::getWorkerContextConnection(uint64_t pageID, const WebPreferencesStore& store) 1644 1644 { 1645 1645 ASSERT(!m_serviceWorkerManager); … … 1665 1665 auto workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this); 1666 1666 workerContextConnection->open(); 1667 m_serviceWorkerManager = ServiceWorkerContextManager(WTFMove(workerContextConnection), store);1667 m_serviceWorkerManager = ServiceWorkerContextManager(WTFMove(workerContextConnection), pageID, store); 1668 1668 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidGetWorkerContextConnection(connectionClientPort), 0); 1669 1669 } -
trunk/Source/WebKit/WebProcess/WebProcess.h
r223935 r223981 300 300 #endif 301 301 #if ENABLE(SERVICE_WORKER) 302 void getWorkerContextConnection( const WebPreferencesStore&);302 void getWorkerContextConnection(uint64_t pageID, const WebPreferencesStore&); 303 303 #endif 304 304 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r223935 r223981 116 116 117 117 #if ENABLE(SERVICE_WORKER) 118 GetWorkerContextConnection( struct WebKit::WebPreferencesStore store)118 GetWorkerContextConnection(uint64_t pageID, struct WebKit::WebPreferencesStore store) 119 119 #endif 120 120 } -
trunk/Source/WebKitLegacy/mac/ChangeLog
r223929 r223981 1 2017-10-25 Youenn Fablet <youenn@apple.com> 2 3 Enable ServiceWorker to fetch resources 4 https://bugs.webkit.org/show_bug.cgi?id=178673 5 6 Reviewed by Brady Eidson. 7 8 * WebCoreSupport/WebFrameLoaderClient.mm: 9 (WebFrameLoaderClient::pageID const): 10 (WebFrameLoaderClient::frameID const): 11 (WebFrameLoaderClient::sessionID const): 12 13 Added implementation to the new getters. 14 They are noop in the context of WK1. 15 1 16 2017-10-24 Eric Carlson <eric.carlson@apple.com> 2 17 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
r222456 r223981 63 63 bool hasWebView() const final; // mainly for assertions 64 64 65 uint64_t pageID() const final; 66 uint64_t frameID() const final; 67 PAL::SessionID sessionID() const final; 68 65 69 void makeRepresentation(WebCore::DocumentLoader*) final; 66 70 bool hasHTMLView() const final; -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
r222896 r223981 203 203 } 204 204 205 uint64_t WebFrameLoaderClient::pageID() const 206 { 207 RELEASE_ASSERT_NOT_REACHED(); 208 return 0; 209 } 210 211 uint64_t WebFrameLoaderClient::frameID() const 212 { 213 RELEASE_ASSERT_NOT_REACHED(); 214 return 0; 215 } 216 217 PAL::SessionID WebFrameLoaderClient::sessionID() const 218 { 219 RELEASE_ASSERT_NOT_REACHED(); 220 return PAL::SessionID::defaultSessionID(); 221 } 222 205 223 void WebFrameLoaderClient::frameLoaderDestroyed() 206 224 { -
trunk/Source/WebKitLegacy/win/ChangeLog
r223779 r223981 1 2017-10-25 Youenn Fablet <youenn@apple.com> 2 3 Enable ServiceWorker to fetch resources 4 https://bugs.webkit.org/show_bug.cgi?id=178673 5 6 Reviewed by Brady Eidson. 7 8 Added implementation to the new getters. 9 They are noop in the context of WK1. 10 11 * WebCoreSupport/WebFrameLoaderClient.cpp: 12 (WebFrameLoaderClient::pageID const): 13 (WebFrameLoaderClient::frameID const): 14 (WebFrameLoaderClient::sessionID const): 15 * WebCoreSupport/WebFrameLoaderClient.h: 16 1 17 2017-10-20 Antoine Quint <graouts@apple.com> 2 18 -
trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
r222492 r223981 122 122 } 123 123 124 uint64_t WebFrameLoaderClient::pageID() const 125 { 126 RELEASE_ASSERT_NOT_REACHED(); 127 return 0; 128 } 129 130 uint64_t WebFrameLoaderClient::frameID() const 131 { 132 RELEASE_ASSERT_NOT_REACHED(); 133 return 0; 134 } 135 136 PAL::SessionID WebFrameLoaderClient::sessionID() const 137 { 138 RELEASE_ASSERT_NOT_REACHED(); 139 return PAL::SessionID::defaultSessionID(); 140 } 141 124 142 bool WebFrameLoaderClient::hasWebView() const 125 143 { -
trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h
r222456 r223981 52 52 void dispatchDidFailToStartPlugin(const WebCore::PluginView*) const; 53 53 54 uint64_t pageID() const final; 55 uint64_t frameID() const final; 56 PAL::SessionID sessionID() const final; 57 54 58 bool hasWebView() const override; 55 59
Note: See TracChangeset
for help on using the changeset viewer.