Changeset 220977 in webkit


Ignore:
Timestamp:
Aug 21, 2017 1:02:42 PM (7 years ago)
Author:
beidson@apple.com
Message:

Split the one SWServer::Connection into SWClientConnection and SWServer::Connection.
https://bugs.webkit.org/show_bug.cgi?id=175745

Reviewed by Andy Estes.

Source/WebCore:

No new tests (No behavior change).

Each of these has a much different environment that it lives in, so being the same object
hinders clean development.

This split will also make it easier for the WebCore objects to directly handle WK2 messages.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/Logging.h:
  • workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::scheduleJob):

  • workers/service/ServiceWorkerContainer.h:
  • workers/service/ServiceWorkerProvider.h:
  • workers/service/server/SWClientConnection.cpp: Copied from Source/WebCore/workers/service/server/SWServer.cpp.

(WebCore::SWClientConnection::SWClientConnection):
(WebCore::SWClientConnection::~SWClientConnection):
(WebCore::SWClientConnection::scheduleJob):
(WebCore::SWClientConnection::jobRejectedInServer):

  • workers/service/server/SWClientConnection.h: Copied from Source/WebCore/workers/service/server/SWServer.h.
  • workers/service/server/SWServer.cpp:

(WebCore::SWServer::Connection::Connection):
(WebCore::SWServer::Connection::~Connection):
(WebCore::SWServer::~SWServer):
(WebCore::SWServer::Connection::scheduleJobInServer):
(WebCore::SWServer::scheduleJob):
(WebCore::SWServer::registerConnection):
(WebCore::SWServer::unregisterConnection):
(WebCore::SWServer::Connection::scheduleJob): Deleted.
(WebCore::SWServer::Connection::jobRejected): Deleted.

  • workers/service/server/SWServer.h:

(WebCore::SWServer::Connection::server):
(WebCore::SWServer::Connection::~Connection): Deleted.

Source/WebKit:

  • CMakeLists.txt:
  • DerivedSources.make:
  • WebKit.xcodeproj/project.pbxproj:
  • StorageProcess/ServiceWorker/WebSWServerConnection.cpp: Renamed from Source/WebKit/WebProcess/Storage/WebSWServerConnection.cpp.

(WebKit::WebSWServerConnection::WebSWServerConnection):
(WebKit::WebSWServerConnection::~WebSWServerConnection):
(WebKit::WebSWServerConnection::disconnectedFromWebProcess):
(WebKit::WebSWServerConnection::rejectJobInClient):

  • StorageProcess/ServiceWorker/WebSWServerConnection.h: Copied from Source/WebKit/WebProcess/Storage/WebSWServerConnection.h.

(WebKit::WebSWServerConnection::identifier const):

  • StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: Copied from Source/WebKit/WebProcess/Storage/WebSWServerConnection.messages.in.
  • StorageProcess/StorageToWebProcessConnection.cpp:

(WebKit::StorageToWebProcessConnection::didReceiveMessage):
(WebKit::StorageToWebProcessConnection::didClose):
(WebKit::StorageToWebProcessConnection::establishSWServerConnection):
(WebKit::StorageToWebProcessConnection::removeSWServerConnection):

  • StorageProcess/StorageToWebProcessConnection.h:
  • WebProcess/Storage/WebSWClientConnection.cpp: Copied from Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp.

(WebKit::WebSWClientConnection::WebSWClientConnection):
(WebKit::WebSWClientConnection::~WebSWClientConnection):
(WebKit::WebSWClientConnection::scheduleJobInServer):

  • WebProcess/Storage/WebSWClientConnection.h: Renamed from Source/WebKit/WebProcess/Storage/WebSWServerConnection.h.

(WebKit::WebSWClientConnection::identifier const):

  • WebProcess/Storage/WebSWClientConnection.messages.in: Renamed from Source/WebKit/WebProcess/Storage/WebSWServerConnection.messages.in.
  • WebProcess/Storage/WebServiceWorkerProvider.cpp:

(WebKit::WebServiceWorkerProvider::serviceWorkerConnectionForSession):

  • WebProcess/Storage/WebServiceWorkerProvider.h:
  • WebProcess/Storage/WebToStorageProcessConnection.cpp:

(WebKit::WebToStorageProcessConnection::didReceiveMessage):
(WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession):

  • WebProcess/Storage/WebToStorageProcessConnection.h:
Location:
trunk/Source
Files:
1 added
19 edited
5 copied
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r220956 r220977  
    29922992    workers/service/ServiceWorkerRegistrationParameters.cpp
    29932993
     2994    workers/service/server/SWClientConnection.cpp
    29942995    workers/service/server/SWServer.cpp
    29952996
  • trunk/Source/WebCore/ChangeLog

    r220971 r220977  
     12017-08-21  Brady Eidson  <beidson@apple.com>
     2
     3        Split the one SWServer::Connection into SWClientConnection and SWServer::Connection.
     4        https://bugs.webkit.org/show_bug.cgi?id=175745
     5
     6        Reviewed by Andy Estes.
     7
     8        No new tests (No behavior change).
     9
     10        Each of these has a much different environment that it lives in, so being the same object
     11        hinders clean development.
     12       
     13        This split will also make it easier for the WebCore objects to directly handle WK2 messages.
     14       
     15        * CMakeLists.txt:
     16        * WebCore.xcodeproj/project.pbxproj:
     17       
     18        * platform/Logging.h:
     19
     20        * workers/service/ServiceWorkerContainer.cpp:
     21        (WebCore::ServiceWorkerContainer::addRegistration):
     22        (WebCore::ServiceWorkerContainer::scheduleJob):
     23        * workers/service/ServiceWorkerContainer.h:
     24
     25        * workers/service/ServiceWorkerProvider.h:
     26
     27        * workers/service/server/SWClientConnection.cpp: Copied from Source/WebCore/workers/service/server/SWServer.cpp.
     28        (WebCore::SWClientConnection::SWClientConnection):
     29        (WebCore::SWClientConnection::~SWClientConnection):
     30        (WebCore::SWClientConnection::scheduleJob):
     31        (WebCore::SWClientConnection::jobRejectedInServer):
     32        * workers/service/server/SWClientConnection.h: Copied from Source/WebCore/workers/service/server/SWServer.h.
     33
     34        * workers/service/server/SWServer.cpp:
     35        (WebCore::SWServer::Connection::Connection):
     36        (WebCore::SWServer::Connection::~Connection):
     37        (WebCore::SWServer::~SWServer):
     38        (WebCore::SWServer::Connection::scheduleJobInServer):
     39        (WebCore::SWServer::scheduleJob):
     40        (WebCore::SWServer::registerConnection):
     41        (WebCore::SWServer::unregisterConnection):
     42        (WebCore::SWServer::Connection::scheduleJob): Deleted.
     43        (WebCore::SWServer::Connection::jobRejected): Deleted.
     44        * workers/service/server/SWServer.h:
     45        (WebCore::SWServer::Connection::server):
     46        (WebCore::SWServer::Connection::~Connection): Deleted.
     47
    1482017-08-21  Andy Estes  <aestes@apple.com>
    249
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r220971 r220977  
    23082308                517A52F01F47535B00DCDC0A /* SWServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A52EE1F47535900DCDC0A /* SWServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23092309                517A52F11F4754E700DCDC0A /* SWServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A52EF1F47535900DCDC0A /* SWServer.cpp */; };
     2310                517A531C1F4B53B100DCDC0A /* SWClientConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A52FE1F478CCE00DCDC0A /* SWClientConnection.cpp */; };
     2311                517A531D1F4B53B100DCDC0A /* SWClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A52FF1F478CCE00DCDC0A /* SWClientConnection.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23102312                517A63C31B74318700E7DCDC /* KeyedDecoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */; };
    23112313                517A63C41B74318B00E7DCDC /* KeyedEncoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */; };
     
    1010210104                517A52EE1F47535900DCDC0A /* SWServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWServer.h; sourceTree = "<group>"; };
    1010310105                517A52EF1F47535900DCDC0A /* SWServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SWServer.cpp; sourceTree = "<group>"; };
     10106                517A52FE1F478CCE00DCDC0A /* SWClientConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SWClientConnection.cpp; sourceTree = "<group>"; };
     10107                517A52FF1F478CCE00DCDC0A /* SWClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWClientConnection.h; sourceTree = "<group>"; };
    1010410108                517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedDecoderCF.cpp; sourceTree = "<group>"; };
    1010510109                517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedDecoderCF.h; sourceTree = "<group>"; };
     
    1868818692                        isa = PBXGroup;
    1868918693                        children = (
     18694                                517A52FE1F478CCE00DCDC0A /* SWClientConnection.cpp */,
     18695                                517A52FF1F478CCE00DCDC0A /* SWClientConnection.h */,
    1869018696                                517A52EF1F47535900DCDC0A /* SWServer.cpp */,
    1869118697                                517A52EE1F47535900DCDC0A /* SWServer.h */,
     
    2941329419                                E46180291C8A06CD0026C02C /* RenderTreeUpdater.h in Headers */,
    2941429420                                E48E332C1F47037C00BAB0EF /* RenderTreeUpdaterFirstLetter.h in Headers */,
     29421                                E48E33321F47437300BAB0EF /* RenderTreeUpdaterGeneratedContent.h in Headers */,
    2941529422                                E48E332E1F47038000BAB0EF /* RenderTreeUpdaterListItem.h in Headers */,
    2941629423                                E44614520CD68A3500FADA75 /* RenderVideo.h in Headers */,
     
    2962729634                                FD45A95B175D41EE00C21EC8 /* ShapeInterval.h in Headers */,
    2962829635                                FD45A952175D3F3E00C21EC8 /* ShapeOutsideInfo.h in Headers */,
    29629                                 E48E33321F47437300BAB0EF /* RenderTreeUpdaterGeneratedContent.h in Headers */,
    2963029636                                FD1AF1501656F15100C6D4F7 /* ShapeValue.h in Headers */,
    2963129637                                1A4A954E0B4EDCCB002D8C3C /* SharedBuffer.h in Headers */,
     
    3003230038                                B2227AF60D00BF220071B782 /* SVGZoomAndPan.h in Headers */,
    3003330039                                B2E4EC980D00C22B00432643 /* SVGZoomEvent.h in Headers */,
     30040                                517A531D1F4B53B100DCDC0A /* SWClientConnection.h in Headers */,
    3003430041                                517A52F01F47535B00DCDC0A /* SWServer.h in Headers */,
    3003530042                                E180811716FCF9CB00B80D07 /* SynchronousLoaderClient.h in Headers */,
     
    3127631283                                62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */,
    3127731284                                97BC6A201505F081001B74AC /* Database.cpp in Sources */,
    31278                                 E48E33311F47437000BAB0EF /* RenderTreeUpdaterGeneratedContent.cpp in Sources */,
    3127931285                                97BC6A231505F081001B74AC /* DatabaseAuthorizer.cpp in Sources */,
    3128031286                                97BC6A271505F081001B74AC /* DatabaseContext.cpp in Sources */,
     
    3330633312                                E461802B1C8A06D90026C02C /* RenderTreeUpdater.cpp in Sources */,
    3330733313                                E48284081F44594C00863AC3 /* RenderTreeUpdaterFirstLetter.cpp in Sources */,
     33314                                E48E33311F47437000BAB0EF /* RenderTreeUpdaterGeneratedContent.cpp in Sources */,
    3330833315                                E48E332D1F47038000BAB0EF /* RenderTreeUpdaterListItem.cpp in Sources */,
    3330933316                                E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */,
     
    3378533792                                B2227AF50D00BF220071B782 /* SVGZoomAndPan.cpp in Sources */,
    3378633793                                B2E4EC970D00C22B00432643 /* SVGZoomEvent.cpp in Sources */,
     33794                                517A531C1F4B53B100DCDC0A /* SWClientConnection.cpp in Sources */,
    3378733795                                517A52F11F4754E700DCDC0A /* SWServer.cpp in Sources */,
    3378833796                                E180811216FCF42F00B80D07 /* SynchronousLoaderClient.cpp in Sources */,
  • trunk/Source/WebCore/platform/Logging.h

    r220812 r220977  
    8282    M(Scrolling) \
    8383    M(Services) \
     84    M(ServiceWorker) \
    8485    M(SpellingAndGrammar) \
    8586    M(SQLDatabase) \
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r220924 r220977  
    8181    }
    8282
    83     if (!m_serverConnection)
    84         m_serverConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
     83    if (!m_swConnection)
     84        m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
    8585
    8686    if (relativeScriptURL.isEmpty()) {
     
    121121void ServiceWorkerContainer::scheduleJob(Ref<ServiceWorkerJob>&& job)
    122122{
    123     ASSERT(m_serverConnection);
     123    ASSERT(m_swConnection);
    124124
    125125    ServiceWorkerJob& rawJob = job.get();
     
    127127    ASSERT_UNUSED(result, result.isNewEntry);
    128128
    129     m_serverConnection->scheduleJob(rawJob);
     129    m_swConnection->scheduleJob(rawJob);
    130130}
    131131
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h

    r220924 r220977  
    3131#include "DOMPromiseProxy.h"
    3232#include "EventTarget.h"
     33#include "SWClientConnection.h"
    3334#include "SWServer.h"
    3435#include "ServiceWorkerJobClient.h"
     
    8384    NavigatorBase& m_navigator;
    8485
    85     RefPtr<SWServer::Connection> m_serverConnection;
     86    RefPtr<SWClientConnection> m_swConnection;
    8687    HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_jobMap;
    8788
  • trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h

    r220924 r220977  
    2828#if ENABLE(SERVICE_WORKER)
    2929
    30 #include "SWServer.h"
    31 
    3230namespace PAL {
    3331class SessionID;
     
    3634namespace WebCore {
    3735
     36class SWClientConnection;
    3837class ServiceWorkerJob;
    3938
     
    4544    WEBCORE_EXPORT static void setSharedProvider(ServiceWorkerProvider&);
    4645
    47     virtual SWServer::Connection& serviceWorkerConnectionForSession(const PAL::SessionID&) = 0;
     46    virtual SWClientConnection& serviceWorkerConnectionForSession(const PAL::SessionID&) = 0;
    4847};
    4948
  • trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp

    r220974 r220977  
    2525
    2626#include "config.h"
    27 #include "SWServer.h"
     27#include "SWClientConnection.h"
    2828
    2929#if ENABLE(SERVICE_WORKER)
    3030
    31 #include "ExceptionCode.h"
    3231#include "ExceptionData.h"
    3332#include "ServiceWorkerJobData.h"
    34 #include <wtf/text/WTFString.h>
    3533
    3634namespace WebCore {
    3735
    38 void SWServer::Connection::scheduleJob(ServiceWorkerJob& job)
     36SWClientConnection::SWClientConnection()
     37{
     38}
     39
     40SWClientConnection::~SWClientConnection()
     41{
     42}
     43
     44void SWClientConnection::scheduleJob(ServiceWorkerJob& job)
    3945{
    4046    auto addResult = m_scheduledJobs.add(job.identifier(), &job);
    4147    ASSERT_UNUSED(addResult, addResult.isNewEntry);
    4248
    43     scheduleJob(job.data());
     49    scheduleJobInServer(job.data());
    4450}
    4551
    46 void SWServer::Connection::jobRejected(uint64_t jobIdentifier, const ExceptionData& exceptionData)
     52void SWClientConnection::jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData& exceptionData)
    4753{
    4854    auto job = m_scheduledJobs.take(jobIdentifier);
  • trunk/Source/WebCore/workers/service/server/SWClientConnection.h

    r220974 r220977  
    3636struct ExceptionData;
    3737
    38 class SWServer {
     38class SWClientConnection : public ThreadSafeRefCounted<SWClientConnection> {
    3939public:
    40     class Connection : public ThreadSafeRefCounted<Connection> {
    41     public:
    42         virtual ~Connection() { }
    43         void scheduleJob(ServiceWorkerJob&);
     40    WEBCORE_EXPORT SWClientConnection();
     41    WEBCORE_EXPORT virtual ~SWClientConnection();
    4442
    45     protected:
    46         WEBCORE_EXPORT void jobRejected(uint64_t jobIdentifier, const ExceptionData&);
     43    void scheduleJob(ServiceWorkerJob&);
    4744
    48     private:
    49         virtual void scheduleJob(const ServiceWorkerJobData&) = 0;
     45protected:
     46    WEBCORE_EXPORT void jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData&);
    5047
    51         HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
    52     };
     48private:
     49    virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
    5350
     51    HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
    5452};
    5553
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r220924 r220977  
    3131#include "ExceptionCode.h"
    3232#include "ExceptionData.h"
     33#include "Logging.h"
    3334#include "ServiceWorkerJobData.h"
    3435#include <wtf/text/WTFString.h>
     
    3637namespace WebCore {
    3738
    38 void SWServer::Connection::scheduleJob(ServiceWorkerJob& job)
     39SWServer::Connection::Connection(SWServer& server)
     40    : m_server(server)
    3941{
    40     auto addResult = m_scheduledJobs.add(job.identifier(), &job);
    41     ASSERT_UNUSED(addResult, addResult.isNewEntry);
    42 
    43     scheduleJob(job.data());
     42    m_server.registerConnection(*this);
    4443}
    4544
    46 void SWServer::Connection::jobRejected(uint64_t jobIdentifier, const ExceptionData& exceptionData)
     45SWServer::Connection::~Connection()
    4746{
    48     auto job = m_scheduledJobs.take(jobIdentifier);
    49     if (!job) {
    50         LOG_ERROR("Job %" PRIu64 " rejected from server, but was not found", jobIdentifier);
    51         return;
    52     }
     47    m_server.unregisterConnection(*this);
     48}
    5349
    54     job->failedWithException(exceptionData.toException());
     50
     51SWServer::~SWServer()
     52{
     53    RELEASE_ASSERT(m_connections.isEmpty());
     54}
     55
     56void SWServer::Connection::scheduleJobInServer(const ServiceWorkerJobData& jobData)
     57{
     58    LOG(ServiceWorker, "Scheduling ServiceWorker job %" PRIu64 " in server", jobData.identifier);
     59    m_server.scheduleJob(*this, jobData);
     60}
     61
     62void SWServer::scheduleJob(Connection& connection, const ServiceWorkerJobData& jobData)
     63{
     64    // FIXME: For now, all scheduled jobs immediately reject.
     65    connection.rejectJobInClient(jobData.identifier, ExceptionData { UnknownError, ASCIILiteral("serviceWorker job scheduling is not yet implemented") });
     66}
     67
     68void SWServer::registerConnection(Connection& connection)
     69{
     70    auto result = m_connections.add(&connection);
     71    ASSERT_UNUSED(result, result.isNewEntry);
     72}
     73
     74void SWServer::unregisterConnection(Connection& connection)
     75{
     76    ASSERT(!m_connections.contains(&connection));
     77    m_connections.remove(&connection);
    5578}
    5679
  • trunk/Source/WebCore/workers/service/server/SWServer.h

    r220924 r220977  
    3030#include "ServiceWorkerJob.h"
    3131#include <wtf/HashMap.h>
     32#include <wtf/HashSet.h>
    3233#include <wtf/ThreadSafeRefCounted.h>
    3334
     
    3839class SWServer {
    3940public:
    40     class Connection : public ThreadSafeRefCounted<Connection> {
     41    class Connection {
     42    friend class SWServer;
    4143    public:
    42         virtual ~Connection() { }
    43         void scheduleJob(ServiceWorkerJob&);
     44        WEBCORE_EXPORT virtual ~Connection();
    4445
    4546    protected:
    46         WEBCORE_EXPORT void jobRejected(uint64_t jobIdentifier, const ExceptionData&);
     47        WEBCORE_EXPORT Connection(SWServer&);
     48        SWServer& server() { return m_server; }
     49
     50        WEBCORE_EXPORT void scheduleJobInServer(const ServiceWorkerJobData&);
    4751
    4852    private:
    49         virtual void scheduleJob(const ServiceWorkerJobData&) = 0;
     53        virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0;
    5054
    51         HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
     55        SWServer& m_server;
    5256    };
    5357
     58    WEBCORE_EXPORT ~SWServer();
     59
     60    WEBCORE_EXPORT void scheduleJob(Connection&, const ServiceWorkerJobData&);
     61
     62private:
     63    void registerConnection(Connection&);
     64    void unregisterConnection(Connection&);
     65
     66    HashSet<Connection*> m_connections;
    5467};
    5568
  • trunk/Source/WebKit/CMakeLists.txt

    r220924 r220977  
    3131    "${WEBKIT2_DIR}/StorageProcess"
    3232    "${WEBKIT2_DIR}/StorageProcess/IndexedDB"
     33    "${WEBKIT2_DIR}/StorageProcess/ServiceWorker"
    3334    "${WEBKIT2_DIR}/UIProcess"
    3435    "${WEBKIT2_DIR}/UIProcess/API"
     
    274275
    275276    StorageProcess/IndexedDB/WebIDBConnectionToClient.cpp
     277
     278    StorageProcess/ServiceWorker/WebSWServerConnection.cpp
     279
    276280    UIProcess/BackgroundProcessResponsivenessTimer.cpp
    277281    UIProcess/ChildProcessProxy.cpp
     
    529533    WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
    530534
    531     WebProcess/Storage/WebSWServerConnection.cpp
     535    WebProcess/Storage/WebSWClientConnection.cpp
    532536    WebProcess/Storage/WebServiceWorkerProvider.cpp
    533537    WebProcess/Storage/WebToStorageProcessConnection.cpp
     
    613617    StorageProcess/IndexedDB/WebIDBConnectionToClient.messages.in
    614618
     619    StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
     620
    615621    UIProcess/DrawingAreaProxy.messages.in
    616622    UIProcess/RemoteWebInspectorProxy.messages.in
     
    670676    WebProcess/Plugins/PluginProxy.messages.in
    671677
    672     WebProcess/Storage/WebSWServerConnection.messages.in
     678    WebProcess/Storage/WebSWClientConnection.messages.in
    673679
    674680    WebProcess/UserContent/WebUserContentController.messages.in
  • trunk/Source/WebKit/ChangeLog

    r220963 r220977  
     12017-08-21  Brady Eidson  <beidson@apple.com>
     2
     3        Split the one SWServer::Connection into SWClientConnection and SWServer::Connection.
     4        https://bugs.webkit.org/show_bug.cgi?id=175745
     5
     6        Reviewed by Andy Estes.
     7
     8        * CMakeLists.txt:
     9        * DerivedSources.make:
     10        * WebKit.xcodeproj/project.pbxproj:
     11
     12        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: Renamed from Source/WebKit/WebProcess/Storage/WebSWServerConnection.cpp.
     13        (WebKit::WebSWServerConnection::WebSWServerConnection):
     14        (WebKit::WebSWServerConnection::~WebSWServerConnection):
     15        (WebKit::WebSWServerConnection::disconnectedFromWebProcess):
     16        (WebKit::WebSWServerConnection::rejectJobInClient):
     17        * StorageProcess/ServiceWorker/WebSWServerConnection.h: Copied from Source/WebKit/WebProcess/Storage/WebSWServerConnection.h.
     18        (WebKit::WebSWServerConnection::identifier const):
     19        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: Copied from Source/WebKit/WebProcess/Storage/WebSWServerConnection.messages.in.
     20
     21        * StorageProcess/StorageToWebProcessConnection.cpp:
     22        (WebKit::StorageToWebProcessConnection::didReceiveMessage):
     23        (WebKit::StorageToWebProcessConnection::didClose):
     24        (WebKit::StorageToWebProcessConnection::establishSWServerConnection):
     25        (WebKit::StorageToWebProcessConnection::removeSWServerConnection):
     26        * StorageProcess/StorageToWebProcessConnection.h:
     27
     28        * WebProcess/Storage/WebSWClientConnection.cpp: Copied from Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp.
     29        (WebKit::WebSWClientConnection::WebSWClientConnection):
     30        (WebKit::WebSWClientConnection::~WebSWClientConnection):
     31        (WebKit::WebSWClientConnection::scheduleJobInServer):
     32        * WebProcess/Storage/WebSWClientConnection.h: Renamed from Source/WebKit/WebProcess/Storage/WebSWServerConnection.h.
     33        (WebKit::WebSWClientConnection::identifier const):
     34        * WebProcess/Storage/WebSWClientConnection.messages.in: Renamed from Source/WebKit/WebProcess/Storage/WebSWServerConnection.messages.in.
     35
     36        * WebProcess/Storage/WebServiceWorkerProvider.cpp:
     37        (WebKit::WebServiceWorkerProvider::serviceWorkerConnectionForSession):
     38        * WebProcess/Storage/WebServiceWorkerProvider.h:
     39
     40        * WebProcess/Storage/WebToStorageProcessConnection.cpp:
     41        (WebKit::WebToStorageProcessConnection::didReceiveMessage):
     42        (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession):
     43        * WebProcess/Storage/WebToStorageProcessConnection.h:
     44
    1452017-08-21  Charlie Turner  <cturner@igalia.com>
    246
  • trunk/Source/WebKit/DerivedSources.make

    r220924 r220977  
    3737    $(WebKit2)/StorageProcess \
    3838    $(WebKit2)/StorageProcess/IndexedDB \
     39    $(WebKit2)/StorageProcess/ServiceWorker \
    3940    $(WebKit2)/StorageProcess/mac \
    4041    $(WebKit2)/WebProcess/ApplePay \
     
    159160    WebPaymentCoordinator \
    160161    WebPaymentCoordinatorProxy \
     162    WebSWClientConnection \
    161163    WebSWServerConnection \
    162164    PlaybackSessionManager \
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp

    r220974 r220977  
    3232#include "StorageToWebProcessConnectionMessages.h"
    3333#include "WebProcess.h"
     34#include "WebSWClientConnectionMessages.h"
    3435#include "WebSWServerConnectionMessages.h"
    3536#include "WebToStorageProcessConnection.h"
     
    4445namespace WebKit {
    4546
    46 WebSWServerConnection::WebSWServerConnection(const SessionID& sessionID)
    47     : m_sessionID(sessionID)
    48     , m_connection(WebProcess::singleton().webToStorageProcessConnection()->connection())
    49 {
    50     bool result = sendSync(Messages::StorageToWebProcessConnection::EstablishSWServerConnection(sessionID), Messages::StorageToWebProcessConnection::EstablishSWServerConnection::Reply(m_identifier));
    51 
    52     ASSERT_UNUSED(result, result);
    53 }
    54 
    55 WebSWServerConnection::WebSWServerConnection(IPC::Connection& connection, uint64_t connectionIdentifier, const SessionID& sessionID)
    56     : m_sessionID(sessionID)
     47WebSWServerConnection::WebSWServerConnection(SWServer& server, IPC::Connection& connection, uint64_t connectionIdentifier, const SessionID& sessionID)
     48    : SWServer::Connection(server)
     49    , m_sessionID(sessionID)
    5750    , m_identifier(connectionIdentifier)
    5851    , m_connection(connection)
     
    6962}
    7063
    71 void WebSWServerConnection::scheduleJob(const ServiceWorkerJobData& jobData)
     64void WebSWServerConnection::rejectJobInClient(uint64_t jobIdentifier, const ExceptionData& exceptionData)
    7265{
    73     LOG(ServiceWorker, "Scheduling ServiceWorker job %" PRIu64 " in storage process", jobData.identifier);
    74     send(Messages::WebSWServerConnection::ScheduleStorageJob(jobData));
    75 }
    76 
    77 void WebSWServerConnection::scheduleStorageJob(const ServiceWorkerJobData& jobData)
    78 {
    79     ASSERT(isMainThread());
    80     LOG(ServiceWorker, "Received ServiceWorker job %" PRIu64 " in storage process", jobData.identifier);
    81 
    82     // FIXME: For now, all scheduled jobs immediately reject.
    83     send(Messages::WebSWServerConnection::JobRejected(jobData.identifier, ExceptionData { UnknownError, ASCIILiteral("serviceWorker job scheduling is not yet implemented") }));
     66    send(Messages::WebSWClientConnection::JobRejectedInServer(jobIdentifier, exceptionData));
    8467}
    8568
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h

    r220974 r220977  
    4141class WebSWServerConnection : public WebCore::SWServer::Connection, public IPC::MessageSender, public IPC::MessageReceiver {
    4242public:
    43     static Ref<WebSWServerConnection> create(const PAL::SessionID& sessionID)
    44     {
    45         return adoptRef(*new WebSWServerConnection(sessionID));
    46     }
    47     static Ref<WebSWServerConnection> create(IPC::Connection& connection, uint64_t connectionIdentifier, const PAL::SessionID& sessionID)
    48     {
    49         return adoptRef(*new WebSWServerConnection(connection, connectionIdentifier, sessionID));
    50     }
    51 
     43    WebSWServerConnection(WebCore::SWServer&, IPC::Connection&, uint64_t connectionIdentifier, const PAL::SessionID&);
     44    WebSWServerConnection(const WebSWServerConnection&) = delete;
    5245    ~WebSWServerConnection() final;
    5346
    5447    uint64_t identifier() const { return m_identifier; }
    55 
    56     void scheduleJob(const WebCore::ServiceWorkerJobData&) final;
    5748
    5849    void disconnectedFromWebProcess();
     
    6051
    6152private:
    62     WebSWServerConnection(const PAL::SessionID&);
    63     WebSWServerConnection(IPC::Connection&, uint64_t connectionIdentifier, const PAL::SessionID&);
    64 
    65     void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
     53    // Implement SWServer::Connection
     54    void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final;
    6655
    6756    IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); }
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in

    r220974 r220977  
    2424
    2525messages -> WebSWServerConnection {
    26     # Messages targetting the Storage process
    27     ScheduleStorageJob(struct WebCore::ServiceWorkerJobData jobData)
    28 
    29     # Messages targetting the Web process.
    30     # When possible, they can be implemented directly by WebCore::SWServer::Connection
    31     JobRejected(uint64_t identifier, struct WebCore::ExceptionData exception)
     26    # When possible, these messages can be implemented directly by WebCore::SWClientConnection
     27    ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData)
    3228}
    3329
  • trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp

    r220924 r220977  
    3636
    3737using namespace PAL;
     38using namespace WebCore;
    3839
    3940namespace WebKit {
     
    7475#if ENABLE(SERVICE_WORKER)
    7576    if (decoder.messageReceiverName() == Messages::WebSWServerConnection::messageReceiverName()) {
    76         auto iterator = m_webServiceWorkerConnections.find(decoder.destinationID());
    77         if (iterator != m_webServiceWorkerConnections.end())
     77        auto iterator = m_swConnections.find(decoder.destinationID());
     78        if (iterator != m_swConnections.end())
    7879            iterator->value->didReceiveMessage(connection, decoder);
    7980        return;
     
    105106
    106107#if ENABLE(SERVICE_WORKER)
    107     auto serviceWorkerConnections = m_webServiceWorkerConnections;
    108     for (auto& connection : serviceWorkerConnections.values())
     108    Vector<std::unique_ptr<WebSWServerConnection>> connectionVector;
     109    connectionVector.reserveInitialCapacity(m_swConnections.size());
     110
     111    for (auto& connection : m_swConnections.values())
     112        connectionVector.uncheckedAppend(WTFMove(connection));
     113    for (auto& connection : connectionVector)
    109114        connection->disconnectedFromWebProcess();
    110115
    111     m_webServiceWorkerConnections.clear();
     116    m_swConnections.clear();
    112117#endif
    113118}
     
    130135    serverConnectionIdentifier = generateConnectionToServerIdentifier();
    131136    LOG(ServiceWorker, "StorageToWebProcessConnection::establishSWServerConnection - %" PRIu64, serverConnectionIdentifier);
    132     ASSERT(!m_webServiceWorkerConnections.contains(serverConnectionIdentifier));
     137    ASSERT(!m_swConnections.contains(serverConnectionIdentifier));
    133138
    134     m_webServiceWorkerConnections.set(serverConnectionIdentifier, WebSWServerConnection::create(m_connection.get(), serverConnectionIdentifier, sessionID));
     139    auto result = m_swServers.add(sessionID, nullptr);
     140    if (result.isNewEntry)
     141        result.iterator->value = std::make_unique<SWServer>();
     142
     143    ASSERT(result.iterator->value);
     144
     145    m_swConnections.set(serverConnectionIdentifier, std::make_unique<WebSWServerConnection>(*result.iterator->value, m_connection.get(), serverConnectionIdentifier, sessionID));
    135146}
    136147
    137148void StorageToWebProcessConnection::removeSWServerConnection(uint64_t serverConnectionIdentifier)
    138149{
    139     ASSERT(m_webServiceWorkerConnections.contains(serverConnectionIdentifier));
     150    ASSERT(m_swConnections.contains(serverConnectionIdentifier));
    140151
    141     auto connection = m_webServiceWorkerConnections.take(serverConnectionIdentifier);
     152    auto connection = m_swConnections.take(serverConnectionIdentifier);
    142153    connection->disconnectedFromWebProcess();
    143154}
  • trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.h

    r220924 r220977  
    2929#include "MessageSender.h"
    3030
     31#include <WebCore/SWServer.h>
    3132#include <pal/SessionID.h>
    3233#include <wtf/HashMap.h>
     
    7071    void establishSWServerConnection(PAL::SessionID, uint64_t& serverConnectionIdentifier);
    7172    void removeSWServerConnection(uint64_t serverConnectionIdentifier);
    72     HashMap<uint64_t, RefPtr<WebSWServerConnection>> m_webServiceWorkerConnections;
     73    HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers;
     74    HashMap<uint64_t, std::unique_ptr<WebSWServerConnection>> m_swConnections;
    7375#endif
    7476
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r220924 r220977  
    10291029                517A52D81F43A9DA00DCDC0A /* WebSWServerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */; };
    10301030                517A52D91F43A9DA00DCDC0A /* WebSWServerConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */; };
     1031                517A53041F4793C600DCDC0A /* WebSWClientConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */; };
     1032                517A53051F4793C600DCDC0A /* WebSWClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A53021F4793B200DCDC0A /* WebSWClientConnection.h */; };
     1033                517A530A1F479E3600DCDC0A /* WebSWServerConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A53091F479E3100DCDC0A /* WebSWServerConnection.cpp */; };
     1034                517A530B1F479E3600DCDC0A /* WebSWServerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A53071F479E3100DCDC0A /* WebSWServerConnection.h */; };
     1035                517A530F1F47A86200DCDC0A /* WebSWClientConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */; };
     1036                517A53101F47A86200DCDC0A /* WebSWClientConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */; };
    10311037                517CF0E3163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */; };
    10321038                517CF0E3163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp */; };
     
    11111117                51F060E11654318500F3282C /* WebRTCResolverMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */; };
    11121118                51F060E11654318500F3282E /* NetworkRTCProviderMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3282E /* NetworkRTCProviderMessageReceiver.cpp */; };
    1113                 51F645881F472E2E00B54DED /* WebSWServerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F645861F472E2600B54DED /* WebSWServerConnection.h */; };
    1114                 51F645891F472E2E00B54DED /* WebSWServerConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F645871F472E2600B54DED /* WebSWServerConnection.cpp */; };
    11151119                51F7DC41180CC93600212CA3 /* XPCServiceMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC82839616B47EC400A278FE /* XPCServiceMain.mm */; };
    11161120                51F7DC43180CC93600212CA3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC3DE46815A91763008D26FC /* Foundation.framework */; };
     
    33083312                517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnectionMessages.h; sourceTree = "<group>"; };
    33093313                517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWServerConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
     3314                517A53021F4793B200DCDC0A /* WebSWClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWClientConnection.h; sourceTree = "<group>"; };
     3315                517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWClientConnection.cpp; sourceTree = "<group>"; };
     3316                517A53071F479E3100DCDC0A /* WebSWServerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnection.h; sourceTree = "<group>"; };
     3317                517A53081F479E3100DCDC0A /* WebSWServerConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWServerConnection.messages.in; sourceTree = "<group>"; };
     3318                517A53091F479E3100DCDC0A /* WebSWServerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWServerConnection.cpp; sourceTree = "<group>"; };
     3319                517A530C1F479E9700DCDC0A /* WebSWClientConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWClientConnection.messages.in; sourceTree = "<group>"; };
     3320                517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWClientConnectionMessages.h; sourceTree = "<group>"; };
     3321                517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWClientConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
    33103322                517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkProcessConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
    33113323                517CF0E1163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
     
    34163428                51F060DD1654317500F3282E /* NetworkRTCProviderMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCProviderMessageReceiver.cpp; sourceTree = "<group>"; };
    34173429                51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebResourceLoaderMessages.h; sourceTree = "<group>"; };
    3418                 51F645851F472E2600B54DED /* WebSWServerConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWServerConnection.messages.in; sourceTree = "<group>"; };
    3419                 51F645861F472E2600B54DED /* WebSWServerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnection.h; sourceTree = "<group>"; };
    3420                 51F645871F472E2600B54DED /* WebSWServerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWServerConnection.cpp; sourceTree = "<group>"; };
    34213430                51F7DC4A180CC93600212CA3 /* com.apple.WebKit.Storage.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = com.apple.WebKit.Storage.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
    34223431                51F886A31F2C214A00C193EF /* WKTestingSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKTestingSupport.cpp; sourceTree = "<group>"; };
     
    60766085                                51BEB6291F3A5ACD005029B9 /* WebServiceWorkerProvider.cpp */,
    60776086                                51BEB62A1F3A5ACD005029B9 /* WebServiceWorkerProvider.h */,
    6078                                 51F645861F472E2600B54DED /* WebSWServerConnection.h */,
    6079                                 51F645871F472E2600B54DED /* WebSWServerConnection.cpp */,
    6080                                 51F645851F472E2600B54DED /* WebSWServerConnection.messages.in */,
     6087                                517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */,
     6088                                517A53021F4793B200DCDC0A /* WebSWClientConnection.h */,
     6089                                517A530C1F479E9700DCDC0A /* WebSWClientConnection.messages.in */,
    60816090                                5118E9991F295259003EF9F5 /* WebToStorageProcessConnection.cpp */,
    60826091                                5118E99A1F295259003EF9F5 /* WebToStorageProcessConnection.h */,
     
    61976206                        sourceTree = "<group>";
    61986207                };
     6208                517A53061F479E0F00DCDC0A /* ServiceWorker */ = {
     6209                        isa = PBXGroup;
     6210                        children = (
     6211                                517A53091F479E3100DCDC0A /* WebSWServerConnection.cpp */,
     6212                                517A53071F479E3100DCDC0A /* WebSWServerConnection.h */,
     6213                                517A53081F479E3100DCDC0A /* WebSWServerConnection.messages.in */,
     6214                        );
     6215                        path = ServiceWorker;
     6216                        sourceTree = "<group>";
     6217                };
    61996218                517DD5BB180DA7C40081660B /* Storage */ = {
    62006219                        isa = PBXGroup;
     
    62986317                                E1FEF39B190F791C00731658 /* ios */,
    62996318                                517DD5C0180DB7AA0081660B /* mac */,
     6319                                517A53061F479E0F00DCDC0A /* ServiceWorker */,
    63006320                                51E351FA180F5D0B00E53BE9 /* StorageProcess.cpp */,
    63016321                                51E351FB180F5D0B00E53BE9 /* StorageProcess.h */,
     
    80118031                                51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */,
    80128032                                51F060DD1654317500F3281C /* WebRTCSocketMessageReceiver.cpp */,
     8033                                5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */,
     8034                                5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */,
     8035                                517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */,
     8036                                517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */,
    80138037                                517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */,
    80148038                                517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */,
    8015                                 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */,
    8016                                 5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */,
    80178039                                1AAF08B519269E6D00B6390C /* WebUserContentControllerMessageReceiver.cpp */,
    80188040                                1AAF08B619269E6D00B6390C /* WebUserContentControllerMessages.h */,
     
    83568378                                1AC1336C18565C7A00F3EC05 /* APIPageHandle.h in Headers */,
    83578379                                1AFDD3151891B54000153970 /* APIPolicyClient.h in Headers */,
    8358                                 51F645881F472E2E00B54DED /* WebSWServerConnection.h in Headers */,
    83598380                                7CE4D2201A4914CA00C7F152 /* APIProcessPoolConfiguration.h in Headers */,
    83608381                                F634445612A885C8000612D8 /* APISecurityOrigin.h in Headers */,
     
    89058926                                D3B9484911FF4B6500032B39 /* WebSearchPopupMenu.h in Headers */,
    89068927                                51BEB62C1F3A5AD7005029B9 /* WebServiceWorkerProvider.h in Headers */,
    8907                                 517A52D91F43A9DA00DCDC0A /* WebSWServerConnectionMessages.h in Headers */,
    89088928                                1A4832D71A9CDF96008B4DFE /* WebsiteData.h in Headers */,
    89098929                                1A4832D11A9BDC2F008B4DFE /* WebsiteDataRecord.h in Headers */,
     
    89128932                                836034A01ACB34D600626549 /* WebSQLiteDatabaseTracker.h in Headers */,
    89138933                                1A52C0F81A38CDC70016160A /* WebStorageNamespaceProvider.h in Headers */,
     8934                                517A53051F4793C600DCDC0A /* WebSWClientConnection.h in Headers */,
     8935                                517A53101F47A86200DCDC0A /* WebSWClientConnectionMessages.h in Headers */,
     8936                                517A530B1F479E3600DCDC0A /* WebSWServerConnection.h in Headers */,
     8937                                517A52D91F43A9DA00DCDC0A /* WebSWServerConnectionMessages.h in Headers */,
    89148938                                BCC5715B115ADAEF001CCAF9 /* WebSystemInterface.h in Headers */,
    89158939                                5118E99C1F295266003EF9F5 /* WebToStorageProcessConnection.h in Headers */,
     
    1053810562                                D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */,
    1053910563                                51BEB62B1F3A5AD7005029B9 /* WebServiceWorkerProvider.cpp in Sources */,
    10540                                 517A52D81F43A9DA00DCDC0A /* WebSWServerConnectionMessageReceiver.cpp in Sources */,
    1054110564                                1A4832D61A9CDF96008B4DFE /* WebsiteData.cpp in Sources */,
    1054210565                                1A4832D91A9D1FD2008B4DFE /* WebsiteDataRecord.cpp in Sources */,
     
    1054910572                                8360349F1ACB34D600626549 /* WebSQLiteDatabaseTracker.cpp in Sources */,
    1055010573                                1A52C0F71A38CDC70016160A /* WebStorageNamespaceProvider.cpp in Sources */,
     10574                                517A53041F4793C600DCDC0A /* WebSWClientConnection.cpp in Sources */,
     10575                                517A530F1F47A86200DCDC0A /* WebSWClientConnectionMessageReceiver.cpp in Sources */,
     10576                                517A530A1F479E3600DCDC0A /* WebSWServerConnection.cpp in Sources */,
     10577                                517A52D81F43A9DA00DCDC0A /* WebSWServerConnectionMessageReceiver.cpp in Sources */,
    1055110578                                BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */,
    1055210579                                5118E99B1F295266003EF9F5 /* WebToStorageProcessConnection.cpp in Sources */,
     
    1067510702                                370F34A21829BE1E009027C8 /* WKNavigationData.mm in Sources */,
    1067610703                                BCF69FAA1176D1CB00471A52 /* WKNavigationDataRef.cpp in Sources */,
    10677                                 51F645891F472E2E00B54DED /* WebSWServerConnection.cpp in Sources */,
    1067810704                                2D3A65E21A7C3A9300CAC637 /* WKNavigationRef.cpp in Sources */,
    1067910705                                1A1B0EB518A424950038481A /* WKNavigationResponse.mm in Sources */,
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp

    r220974 r220977  
    2525
    2626#include "config.h"
    27 #include "WebServiceWorkerProvider.h"
     27#include "WebSWClientConnection.h"
    2828
    2929#if ENABLE(SERVICE_WORKER)
    3030
    31 #include "WebProcess.h"
    32 #include "WebSWServerConnection.h"
    33 #include "WebToStorageProcessConnection.h"
    34 #include <WebCore/Exception.h>
    35 #include <WebCore/ExceptionCode.h>
    36 #include <WebCore/ServiceWorkerJob.h>
    37 #include <pal/SessionID.h>
    38 #include <wtf/text/WTFString.h>
     31#include "Logging.h"
     32#include "StorageToWebProcessConnectionMessages.h"
     33#include "WebSWServerConnectionMessages.h"
     34#include <WebCore/ServiceWorkerJobData.h>
    3935
    4036using namespace PAL;
     
    4339namespace WebKit {
    4440
    45 WebServiceWorkerProvider& WebServiceWorkerProvider::singleton()
     41WebSWClientConnection::WebSWClientConnection(IPC::Connection& connection, const SessionID& sessionID)
     42    : m_sessionID(sessionID)
     43    , m_connection(connection)
    4644{
    47     static NeverDestroyed<WebServiceWorkerProvider> provider;
    48     return provider;
     45    bool result = sendSync(Messages::StorageToWebProcessConnection::EstablishSWServerConnection(sessionID), Messages::StorageToWebProcessConnection::EstablishSWServerConnection::Reply(m_identifier));
     46
     47    ASSERT_UNUSED(result, result);
    4948}
    5049
    51 WebServiceWorkerProvider::WebServiceWorkerProvider()
     50WebSWClientConnection::~WebSWClientConnection()
    5251{
    5352}
    5453
    55 SWServer::Connection& WebServiceWorkerProvider::serviceWorkerConnectionForSession(const SessionID& sessionID)
     54void WebSWClientConnection::scheduleJobInServer(const ServiceWorkerJobData& jobData)
    5655{
    57     ASSERT(WebProcess::singleton().webToStorageProcessConnection());
    58     return WebProcess::singleton().webToStorageProcessConnection()->serviceWorkerConnectionForSession(sessionID);
     56    send(Messages::WebSWServerConnection::ScheduleJobInServer(jobData));
    5957}
    6058
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h

    r220974 r220977  
    2828#if ENABLE(SERVICE_WORKER)
    2929
     30#include "Connection.h"
    3031#include "MessageReceiver.h"
    3132#include "MessageSender.h"
    32 #include <WebCore/SWServer.h>
     33#include <WebCore/SWClientConnection.h>
    3334#include <pal/SessionID.h>
    3435
     
    3940namespace WebKit {
    4041
    41 class WebSWServerConnection : public WebCore::SWServer::Connection, public IPC::MessageSender, public IPC::MessageReceiver {
     42class WebSWClientConnection : public WebCore::SWClientConnection, public IPC::MessageSender, public IPC::MessageReceiver {
    4243public:
    43     static Ref<WebSWServerConnection> create(const PAL::SessionID& sessionID)
    44     {
    45         return adoptRef(*new WebSWServerConnection(sessionID));
    46     }
    47     static Ref<WebSWServerConnection> create(IPC::Connection& connection, uint64_t connectionIdentifier, const PAL::SessionID& sessionID)
    48     {
    49         return adoptRef(*new WebSWServerConnection(connection, connectionIdentifier, sessionID));
    50     }
    51 
    52     ~WebSWServerConnection() final;
     44    WebSWClientConnection(IPC::Connection&, const PAL::SessionID&);
     45    WebSWClientConnection(const WebSWClientConnection&) = delete;
     46    ~WebSWClientConnection() final;
    5347
    5448    uint64_t identifier() const { return m_identifier; }
    5549
    56     void scheduleJob(const WebCore::ServiceWorkerJobData&) final;
     50    void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
    5751
    5852    void disconnectedFromWebProcess();
     
    6054
    6155private:
    62     WebSWServerConnection(const PAL::SessionID&);
    63     WebSWServerConnection(IPC::Connection&, uint64_t connectionIdentifier, const PAL::SessionID&);
    64 
    6556    void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
    6657
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in

    r220974 r220977  
    2323#if ENABLE(SERVICE_WORKER)
    2424
    25 messages -> WebSWServerConnection {
    26     # Messages targetting the Storage process
    27     ScheduleStorageJob(struct WebCore::ServiceWorkerJobData jobData)
    28 
    29     # Messages targetting the Web process.
    30     # When possible, they can be implemented directly by WebCore::SWServer::Connection
    31     JobRejected(uint64_t identifier, struct WebCore::ExceptionData exception)
     25messages -> WebSWClientConnection {
     26    # When possible, these messages can be implemented directly by WebCore::SWServer::Connection
     27    JobRejectedInServer(uint64_t identifier, struct WebCore::ExceptionData exception)
    3228}
    3329
  • trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp

    r220924 r220977  
    5353}
    5454
    55 SWServer::Connection& WebServiceWorkerProvider::serviceWorkerConnectionForSession(const SessionID& sessionID)
     55WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnectionForSession(const SessionID& sessionID)
    5656{
    5757    ASSERT(WebProcess::singleton().webToStorageProcessConnection());
  • trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h

    r220924 r220977  
    4141    WebServiceWorkerProvider();
    4242
    43     WebCore::SWServer::Connection& serviceWorkerConnectionForSession(const PAL::SessionID&) final;
     43    WebCore::SWClientConnection& serviceWorkerConnectionForSession(const PAL::SessionID&) final;
    4444
    4545}; // class WebServiceWorkerProvider
  • trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp

    r220924 r220977  
    3131#include "WebIDBConnectionToServerMessages.h"
    3232#include "WebProcess.h"
    33 #include "WebSWServerConnection.h"
    34 #include "WebSWServerConnectionMessages.h"
     33#include "WebSWClientConnection.h"
     34#include "WebSWClientConnectionMessages.h"
    3535
    3636using namespace PAL;
     
    6161
    6262#if ENABLE(SERVICE_WORKER)
    63     if (decoder.messageReceiverName() == Messages::WebSWServerConnection::messageReceiverName()) {
    64         auto serviceWorkerConnection = m_serviceWorkerConnectionsByIdentifier.get(decoder.destinationID());
     63    if (decoder.messageReceiverName() == Messages::WebSWClientConnection::messageReceiverName()) {
     64        auto serviceWorkerConnection = m_swConnectionsByIdentifier.get(decoder.destinationID());
    6565        if (serviceWorkerConnection)
    6666            serviceWorkerConnection->didReceiveMessage(connection, decoder);
     
    103103
    104104#if ENABLE(SERVICE_WORKER)
    105 WebSWServerConnection& WebToStorageProcessConnection::serviceWorkerConnectionForSession(const SessionID& sessionID)
     105WebSWClientConnection& WebToStorageProcessConnection::serviceWorkerConnectionForSession(const SessionID& sessionID)
    106106{
    107     auto result = m_serviceWorkerConnectionsBySession.add(sessionID, nullptr);
     107    auto result = m_swConnectionsBySession.add(sessionID, nullptr);
    108108    if (result.isNewEntry) {
    109         result.iterator->value = WebSWServerConnection::create(sessionID);
    110         ASSERT(!m_serviceWorkerConnectionsByIdentifier.contains(result.iterator->value->identifier()));
    111         m_serviceWorkerConnectionsByIdentifier.set(result.iterator->value->identifier(), result.iterator->value);
     109        result.iterator->value = std::make_unique<WebSWClientConnection>(m_connection.get(), sessionID);
     110        ASSERT(!m_swConnectionsByIdentifier.contains(result.iterator->value->identifier()));
     111        m_swConnectionsByIdentifier.set(result.iterator->value->identifier(), result.iterator->value.get());
    112112    }
    113113
  • trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.h

    r220924 r220977  
    3030#include "MessageSender.h"
    3131#include "WebIDBConnectionToServer.h"
     32#include "WebSWClientConnection.h"
     33#include <WebCore/SWServer.h>
    3234#include <pal/SessionID.h>
    3335#include <wtf/RefCounted.h>
     
    3840
    3941namespace WebKit {
    40 
    41 class WebSWServerConnection;
    4242
    4343class WebToStorageProcessConnection : public RefCounted<WebToStorageProcessConnection>, public IPC::Connection::Client, public IPC::MessageSender {
     
    5555#endif
    5656#if ENABLE(SERVICE_WORKER)
    57     WebSWServerConnection& serviceWorkerConnectionForSession(const PAL::SessionID&);
     57    WebSWClientConnection& serviceWorkerConnectionForSession(const PAL::SessionID&);
    5858#endif
    5959
     
    7878
    7979#if ENABLE(SERVICE_WORKER)
    80     HashMap<PAL::SessionID, RefPtr<WebSWServerConnection>> m_serviceWorkerConnectionsBySession;
    81     HashMap<uint64_t, RefPtr<WebSWServerConnection>> m_serviceWorkerConnectionsByIdentifier;
     80    HashMap<PAL::SessionID, std::unique_ptr<WebSWClientConnection>> m_swConnectionsBySession;
     81    HashMap<uint64_t, WebSWClientConnection*> m_swConnectionsByIdentifier;
    8282#endif
    8383};
Note: See TracChangeset for help on using the changeset viewer.