Changeset 224295 in webkit


Ignore:
Timestamp:
Nov 1, 2017 2:23:52 PM (6 years ago)
Author:
beidson@apple.com
Message:

Plumbing for handling SW scripts failing to evaluate
https://bugs.webkit.org/show_bug.cgi?id=178926

Reviewed by Chris Dumez.

Source/WebCore:

No new tests (Currently no observable behavior change).

In an upcoming patch we'll actually run the appropriate observable steps for when
a ServiceWorker script fails to evaluate.

This is a standalone refactoring + plumbing patch that will make the observable changes
easier to review.

  • bindings/js/WorkerScriptController.cpp:

(WebCore::WorkerScriptController::evaluate):

  • bindings/js/WorkerScriptController.h:

(WebCore::WorkerScriptController::workerGlobalScopeWrapper):
(WebCore::WorkerScriptController::vm):
(WebCore::WorkerScriptController::initScriptIfNeeded):

  • workers/WorkerMessagingProxy.cpp:

(WebCore::WorkerMessagingProxy::startWorkerGlobalScope):

  • workers/WorkerThread.cpp:

(WebCore::WorkerThread::start):
(WebCore::WorkerThread::workerThread):

  • workers/WorkerThread.h:
  • workers/service/context/SWContextManager.cpp:

(WebCore::SWContextManager::registerServiceWorkerThreadForUpdate):
(WebCore::SWContextManager::registerServiceWorkerThread): Deleted.

  • workers/service/context/SWContextManager.h:
  • workers/service/context/ServiceWorkerThread.h:

(WebCore::ServiceWorkerThread::serverConnectionIdentifier const):
(WebCore::ServiceWorkerThread::contextData const):

  • workers/service/context/ServiceWorkerThreadProxy.cpp:

(WebCore::ServiceWorkerThreadProxy::create):
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):

  • workers/service/server/SWServer.cpp:

(WebCore::SWServer::updateWorker):
(WebCore::SWServer::createWorker): Deleted.

  • workers/service/server/SWServer.h:
  • workers/service/server/SWServerRegistration.cpp:

(WebCore::SWServerRegistration::scriptFetchFinished):
(WebCore::SWServerRegistration::scriptContextFailedToStart):

Source/WebKit:

  • StorageProcess/ServiceWorker/WebSWServerConnection.cpp:

(WebKit::WebSWServerConnection::updateServiceWorkerContext):
(WebKit::WebSWServerConnection::setContextConnection):
(WebKit::WebSWServerConnection::startServiceWorkerContext): Deleted.

  • StorageProcess/ServiceWorker/WebSWServerConnection.h:
  • WebProcess/Storage/WebSWContextManagerConnection.cpp:

