Changeset 224041 in webkit


Ignore:
Timestamp:
Oct 26, 2017 1:14:40 PM (6 years ago)
Author:
Chris Dumez
Message:

Bring back SWContextManager abstraction in WebCore
https://bugs.webkit.org/show_bug.cgi?id=178876

Reviewed by Geoffrey Garen.

Bring back SWContextManager abstraction in WebCore. It was killed in <https://trac.webkit.org/changeset/223718> but
is actually useful when the ServiceWorker wants to message the storage process.

Source/WebCore:

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • workers/service/context/SWContextManager.cpp: Added.

(WebCore::SWContextManager::singleton):
(WebCore::SWContextManager::setConnection):
(WebCore::SWContextManager::connection const):
(WebCore::SWContextManager::registerServiceWorkerThread):
(WebCore::SWContextManager::serviceWorkerThreadProxy const):
(WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope):

  • workers/service/context/SWContextManager.h: Copied from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.

(WebCore::SWContextManager::Connection::~Connection):

Source/WebKit:

  • CMakeLists.txt:
  • DerivedSources.make:
  • StorageProcess/ServiceWorker/WebSWServerConnection.cpp:

(WebKit::WebSWServerConnection::startServiceWorkerContext):
(WebKit::WebSWServerConnection::startFetch):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):

  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Storage/WebSWContextManagerConnection.cpp: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp.

(WebKit::WebSWContextManagerConnection::WebSWContextManagerConnection):
(WebKit::WebSWContextManagerConnection::updatePreferences):
(WebKit::WebSWContextManagerConnection::startServiceWorker):
(WebKit::WebSWContextManagerConnection::startFetch):
(WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope):

  • WebProcess/Storage/WebSWContextManagerConnection.h: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
  • WebProcess/Storage/WebSWContextManagerConnection.messages.in: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.messages.in.
  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::didReceiveMessage):
(WebKit::WebProcess::getWorkerContextConnection):

  • WebProcess/WebProcess.h:
