Changeset 239701 in webkit


Ignore:
Timestamp:
Jan 7, 2019, 2:31:41 PM (6 years ago)
Author:
achristensen@apple.com
Message:

Remove use of NetworkProcess::singleton in ServiceWorker code
https://bugs.webkit.org/show_bug.cgi?id=193209

Reviewed by Megan Gardner.

Use a member Ref<NetworkProcess> instead to avoid global singleton use.

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::establishSWServerConnection):

  • NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:

(WebKit::WebSWServerConnection::WebSWServerConnection):
(WebKit::WebSWServerConnection::~WebSWServerConnection):
(WebKit::WebSWServerConnection::startFetch):
(WebKit::WebSWServerConnection::postMessageToServiceWorker):
(WebKit::WebSWServerConnection::scheduleJobInServer):

  • NetworkProcess/ServiceWorker/WebSWServerConnection.h:
Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r239700 r239701  
     12019-01-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        Remove use of NetworkProcess::singleton in ServiceWorker code
     4        https://bugs.webkit.org/show_bug.cgi?id=193209
     5
     6        Reviewed by Megan Gardner.
     7
     8        Use a member Ref<NetworkProcess> instead to avoid global singleton use.
     9
     10        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     11        (WebKit::NetworkConnectionToWebProcess::establishSWServerConnection):
     12        * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
     13        (WebKit::WebSWServerConnection::WebSWServerConnection):
     14        (WebKit::WebSWServerConnection::~WebSWServerConnection):
     15        (WebKit::WebSWServerConnection::startFetch):
     16        (WebKit::WebSWServerConnection::postMessageToServiceWorker):
     17        (WebKit::WebSWServerConnection::scheduleJobInServer):
     18        * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
     19
    1202019-01-07  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r239680 r239701  
    728728{
    729729    auto& server = m_networkProcess->swServerForSession(sessionID);
    730     auto connection = std::make_unique<WebSWServerConnection>(server, m_connection.get(), sessionID);
     730    auto connection = std::make_unique<WebSWServerConnection>(m_networkProcess, server, m_connection.get(), sessionID);
    731731   
    732732    serverConnectionIdentifier = connection->identifier();
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp

    r239534 r239701  
    6161#define SWSERVERCONNECTION_RELEASE_LOG_ERROR_IF_ALLOWED(fmt, ...) RELEASE_LOG_ERROR_IF(m_sessionID.isAlwaysOnLoggingAllowed(), ServiceWorker, "%p - WebSWServerConnection::" fmt, this, ##__VA_ARGS__)
    6262
    63 WebSWServerConnection::WebSWServerConnection(SWServer& server, IPC::Connection& connection, SessionID sessionID)
     63WebSWServerConnection::WebSWServerConnection(NetworkProcess& networkProcess, SWServer& server, IPC::Connection& connection, SessionID sessionID)
    6464    : SWServer::Connection(server)
    6565    , m_sessionID(sessionID)
    6666    , m_contentConnection(connection)
    67 {
    68     NetworkProcess::singleton().registerSWServerConnection(*this);
     67    , m_networkProcess(networkProcess)
     68{
     69    networkProcess.registerSWServerConnection(*this);
    6970}
    7071
    7172WebSWServerConnection::~WebSWServerConnection()
    7273{
    73     NetworkProcess::singleton().unregisterSWServerConnection(*this);
     74    m_networkProcess->unregisterSWServerConnection(*this);
    7475    for (const auto& keyValue : m_clientOrigins)
    7576        server().unregisterServiceWorkerClient(keyValue.value, keyValue.key);
     
    166167
    167168        if (!worker->contextConnection())
    168             NetworkProcess::singleton().createServerToContextConnection(worker->securityOrigin(), server().sessionID());
     169            m_networkProcess->createServerToContextConnection(worker->securityOrigin(), server().sessionID());
    169170
    170171        server().runServiceWorkerIfNecessary(serviceWorkerIdentifier, [weakThis = WTFMove(weakThis), this, fetchIdentifier, serviceWorkerIdentifier, request = WTFMove(request), options = WTFMove(options), formData = WTFMove(formData), referrer = WTFMove(referrer)](auto* contextConnection) {
     
    209210
    210211    if (!destinationWorker->contextConnection())
    211         NetworkProcess::singleton().createServerToContextConnection(destinationWorker->securityOrigin(), server().sessionID());
     212        m_networkProcess->createServerToContextConnection(destinationWorker->securityOrigin(), server().sessionID());
    212213
    213214    // It's possible this specific worker cannot be re-run (e.g. its registration has been removed)
     
    221222{
    222223    auto securityOrigin = SecurityOriginData::fromURL(jobData.scriptURL);
    223     if (!NetworkProcess::singleton().serverToContextConnectionForOrigin(securityOrigin))
    224         NetworkProcess::singleton().createServerToContextConnection(securityOrigin, server().sessionID());
     224    if (!m_networkProcess->serverToContextConnectionForOrigin(securityOrigin))
     225        m_networkProcess->createServerToContextConnection(securityOrigin, server().sessionID());
    225226
    226227    SWSERVERCONNECTION_RELEASE_LOG_IF_ALLOWED("Scheduling ServiceWorker job %s in server", jobData.identifier().loggingString().utf8().data());
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h

    r239534 r239701  
    4949namespace WebKit {
    5050
     51class NetworkProcess;
     52
    5153class WebSWServerConnection : public WebCore::SWServer::Connection, public IPC::MessageSender, public IPC::MessageReceiver {
    5254public:
    53     WebSWServerConnection(WebCore::SWServer&, IPC::Connection&, PAL::SessionID);
     55    WebSWServerConnection(NetworkProcess&, WebCore::SWServer&, IPC::Connection&, PAL::SessionID);
    5456    WebSWServerConnection(const WebSWServerConnection&) = delete;
    5557    ~WebSWServerConnection() final;
     
    104106    PAL::SessionID m_sessionID;
    105107    Ref<IPC::Connection> m_contentConnection;
     108    Ref<NetworkProcess> m_networkProcess;
    106109    HashMap<WebCore::ServiceWorkerClientIdentifier, WebCore::ClientOrigin> m_clientOrigins;
    107110};
Note: See TracChangeset for help on using the changeset viewer.