(WebKit::WebSWContextManagerConnection::updateServiceWorker):
(WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage):
(WebKit::WebSWContextManagerConnection::startServiceWorker): Deleted.

  • WebProcess/Storage/WebSWContextManagerConnection.h:
  • WebProcess/Storage/WebSWContextManagerConnection.messages.in:
Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224290 r224295  
     12017-11-01  Brady Eidson  <beidson@apple.com>
     2
     3        Plumbing for handling SW scripts failing to evaluate
     4        https://bugs.webkit.org/show_bug.cgi?id=178926
     5
     6        Reviewed by Chris Dumez.
     7
     8        No new tests (Currently no observable behavior change).
     9
     10        In an upcoming patch we'll actually run the appropriate observable steps for when
     11        a ServiceWorker script fails to evaluate.
     12
     13        This is a standalone refactoring + plumbing patch that will make the observable changes
     14        easier to review.
     15
     16        * bindings/js/WorkerScriptController.cpp:
     17        (WebCore::WorkerScriptController::evaluate):
     18        * bindings/js/WorkerScriptController.h:
     19        (WebCore::WorkerScriptController::workerGlobalScopeWrapper):
     20        (WebCore::WorkerScriptController::vm):
     21        (WebCore::WorkerScriptController::initScriptIfNeeded):
     22
     23        * workers/WorkerMessagingProxy.cpp:
     24        (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
     25
     26        * workers/WorkerThread.cpp:
     27        (WebCore::WorkerThread::start):
     28        (WebCore::WorkerThread::workerThread):
     29        * workers/WorkerThread.h:
     30
     31        * workers/service/context/SWContextManager.cpp:
     32        (WebCore::SWContextManager::registerServiceWorkerThreadForUpdate):
     33        (WebCore::SWContextManager::registerServiceWorkerThread): Deleted.
     34        * workers/service/context/SWContextManager.h:
     35
     36        * workers/service/context/ServiceWorkerThread.h:
     37        (WebCore::ServiceWorkerThread::serverConnectionIdentifier const):
     38        (WebCore::ServiceWorkerThread::contextData const):
     39
     40        * workers/service/context/ServiceWorkerThreadProxy.cpp:
     41        (WebCore::ServiceWorkerThreadProxy::create):
     42        (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
     43
     44        * workers/service/server/SWServer.cpp:
     45        (WebCore::SWServer::updateWorker):
     46        (WebCore::SWServer::createWorker): Deleted.
     47        * workers/service/server/SWServer.h:
     48
     49        * workers/service/server/SWServerRegistration.cpp:
     50        (WebCore::SWServerRegistration::scriptFetchFinished):
     51        (WebCore::SWServerRegistration::scriptContextFailedToStart):
     52
    1532017-11-01  Ryosuke Niwa  <rniwa@webkit.org>
    254
  • trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp

    r223746 r224295  
    121121}
    122122
    123 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
     123void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, String* returnedExceptionMessage)
    124124{
    125125    if (isExecutionForbidden())
     
    127127
    128128    NakedPtr<JSC::Exception> exception;
    129     evaluate(sourceCode, exception);
     129    evaluate(sourceCode, exception, returnedExceptionMessage);
    130130    if (exception) {
    131131        JSLockHolder lock(vm());
     
    134134}
    135135
    136 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, NakedPtr<JSC::Exception>& returnedException)
     136void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, NakedPtr<JSC::Exception>& returnedException, String* returnedExceptionMessage)
    137137{
    138138    if (isExecutionForbidden())
     
    158158        String sourceURL = sourceCode.url().string();
    159159        JSC::Strong<JSC::Unknown> error;
    160         if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, error, sourceCode.cachedScript()))
     160        if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, error, sourceCode.cachedScript())) {
     161            if (returnedExceptionMessage)
     162                *returnedExceptionMessage = errorMessage;
    161163            returnedException = JSC::Exception::create(vm, createError(exec, errorMessage.impl()));
     164        }
    162165    }
    163166}
  • trunk/Source/WebCore/bindings/js/WorkerScriptController.h

    r218951 r224295  
    4040namespace WebCore {
    4141
    42     class JSWorkerGlobalScope;
    43     class ScriptSourceCode;
    44     class WorkerConsoleClient;
    45     class WorkerGlobalScope;
     42class JSWorkerGlobalScope;
     43class ScriptSourceCode;
     44class WorkerConsoleClient;
     45class WorkerGlobalScope;
    4646
    47     class WorkerScriptController {
    48         WTF_MAKE_NONCOPYABLE(WorkerScriptController); WTF_MAKE_FAST_ALLOCATED;
    49     public:
    50         WorkerScriptController(WorkerGlobalScope*);
    51         ~WorkerScriptController();
     47class WorkerScriptController {
     48    WTF_MAKE_NONCOPYABLE(WorkerScriptController); WTF_MAKE_FAST_ALLOCATED;
     49public:
     50    WorkerScriptController(WorkerGlobalScope*);
     51    ~WorkerScriptController();
    5252
    53         JSWorkerGlobalScope* workerGlobalScopeWrapper()
    54         {
    55             initScriptIfNeeded();
    56             return m_workerGlobalScopeWrapper.get();
    57         }
     53    JSWorkerGlobalScope* workerGlobalScopeWrapper()
     54    {
     55        initScriptIfNeeded();
     56        return m_workerGlobalScopeWrapper.get();
     57    }
    5858
    59         void evaluate(const ScriptSourceCode&);
    60         void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException);
     59    void evaluate(const ScriptSourceCode&, String* returnedExceptionMessage = nullptr);
     60    void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException, String* returnedExceptionMessage = nullptr);
    6161
    62         void setException(JSC::Exception*);
     62    void setException(JSC::Exception*);
    6363
    64         // Async request to terminate a JS run execution. Eventually causes termination
    65         // exception raised during JS execution, if the worker thread happens to run JS.
    66         // After JS execution was terminated in this way, the Worker thread has to use
    67         // forbidExecution()/isExecutionForbidden() to guard against reentry into JS.
    68         // Can be called from any thread.
    69         void scheduleExecutionTermination();
    70         bool isTerminatingExecution() const;
     64    // Async request to terminate a JS run execution. Eventually causes termination
     65    // exception raised during JS execution, if the worker thread happens to run JS.
     66    // After JS execution was terminated in this way, the Worker thread has to use
     67    // forbidExecution()/isExecutionForbidden() to guard against reentry into JS.
     68    // Can be called from any thread.
     69    void scheduleExecutionTermination();
     70    bool isTerminatingExecution() const;
    7171
    72         // Called on Worker thread when JS exits with termination exception caused by forbidExecution() request,
    73         // or by Worker thread termination code to prevent future entry into JS.
    74         void forbidExecution();
    75         bool isExecutionForbidden() const;
     72    // Called on Worker thread when JS exits with termination exception caused by forbidExecution() request,
     73    // or by Worker thread termination code to prevent future entry into JS.
     74    void forbidExecution();
     75    bool isExecutionForbidden() const;
    7676
    77         void disableEval(const String& errorMessage);
    78         void disableWebAssembly(const String& errorMessage);
     77    void disableEval(const String& errorMessage);
     78    void disableWebAssembly(const String& errorMessage);
    7979
    80         JSC::VM& vm() { return *m_vm; }
    81        
    82         void releaseHeapAccess();
    83         void acquireHeapAccess();
     80    JSC::VM& vm() { return *m_vm; }
     81   
     82    void releaseHeapAccess();
     83    void acquireHeapAccess();
    8484
    85         void addTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback);
    86         void removeTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback);
     85    void addTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback);
     86    void removeTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback);
    8787
    88         void attachDebugger(JSC::Debugger*);
    89         void detachDebugger(JSC::Debugger*);
     88    void attachDebugger(JSC::Debugger*);
     89    void detachDebugger(JSC::Debugger*);
    9090
    91     private:
    92         void initScriptIfNeeded()
    93         {
    94             if (!m_workerGlobalScopeWrapper)
    95                 initScript();
    96         }
    97         void initScript();
     91private:
     92    void initScriptIfNeeded()
     93    {
     94        if (!m_workerGlobalScopeWrapper)
     95            initScript();
     96    }
     97    void initScript();
    9898
    99         RefPtr<JSC::VM> m_vm;
    100         WorkerGlobalScope* m_workerGlobalScope;
    101         JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
    102         std::unique_ptr<WorkerConsoleClient> m_consoleClient;
    103         bool m_executionForbidden { false };
    104         bool m_isTerminatingExecution { false };
    105         mutable Lock m_scheduledTerminationMutex;
    106     };
     99    RefPtr<JSC::VM> m_vm;
     100    WorkerGlobalScope* m_workerGlobalScope;
     101    JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
     102    std::unique_ptr<WorkerConsoleClient> m_consoleClient;
     103    bool m_executionForbidden { false };
     104    bool m_isTerminatingExecution { false };
     105    mutable Lock m_scheduledTerminationMutex;
     106};
    107107
    108108} // namespace WebCore
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp

    r224147 r224295  
    9292
    9393    workerThreadCreated(thread.get());
    94     thread->start();
     94    thread->start(nullptr);
    9595
    9696    m_inspectorProxy->workerStarted(m_scriptExecutionContext.get(), thread.ptr(), scriptURL);
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r224147 r224295  
    129129}
    130130
    131 bool WorkerThread::start()
     131bool WorkerThread::start(WTF::Function<void(const String&)>&& evaluateCallback)
    132132{
    133133    // Mutex protection is necessary to ensure that m_thread is initialized when the thread starts.
     
    136136    if (m_thread)
    137137        return true;
     138
     139    m_evaluateCallback = WTFMove(evaluateCallback);
    138140
    139141    m_thread = Thread::create("WebCore: Worker", [this] {
     
    182184    }
    183185
    184     scriptController->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData->m_scriptURL));
     186    String exceptionMessage;
     187    scriptController->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData->m_scriptURL), &exceptionMessage);
     188   
     189    RunLoop::main().dispatch([evaluateCallback = WTFMove(m_evaluateCallback), message = exceptionMessage.isolatedCopy()] {
     190        if (evaluateCallback)
     191            evaluateCallback(message);
     192    });
     193   
    185194    // Free the startup data to cause its member variable deref's happen on the worker's thread (since
    186195    // all ref/derefs of these objects are happening on the thread at this point). Note that
  • trunk/Source/WebCore/workers/WorkerThread.h

    r224147 r224295  
    3030#include <runtime/RuntimeFlags.h>
    3131#include <wtf/Forward.h>
     32#include <wtf/Function.h>
    3233#include <wtf/RefCounted.h>
    3334
     
    6364    virtual ~WorkerThread();
    6465
    65     WEBCORE_EXPORT bool start();
     66    WEBCORE_EXPORT bool start(WTF::Function<void(const String&)>&& evaluateCallback);
    6667    void stop();
    6768
     
    115116
    116117    std::unique_ptr<WorkerThreadStartupData> m_startupData;
     118   
     119    WTF::Function<void(const String&)> m_evaluateCallback;
    117120
    118121#if ENABLE(NOTIFICATIONS)
  • trunk/Source/WebCore/workers/service/context/SWContextManager.cpp

    r224113 r224295  
    4848}
    4949
    50 void SWContextManager::registerServiceWorkerThread(Ref<ServiceWorkerThreadProxy>&& serviceWorkerThreadProxy)
     50void SWContextManager::registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThreadProxy>&& serviceWorkerThreadProxy)
    5151{
    5252    auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier();
     53    auto* threadProxy = serviceWorkerThreadProxy.ptr();
    5354    auto result = m_workerMap.add(serviceWorkerIdentifier, WTFMove(serviceWorkerThreadProxy));
    5455    ASSERT_UNUSED(result, result.isNewEntry);
     56   
     57    threadProxy->thread().start([serviceWorkerIdentifier](const String& exceptionMessage) {
     58        SWContextManager::singleton().connection()->serviceWorkerStartedWithMessage(serviceWorkerIdentifier, exceptionMessage);
     59    });
    5560}
    5661
  • trunk/Source/WebCore/workers/service/context/SWContextManager.h

    r224113 r224295  
    4646
    4747        virtual void postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) = 0;
     48        virtual void serviceWorkerStartedWithMessage(uint64_t serviceWorkerIdentifier, const String& exceptionMessage) = 0;
    4849    };
    4950
     
    5152    WEBCORE_EXPORT Connection* connection() const;
    5253
    53     WEBCORE_EXPORT void registerServiceWorkerThread(Ref<ServiceWorkerThreadProxy>&&);
     54    WEBCORE_EXPORT void registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThreadProxy>&&);
    5455    WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(uint64_t) const;
    5556    WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
  • trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h

    r224147 r224295  
    5858    WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
    5959
     60    uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; }
     61    const ServiceWorkerContextData& contextData() const { return m_data; }
     62
    6063protected:
    6164    Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final;
  • trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp

    r224147 r224295  
    3939Ref<ServiceWorkerThreadProxy> ServiceWorkerThreadProxy::create(PageConfiguration&& pageConfiguration, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, PAL::SessionID sessionID, CacheStorageProvider& cacheStorageProvider)
    4040{
    41     auto serviceWorker = adoptRef(*new ServiceWorkerThreadProxy { WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, cacheStorageProvider });
    42     serviceWorker->m_serviceWorkerThread->start();
    43     return serviceWorker;
     41    return adoptRef(*new ServiceWorkerThreadProxy { WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, cacheStorageProvider });
    4442}
    4543
     
    6260    , m_sessionID(sessionID)
    6361{
    64     m_serviceWorkerThread->start();
    6562}
    6663
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r223964 r224295  
    180180}
    181181
    182 Ref<SWServerWorker> SWServer::createWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
     182Ref<SWServerWorker> SWServer::updateWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
    183183{
    184184    String workerID = createCanonicalUUIDString();
     
    187187    ASSERT(result.isNewEntry);
    188188   
    189     connection.startServiceWorkerContext({ registrationKey, workerID, script, url });
     189    connection.updateServiceWorkerContext({ registrationKey, workerID, script, url });
    190190   
    191191    return result.iterator->value.get();
  • trunk/Source/WebCore/workers/service/server/SWServer.h

    r223964 r224295  
    7373
    7474        // Messages to the SW host WebProcess
    75         virtual void startServiceWorkerContext(const ServiceWorkerContextData&) = 0;
     75        virtual void updateServiceWorkerContext(const ServiceWorkerContextData&) = 0;
    7676
    7777        SWServer& m_server;
     
    9090    void postTaskReply(CrossThreadTask&&);
    9191
    92     Ref<SWServerWorker> createWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);
     92    Ref<SWServerWorker> updateWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);
    9393   
    9494private:
  • trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp

    r224218 r224295  
    8585
    8686    // FIXME: Support the proper worker type (classic vs module)
    87     m_server.createWorker(connection, m_registrationKey, m_currentJob->scriptURL, result.script, WorkerType::Classic);
     87    m_server.updateWorker(connection, m_registrationKey, m_currentJob->scriptURL, result.script, WorkerType::Classic);
    8888}
    8989
    9090void SWServerRegistration::scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message)
    9191{
     92    // FIXME: Install has failed. Run the install failed substeps
     93    // Run the Update Worker State algorithm passing registration’s installing worker and redundant as the arguments.
     94    // Run the Update Registration State algorithm passing registration, "installing" and null as the arguments.
     95    // If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
     96
    9297    UNUSED_PARAM(workerID);
    93 
    94     rejectCurrentJob(ExceptionData { UnknownError, message });
     98    UNUSED_PARAM(message);
    9599}
    96100
  • trunk/Source/WebKit/ChangeLog

    r224284 r224295  
     12017-11-01  Brady Eidson  <beidson@apple.com>
     2
     3        Plumbing for handling SW scripts failing to evaluate
     4        https://bugs.webkit.org/show_bug.cgi?id=178926
     5
     6        Reviewed by Chris Dumez.
     7
     8        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
     9        (WebKit::WebSWServerConnection::updateServiceWorkerContext):
     10        (WebKit::WebSWServerConnection::setContextConnection):
     11        (WebKit::WebSWServerConnection::startServiceWorkerContext): Deleted.
     12        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
     13
     14        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
     15        (WebKit::WebSWContextManagerConnection::updateServiceWorker):
     16        (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage):
     17        (WebKit::WebSWContextManagerConnection::startServiceWorker): Deleted.
     18        * WebProcess/Storage/WebSWContextManagerConnection.h:
     19        * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
     20
    1212017-11-01  Frederic Wang  <fwang@igalia.com>
    222
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp

    r224113 r224295  
    9797}
    9898
    99 void WebSWServerConnection::startServiceWorkerContext(const ServiceWorkerContextData& data)
     99void WebSWServerConnection::updateServiceWorkerContext(const ServiceWorkerContextData& data)
    100100{
    101     if (sendToContextProcess(Messages::WebSWContextManagerConnection::StartServiceWorker(identifier(), data)))
     101    if (sendToContextProcess(Messages::WebSWContextManagerConnection::UpdateServiceWorker(identifier(), data)))
    102102        return;
    103103
     
    158158    m_contextConnection = connection;
    159159
    160     // We can now start any pending service worker contexts.
     160    // We can now start any pending service worker updates.
    161161    for (auto& pendingContextData : m_pendingContextDatas)
    162         startServiceWorkerContext(pendingContextData);
     162        updateServiceWorkerContext(pendingContextData);
    163163   
    164164    m_pendingContextDatas.clear();
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h

    r224113 r224295  
    7272
    7373    // Messages to the SW context WebProcess
    74     void startServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
     74    void updateServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
    7575
    7676    IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp

    r224153 r224295  
    9696}
    9797
    98 void WebSWContextManagerConnection::startServiceWorker(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
     98void WebSWContextManagerConnection::updateServiceWorker(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
    9999{
    100100    // FIXME: Provide a sensical session ID.
     
    108108    };
    109109    fillWithEmptyClients(pageConfiguration);
     110
     111    // FIXME: This method should be moved directly to WebCore::SWContextManager::Connection
     112    // If it weren't for ServiceWorkerFrameLoaderClient's dependence on WebDocumentLoader, this could already happen.
    110113    auto frameLoaderClient = std::make_unique<ServiceWorkerFrameLoaderClient>(sessionID, m_pageID, ++m_previousServiceWorkerID);
    111114    pageConfiguration.loaderClientForMainFrame = frameLoaderClient.release();
    112115
    113116    auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, WebProcess::singleton().cacheStorageProvider());
    114     auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier();
    115     SWContextManager::singleton().registerServiceWorkerThread(WTFMove(serviceWorkerThreadProxy));
     117    SWContextManager::singleton().registerServiceWorkerThreadForUpdate(WTFMove(serviceWorkerThreadProxy));
    116118
    117     LOG(ServiceWorker, "Context process PID: %i started worker thread %s\n", getpid(), data.workerID.utf8().data());
     119    LOG(ServiceWorker, "Context process PID: %i created worker thread %s\n", getpid(), data.workerID.utf8().data());
     120}
    118121
    119     m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextStarted(serverConnectionIdentifier, data.registrationKey, serviceWorkerIdentifier, data.workerID), 0);
     122void WebSWContextManagerConnection::serviceWorkerStartedWithMessage(uint64_t serviceWorkerIdentifier, const String& exceptionMessage)
     123{
     124    auto* threadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
     125    ASSERT(threadProxy);
     126   
     127    auto& data = threadProxy->thread().contextData();
     128   
     129    if (exceptionMessage.isEmpty())
     130        m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextStarted(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier, data.workerID), 0);
     131    else
     132        m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, data.workerID, exceptionMessage), 0);
    120133}
    121134
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h

    r224113 r224295  
    5555
    5656    // IPC messages.
    57     void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
     57    void serviceWorkerStartedWithMessage(uint64_t serviceWorkerIdentifier, const String& exceptionMessage) final;
     58    void updateServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
    5859    void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
    5960    void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, const WebCore::ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in

    r224113 r224295  
    2424
    2525messages -> WebSWContextManagerConnection {
    26     StartServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
     26    UpdateServiceWorker(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)
    2828    PostMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, String sourceOrigin)
Note: See TracChangeset for help on using the changeset viewer.