Location:
trunk/Source
Files:
10 edited
2 copied
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224037 r224041  
     12017-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Bring back SWContextManager abstraction in WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=178876
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Bring back SWContextManager abstraction in WebCore. It was killed in <https://trac.webkit.org/changeset/223718> but
     9        is actually useful when the ServiceWorker wants to message the storage process.
     10
     11        * Sources.txt:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * workers/service/context/SWContextManager.cpp: Added.
     14        (WebCore::SWContextManager::singleton):
     15        (WebCore::SWContextManager::setConnection):
     16        (WebCore::SWContextManager::connection const):
     17        (WebCore::SWContextManager::registerServiceWorkerThread):
     18        (WebCore::SWContextManager::serviceWorkerThreadProxy const):
     19        (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope):
     20        * workers/service/context/SWContextManager.h: Copied from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
     21        (WebCore::SWContextManager::Connection::~Connection):
     22
    1232017-10-26  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    224
  • trunk/Source/WebCore/Sources.txt

    r224006 r224041  
    21702170workers/service/context/ServiceWorkerThread.cpp
    21712171workers/service/context/ServiceWorkerThreadProxy.cpp
     2172workers/service/context/SWContextManager.cpp
    21722173
    21732174workers/service/server/SWClientConnection.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r224027 r224041  
    11791179                463EB6231B8789E00096ED51 /* TagCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 463EB6211B8789CB0096ED51 /* TagCollection.h */; };
    11801180                465307D01DB6EE4800E4137C /* JSUIEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E045EF1DAA104F00B0D8B9 /* JSUIEventInit.h */; };
     1181                46658DC91FA24B8700F7DD54 /* SWContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4672413B1FA24B140088BD6D /* SWContextManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11811182                466ED8D31EDE0144005E43F6 /* JSDOMRectList.h in Headers */ = {isa = PBXBuildFile; fileRef = 466ED8D21EDE0135005E43F6 /* JSDOMRectList.h */; };
    11821183                4671E0661D67A59600C6B497 /* CanvasPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 4671E0641D67A57B00C6B497 /* CanvasPath.h */; };
     
    73687369                4671E0631D67A57B00C6B497 /* CanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasPath.cpp; sourceTree = "<group>"; };
    73697370                4671E0641D67A57B00C6B497 /* CanvasPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasPath.h; sourceTree = "<group>"; };
     7371                4672413A1FA24B140088BD6D /* SWContextManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SWContextManager.cpp; sourceTree = "<group>"; };
     7372                4672413B1FA24B140088BD6D /* SWContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWContextManager.h; sourceTree = "<group>"; };
    73707373                467302011C4EFE6600BCB357 /* IgnoreOpensDuringUnloadCountIncrementer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IgnoreOpensDuringUnloadCountIncrementer.h; sourceTree = "<group>"; };
    73717374                4682D1FF1F79782300C863DB /* StoredCredentialsPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StoredCredentialsPolicy.h; sourceTree = "<group>"; };
     
    1726417267                                4112B5411F9F9C9C00E67875 /* ServiceWorkerThreadProxy.cpp */,
    1726517268                                4112B53F1F9F9C9B00E67875 /* ServiceWorkerThreadProxy.h */,
     17269                                4672413A1FA24B140088BD6D /* SWContextManager.cpp */,
     17270                                4672413B1FA24B140088BD6D /* SWContextManager.h */,
    1726617271                        );
    1726717272                        path = context;
     
    2938629391                                B2E4EC980D00C22B00432643 /* SVGZoomEvent.h in Headers */,
    2938729392                                517A531D1F4B53B100DCDC0A /* SWClientConnection.h in Headers */,
     29393                                46658DC91FA24B8700F7DD54 /* SWContextManager.h in Headers */,
    2938829394                                517A52F01F47535B00DCDC0A /* SWServer.h in Headers */,
    2938929395                                51F645971F4A686F00B54DED /* SWServerRegistration.h in Headers */,
  • trunk/Source/WebCore/workers/service/context/SWContextManager.cpp

    r224040 r224041  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
    2727
    2828#if ENABLE(SERVICE_WORKER)
    29 
    30 #include "Connection.h"
    31 #include "MessageReceiver.h"
    32 #include <WebCore/ServiceWorkerThreadProxy.h>
    33 #include <wtf/HashMap.h>
     29#include "SWContextManager.h"
    3430
    3531namespace WebCore {
    36 struct FetchOptions;
    37 class ResourceRequest;
    38 struct ServiceWorkerContextData;
     32
     33SWContextManager& SWContextManager::singleton()
     34{
     35    static SWContextManager* sharedManager = new SWContextManager;
     36    return *sharedManager;
    3937}
    4038
    41 namespace WebKit {
    42 struct WebPreferencesStore;
     39void SWContextManager::setConnection(std::unique_ptr<Connection>&& connection)
     40{
     41    ASSERT(!m_connection);
     42    m_connection = WTFMove(connection);
     43}
    4344
    44 class ServiceWorkerContextManager : public IPC::MessageReceiver {
    45 public:
    46     ServiceWorkerContextManager(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&);
     45auto SWContextManager::connection() const -> Connection*
     46{
     47    return m_connection.get();
     48}
    4749
    48     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     50void SWContextManager::registerServiceWorkerThread(Ref<ServiceWorkerThreadProxy>&& serviceWorkerThreadProxy)
     51{
     52    auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier();
     53    auto result = m_workerMap.add(serviceWorkerIdentifier, WTFMove(serviceWorkerThreadProxy));
     54    ASSERT_UNUSED(result, result.isNewEntry);
     55}
    4956
    50 private:
    51     void updatePreferences(const WebPreferencesStore&);
     57ServiceWorkerThreadProxy* SWContextManager::serviceWorkerThreadProxy(uint64_t serviceWorkerIdentifier) const
     58{
     59    return m_workerMap.get(serviceWorkerIdentifier);
     60}
    5261
    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);
     62void SWContextManager::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const String& sourceOrigin)
     63{
     64    auto* serviceWorker = m_workerMap.get(serviceWorkerIdentifier);
     65    if (!serviceWorker)
     66        return;
    5667
    57     Ref<IPC::Connection> m_connectionToStorageProcess;
    58     HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThreadProxy>> m_workerMap;
    59     uint64_t m_pageID { 0 };
    60     uint64_t m_previousServiceWorkerID { 0 };
    61 };
     68    // FIXME: We should pass valid MessagePortChannels.
     69    serviceWorker->thread().postMessageToServiceWorkerGlobalScope(WTFMove(message), nullptr, sourceOrigin);
     70}
    6271
    63 } // namespace WebKit
     72} // namespace WebCore
    6473
    65 #endif // ENABLE(SERVICE_WORKER)
     74#endif
  • trunk/Source/WebCore/workers/service/context/SWContextManager.h

    r224040 r224041  
    2828#if ENABLE(SERVICE_WORKER)
    2929
    30 #include "Connection.h"
    31 #include "MessageReceiver.h"
    32 #include <WebCore/ServiceWorkerThreadProxy.h>
     30#include "ExceptionOr.h"
     31#include "ServiceWorkerThreadProxy.h"
    3332#include <wtf/HashMap.h>
    3433
    3534namespace WebCore {
    36 struct FetchOptions;
    37 class ResourceRequest;
    38 struct ServiceWorkerContextData;
    39 }
    4035
    41 namespace WebKit {
    42 struct WebPreferencesStore;
     36class SerializedScriptValue;
    4337
    44 class ServiceWorkerContextManager : public IPC::MessageReceiver {
     38class SWContextManager {
    4539public:
    46     ServiceWorkerContextManager(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&);
     40    WEBCORE_EXPORT static SWContextManager& singleton();
    4741
    48     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     42    class Connection {
     43    public:
     44        virtual ~Connection() { }
     45    };
     46
     47    WEBCORE_EXPORT void setConnection(std::unique_ptr<Connection>&&);
     48    WEBCORE_EXPORT Connection* connection() const;
     49
     50    WEBCORE_EXPORT void registerServiceWorkerThread(Ref<ServiceWorkerThreadProxy>&&);
     51    WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(uint64_t) const;
     52    WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const String& sourceOrigin);
    4953
    5054private:
    51     void updatePreferences(const WebPreferencesStore&);
     55    SWContextManager() = default;
    5256
    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     uint64_t m_pageID { 0 };
    60     uint64_t m_previousServiceWorkerID { 0 };
     57    HashMap<uint64_t, RefPtr<ServiceWorkerThreadProxy>> m_workerMap;
     58    std::unique_ptr<Connection> m_connection;
    6159};
    6260
    63 } // namespace WebKit
     61} // namespace WebCore
    6462
    6563#endif // ENABLE(SERVICE_WORKER)
  • trunk/Source/WebKit/CMakeLists.txt

    r223958 r224041  
    542542
    543543    WebProcess/Storage/ServiceWorkerClientFetch.cpp
    544     WebProcess/Storage/ServiceWorkerContextManager.cpp
    545544    WebProcess/Storage/WebSWClientConnection.cpp
     545    WebProcess/Storage/WebSWContextManagerConnection.cpp
    546546    WebProcess/Storage/WebSWOriginTable.cpp
    547547    WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp
     
    689689
    690690    WebProcess/Storage/ServiceWorkerClientFetch.messages.in
    691     WebProcess/Storage/ServiceWorkerContextManager.messages.in
    692691    WebProcess/Storage/WebSWClientConnection.messages.in
     692    WebProcess/Storage/WebSWContextManagerConnection.messages.in
    693693
    694694    WebProcess/UserContent/WebUserContentController.messages.in
  • trunk/Source/WebKit/ChangeLog

    r224035 r224041  
     12017-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Bring back SWContextManager abstraction in WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=178876
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Bring back SWContextManager abstraction in WebCore. It was killed in <https://trac.webkit.org/changeset/223718> but
     9        is actually useful when the ServiceWorker wants to message the storage process.
     10
     11        * CMakeLists.txt:
     12        * DerivedSources.make:
     13        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
     14        (WebKit::WebSWServerConnection::startServiceWorkerContext):
     15        (WebKit::WebSWServerConnection::startFetch):
     16        (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
     17        * WebKit.xcodeproj/project.pbxproj:
     18        * WebProcess/Storage/WebSWContextManagerConnection.cpp: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp.
     19        (WebKit::WebSWContextManagerConnection::WebSWContextManagerConnection):
     20        (WebKit::WebSWContextManagerConnection::updatePreferences):
     21        (WebKit::WebSWContextManagerConnection::startServiceWorker):
     22        (WebKit::WebSWContextManagerConnection::startFetch):
     23        (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope):
     24        * WebProcess/Storage/WebSWContextManagerConnection.h: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
     25        * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.messages.in.
     26        * WebProcess/WebProcess.cpp:
     27        (WebKit::WebProcess::didReceiveMessage):
     28        (WebKit::WebProcess::getWorkerContextConnection):
     29        * WebProcess/WebProcess.h:
     30
    1312017-10-26  Alexey Proskuryakov  <ap@apple.com>
    232
  • trunk/Source/WebKit/DerivedSources.make

    r223903 r224041  
    127127    SecItemShimProxy \
    128128    ServiceWorkerClientFetch \
    129     ServiceWorkerContextManager \
    130129    SmartMagnificationController \
    131130    StorageAreaMap \
     
    164163    WebPaymentCoordinatorProxy \
    165164    WebSWClientConnection \
     165    WebSWContextManagerConnection \
    166166    WebSWServerConnection \
    167167    PlaybackSessionManager \
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp

    r223964 r224041  
    3232#include "Logging.h"
    3333#include "ServiceWorkerClientFetchMessages.h"
    34 #include "ServiceWorkerContextManagerMessages.h"
    3534#include "StorageProcess.h"
    3635#include "StorageToWebProcessConnectionMessages.h"
     
    3938#include "WebProcessMessages.h"
    4039#include "WebSWClientConnectionMessages.h"
     40#include "WebSWContextManagerConnectionMessages.h"
    4141#include "WebSWOriginStore.h"
    4242#include "WebSWServerConnectionMessages.h"
     
    9898void WebSWServerConnection::startServiceWorkerContext(const ServiceWorkerContextData& data)
    9999{
    100     if (sendToContextProcess(Messages::ServiceWorkerContextManager::StartServiceWorker(identifier(), data)))
     100    if (sendToContextProcess(Messages::WebSWContextManagerConnection::StartServiceWorker(identifier(), data)))
    101101        return;
    102102
     
    106106void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
    107107{
    108     sendToContextProcess(Messages::ServiceWorkerContextManager::StartFetch(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
     108    sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
    109109}
    110110
    111111void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)
    112112{
    113     sendToContextProcess(Messages::ServiceWorkerContextManager::PostMessageToServiceWorkerGlobalScope(identifier(), serviceWorkerIdentifier, message, sourceOrigin));
     113    sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope(serviceWorkerIdentifier, message, sourceOrigin));
    114114}
    115115
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r224035 r224041  
    892892                413075B41DE85F580039EC69 /* LibWebRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */; };
    893893                4131F3D11F96BCCC0059995A /* ServiceWorkerClientFetch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */; };
    894                 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */; };
    895                 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */; };
    896894                4131F3E21F9880840059995A /* WebServiceWorkerFetchTaskClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3E01F98712C0059995A /* WebServiceWorkerFetchTaskClient.cpp */; };
    897895                4135FBD11F4FB8090074C47B /* CacheStorageEngineCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */; };
     
    920918                41FAF5F91E3C1025001AE678 /* LibWebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */; };
    921919                4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */; };
    922                 460F488F1F996F7100CF4B87 /* ServiceWorkerContextManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460F488D1F996F6C00CF4B87 /* ServiceWorkerContextManagerMessageReceiver.cpp */; };
    923                 460F48901F996F7100CF4B87 /* ServiceWorkerContextManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 460F488E1F996F6C00CF4B87 /* ServiceWorkerContextManagerMessages.h */; };
     920                460F488F1F996F7100CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */; };
     921                460F48901F996F7100CF4B87 /* WebSWContextManagerConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 460F488E1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessages.h */; };
    924922                462107D81F38DBDB00DD7810 /* PingLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 462107D71F38DBD300DD7810 /* PingLoad.cpp */; };
    925923                463FD4801EB9459600A2982C /* WKProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */; settings = {ATTRIBUTES = (Private, ); }; };
    926924                463FD4821EB94EC000A2982C /* ProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */; };
    927925                465250E61ECF52DC002025CB /* WebKit2InitializeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 465250E51ECF52CD002025CB /* WebKit2InitializeCocoa.mm */; };
     926                466BC03B1FA266DA002FA9C1 /* WebSWContextManagerConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 466BC0381FA266C9002FA9C1 /* WebSWContextManagerConnection.cpp */; };
     927                466BC03C1FA266DA002FA9C1 /* WebSWContextManagerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */; };
    928928                46A2B6081E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */; };
    929929                46A2B6091E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */; };
     
    31953195                4131F3CF1F96A9360059995A /* ServiceWorkerClientFetch.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ServiceWorkerClientFetch.messages.in; sourceTree = "<group>"; };
    31963196                4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerClientFetch.cpp; sourceTree = "<group>"; };
    3197                 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerContextManager.h; sourceTree = "<group>"; };
    3198                 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerContextManager.cpp; sourceTree = "<group>"; };
    31993197                4131F3E01F98712C0059995A /* WebServiceWorkerFetchTaskClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebServiceWorkerFetchTaskClient.cpp; sourceTree = "<group>"; };
    32003198                4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageEngineCaches.cpp; sourceTree = "<group>"; };
     
    32323230                41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCResolver.cpp; path = Network/webrtc/LibWebRTCResolver.cpp; sourceTree = "<group>"; };
    32333231                4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
    3234                 460F488D1F996F6C00CF4B87 /* ServiceWorkerContextManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerContextManagerMessageReceiver.cpp; sourceTree = "<group>"; };
    3235                 460F488E1F996F6C00CF4B87 /* ServiceWorkerContextManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerContextManagerMessages.h; sourceTree = "<group>"; };
     3232                460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWContextManagerConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
     3233                460F488E1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWContextManagerConnectionMessages.h; sourceTree = "<group>"; };
    32363234                462107D71F38DBD300DD7810 /* PingLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PingLoad.cpp; path = NetworkProcess/PingLoad.cpp; sourceTree = "<group>"; };
    32373235                463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKProcessTerminationReason.h; sourceTree = "<group>"; };
    32383236                463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessTerminationReason.h; sourceTree = "<group>"; };
    32393237                465250E51ECF52CD002025CB /* WebKit2InitializeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKit2InitializeCocoa.mm; sourceTree = "<group>"; };
     3238                466BC0381FA266C9002FA9C1 /* WebSWContextManagerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWContextManagerConnection.cpp; sourceTree = "<group>"; };
     3239                466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWContextManagerConnection.h; sourceTree = "<group>"; };
     3240                466BC03A1FA266C9002FA9C1 /* WebSWContextManagerConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWContextManagerConnection.messages.in; sourceTree = "<group>"; };
    32403241                46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundProcessResponsivenessTimer.cpp; sourceTree = "<group>"; };
    32413242                46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackgroundProcessResponsivenessTimer.h; sourceTree = "<group>"; };
     
    62136214                                4131F3CE1F96A4950059995A /* ServiceWorkerClientFetch.h */,
    62146215                                4131F3CF1F96A9360059995A /* ServiceWorkerClientFetch.messages.in */,
    6215                                 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */,
    6216                                 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */,
    62176216                                414DEDC51F9E4BEC0047C40D /* ServiceWorkerFrameLoaderClient.cpp */,
    62186217                                414DEDC41F9E4BEB0047C40D /* ServiceWorkerFrameLoaderClient.h */,
     
    62246223                                517A53021F4793B200DCDC0A /* WebSWClientConnection.h */,
    62256224                                517A530C1F479E9700DCDC0A /* WebSWClientConnection.messages.in */,
     6225                                466BC0381FA266C9002FA9C1 /* WebSWContextManagerConnection.cpp */,
     6226                                466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */,
     6227                                466BC03A1FA266C9002FA9C1 /* WebSWContextManagerConnection.messages.in */,
    62266228                                83F1A0771F96E7700045B94E /* WebSWOriginTable.cpp */,
    62276229                                83F1A0781F96E7710045B94E /* WebSWOriginTable.h */,
     
    80668068                                E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */,
    80678069                                617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchMessageReceiver.cpp */,
    8068                                 460F488D1F996F6C00CF4B87 /* ServiceWorkerContextManagerMessageReceiver.cpp */,
    8069                                 460F488E1F996F6C00CF4B87 /* ServiceWorkerContextManagerMessages.h */,
    80708070                                2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */,
    80718071                                2DE6943C18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h */,
     
    81628162                                517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */,
    81638163                                517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */,
     8164                                460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */,
     8165                                460F488E1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessages.h */,
    81648166                                517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */,
    81658167                                517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */,
     
    88428844                                E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */,
    88438845                                514D9F5719119D35000063A7 /* ServicesController.h in Headers */,
    8844                                 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */,
    8845                                 460F48901F996F7100CF4B87 /* ServiceWorkerContextManagerMessages.h in Headers */,
    88468846                                414DEDD71F9EDDE50047C40D /* ServiceWorkerProcessProxy.h in Headers */,
    88478847                                1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */,
     
    90799079                                517A53051F4793C600DCDC0A /* WebSWClientConnection.h in Headers */,
    90809080                                517A53101F47A86200DCDC0A /* WebSWClientConnectionMessages.h in Headers */,
     9081                                466BC03C1FA266DA002FA9C1 /* WebSWContextManagerConnection.h in Headers */,
     9082                                460F48901F996F7100CF4B87 /* WebSWContextManagerConnectionMessages.h in Headers */,
    90819083                                832994A81F96F50200AC57B1 /* WebSWOriginStore.h in Headers */,
    90829084                                83F1A07A1F96E7790045B94E /* WebSWOriginTable.h in Headers */,
     
    1043710439                                4131F3D11F96BCCC0059995A /* ServiceWorkerClientFetch.cpp in Sources */,
    1043810440                                617A52D81F43A9DA00DCDC0A /* ServiceWorkerClientFetchMessageReceiver.cpp in Sources */,
    10439                                 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */,
    10440                                 460F488F1F996F7100CF4B87 /* ServiceWorkerContextManagerMessageReceiver.cpp in Sources */,
    1044110441                                414DEDD81F9EDDE50047C40D /* ServiceWorkerProcessProxy.cpp in Sources */,
    1044210442                                1AFDE6591954A42B00C48FFA /* SessionState.cpp in Sources */,
     
    1073710737                                517A53041F4793C600DCDC0A /* WebSWClientConnection.cpp in Sources */,
    1073810738                                517A530F1F47A86200DCDC0A /* WebSWClientConnectionMessageReceiver.cpp in Sources */,
     10739                                466BC03B1FA266DA002FA9C1 /* WebSWContextManagerConnection.cpp in Sources */,
     10740                                460F488F1F996F7100CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp in Sources */,
    1073910741                                832994A71F96F50200AC57B1 /* WebSWOriginStore.cpp in Sources */,
    1074010742                                83F1A0791F96E7790045B94E /* WebSWOriginTable.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp

    r224040 r224041  
    2525
    2626#include "config.h"
    27 #include "ServiceWorkerContextManager.h"
     27#include "WebSWContextManagerConnection.h"
    2828
    2929#if ENABLE(SERVICE_WORKER)
     
    4444#include <WebCore/EmptyFrameLoaderClient.h>
    4545#include <WebCore/LibWebRTCProvider.h>
    46 #include <WebCore/MessagePortChannel.h>
    4746#include <WebCore/PageConfiguration.h>
    4847#include <WebCore/RuntimeEnabledFeatures.h>
     
    8382};
    8483
    85 ServiceWorkerContextManager::ServiceWorkerContextManager(Ref<IPC::Connection>&& connection, uint64_t pageID, const WebPreferencesStore& store)
     84WebSWContextManagerConnection::WebSWContextManagerConnection(Ref<IPC::Connection>&& connection, uint64_t pageID, const WebPreferencesStore& store)
    8685    : m_connectionToStorageProcess(WTFMove(connection))
    8786    , m_pageID(pageID)
     
    9089}
    9190
    92 void ServiceWorkerContextManager::updatePreferences(const WebPreferencesStore& store)
     91void WebSWContextManagerConnection::updatePreferences(const WebPreferencesStore& store)
    9392{
    9493    RuntimeEnabledFeatures::sharedFeatures().setCacheAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::cacheAPIEnabledKey()));
     
    9695}
    9796
    98 void ServiceWorkerContextManager::startServiceWorker(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
     97void WebSWContextManagerConnection::startServiceWorker(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
    9998{
    10099    // FIXME: Provide a sensical session ID.
     
    113112    auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, WebProcess::singleton().cacheStorageProvider());
    114113    auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier();
    115     auto result = m_workerMap.add(serviceWorkerIdentifier, WTFMove(serviceWorkerThreadProxy));
    116     ASSERT_UNUSED(result, result.isNewEntry);
     114    SWContextManager::singleton().registerServiceWorkerThread(WTFMove(serviceWorkerThreadProxy));
    117115
    118116    LOG(ServiceWorker, "Context process PID: %i started worker thread %s\n", getpid(), data.workerID.utf8().data());
     
    121119}
    122120
    123 void ServiceWorkerContextManager::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options)
     121void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options)
    124122{
    125     auto serviceWorkerThreadProxy = serviceWorkerIdentifier ? m_workerMap.get(serviceWorkerIdentifier) : nullptr;
     123    auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
    126124    if (!serviceWorkerThreadProxy) {
    127125        m_connectionToStorageProcess->send(Messages::StorageProcess::DidNotHandleFetch(serverConnectionIdentifier, fetchIdentifier), 0);
     
    133131}
    134132
    135 void ServiceWorkerContextManager::postMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)
     133void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)
    136134{
    137     auto* serviceWorker = m_workerMap.get(serviceWorkerIdentifier);
    138     if (!serviceWorker)
    139         return;
    140 
    141     // FIXME: We should pass valid MessagePortChannels.
    142     serviceWorker->thread().postMessageToServiceWorkerGlobalScope(SerializedScriptValue::adopt(message.vector()), nullptr, sourceOrigin);
     135    SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(serviceWorkerIdentifier, SerializedScriptValue::adopt(message.vector()), sourceOrigin);
    143136}
    144137
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h

    r224040 r224041  
    3030#include "Connection.h"
    3131#include "MessageReceiver.h"
    32 #include <WebCore/ServiceWorkerThreadProxy.h>
    33 #include <wtf/HashMap.h>
     32#include <WebCore/SWContextManager.h>
    3433
    3534namespace WebCore {
     
    4039
    4140namespace WebKit {
     41
    4242struct WebPreferencesStore;
    4343
    44 class ServiceWorkerContextManager : public IPC::MessageReceiver {
     44class WebSWContextManagerConnection : public WebCore::SWContextManager::Connection, public IPC::MessageReceiver {
    4545public:
    46     ServiceWorkerContextManager(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&);
     46    WebSWContextManagerConnection(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&);
    4747
    4848    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     49
     50    void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin);
    4951
    5052private:
     
    5355    void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
    5456    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);
    5657
    5758    Ref<IPC::Connection> m_connectionToStorageProcess;
    58     HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThreadProxy>> m_workerMap;
    5959    uint64_t m_pageID { 0 };
    6060    uint64_t m_previousServiceWorkerID { 0 };
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in

    r224040 r224041  
    2323#if ENABLE(SERVICE_WORKER)
    2424
    25 messages -> ServiceWorkerContextManager {
     25messages -> WebSWContextManagerConnection {
    2626    StartServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
    2727    StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
    28     PostMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, IPC::DataReference message, String sourceOrigin)
     28    PostMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, IPC::DataReference message, String sourceOrigin)
    2929}
    3030
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r223981 r224041  
    4242#include "NetworkSessionCreationParameters.h"
    4343#include "PluginProcessConnectionManager.h"
    44 #include "ServiceWorkerContextManager.h"
    45 #include "ServiceWorkerContextManagerMessages.h"
    4644#include "SessionTracker.h"
    4745#include "StatisticsData.h"
     
    6967#include "WebProcessProxyMessages.h"
    7068#include "WebResourceLoadStatisticsStoreMessages.h"
     69#include "WebSWContextManagerConnection.h"
     70#include "WebSWContextManagerConnectionMessages.h"
    7171#include "WebServiceWorkerProvider.h"
    7272#include "WebSocketStream.h"
     
    675675
    676676#if ENABLE(SERVICE_WORKER)
    677     if (decoder.messageReceiverName() == Messages::ServiceWorkerContextManager::messageReceiverName()) {
    678         ASSERT(m_serviceWorkerManager);
    679         if (m_serviceWorkerManager)
    680             m_serviceWorkerManager->didReceiveMessage(connection, decoder);
     677    if (decoder.messageReceiverName() == Messages::WebSWContextManagerConnection::messageReceiverName()) {
     678        ASSERT(SWContextManager::singleton().connection());
     679        if (auto* contextManagerConnection = SWContextManager::singleton().connection())
     680            static_cast<WebSWContextManagerConnection&>(*contextManagerConnection).didReceiveMessage(connection, decoder);
    681681        return;
    682682    }
     
    16431643void WebProcess::getWorkerContextConnection(uint64_t pageID, const WebPreferencesStore& store)
    16441644{
    1645     ASSERT(!m_serviceWorkerManager);
    1646 
    16471645#if USE(UNIX_DOMAIN_SOCKETS)
    16481646    IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
     
    16651663    auto workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    16661664    workerContextConnection->open();
    1667     m_serviceWorkerManager = ServiceWorkerContextManager(WTFMove(workerContextConnection), pageID, store);
     1665    SWContextManager::singleton().setConnection(std::make_unique<WebSWContextManagerConnection>(WTFMove(workerContextConnection), pageID, store));
    16681666    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidGetWorkerContextConnection(connectionClientPort), 0);
    16691667}
  • trunk/Source/WebKit/WebProcess/WebProcess.h

    r223981 r224041  
    3131#include "ResourceCachesToClear.h"
    3232#include "SandboxExtension.h"
    33 #include "ServiceWorkerContextManager.h"
    3433#include "TextCheckerState.h"
    3534#include "ViewUpdateDispatcher.h"
     
    438437    std::unique_ptr<WaylandCompositorDisplay> m_waylandCompositorDisplay;
    439438#endif
    440 #if ENABLE(SERVICE_WORKER)
    441     std::optional<ServiceWorkerContextManager> m_serviceWorkerManager;
    442 #endif
    443439};
    444440
Note: See TracChangeset for help on using the changeset viewer.