Changeset 138693 in webkit


Ignore:
Timestamp:
Jan 2, 2013 7:22:30 PM (10 years ago)
Author:
[email protected]
Message:

[chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
https://bugs.webkit.org/show_bug.cgi?id=105367

Reviewed by Dmitry Titov.

Source/WebCore:

Eliminated a Chromium-specific object wrapping WorkerMessagingProxy in order to fix a
lifetime management bug, which leaked every Document which started a dedicated worker.

Test: fast/workers/worker-document-leak.html

  • workers/WorkerLoaderProxy.h:

(WorkerLoaderProxy):

Added Chromium-specific casting method to bridge two now-distinct class hierarchies.

  • workers/WorkerMessagingProxy.h:

(WorkerMessagingProxy):

Made destructor protected instead of private to allow subclassing.

Source/WebKit/chromium:

Made WebWorkerClientImpl a subclass of WorkerMessagingProxy rather than an object wrapping
WorkerMessagingProxy. WorkerMessagingProxy manages its own lifetime and it is impossible to
properly synchronize the lifetime of WebWorkerClientImpl separately.

This allowed most of WebWorkerClientImpl to be deleted, but forced a divergence in the class
hierarchies of WebWorkerClientImpl and WebSharedWorkerImpl. Conversion methods were added to
WorkerLoaderProxy and WebWorkerBase to bridge the hierarchies of in-process and
out-of-process workers.

  • src/DatabaseObserver.cpp:

(WebCore::DatabaseObserver::canEstablishDatabase):

Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.

  • src/IDBFactoryBackendProxy.cpp:

(WebKit::AllowIndexedDBMainThreadBridge::signalCompleted):

Adjusted how WorkerLoaderProxy's methods are called.

(WebKit::IDBFactoryBackendProxy::allowIndexedDB):

Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.

  • src/LocalFileSystemChromium.cpp:

(WebCore::openFileSystemHelper):

Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.

  • src/WebSharedWorkerImpl.cpp:

(WebKit::WebSharedWorkerImpl::toWebWorkerBase):

Implemented new conversion method.

  • src/WebSharedWorkerImpl.h:

(WebSharedWorkerImpl):

Explicitly derive from WorkerLoaderProxy now that WebWorkerBase no longer does.

(WebKit::WebSharedWorkerImpl::workerLoaderProxy):

Added new conversion method.

  • src/WebWorkerBase.h:

(WebWorkerBase):

Removed derivation from WorkerLoaderProxy. Added method to convert to WorkerLoaderProxy.

  • src/WebWorkerClientImpl.cpp:

(WebKit):

Adjusted comment.

(WebKit::WebWorkerClientImpl::createWorkerContextProxy):

Adjusted whitespace.

(WebKit::WebWorkerClientImpl::terminateWorkerContext):

Eliminated delegation to separate object.

(WebKit::WebWorkerClientImpl::toWebWorkerBase):

Implemented new conversion method.

(WebKit::WebWorkerClientImpl::view):
(WebKit::WebWorkerClientImpl::allowDatabase):
(WebKit::WebWorkerClientImpl::allowFileSystem):
(WebKit::WebWorkerClientImpl::openFileSystem):
(WebKit::WebWorkerClientImpl::allowIndexedDB):

Eliminated delegation to separate object.

(WebKit::WebWorkerClientImpl::WebWorkerClientImpl):

  • src/WebWorkerClientImpl.h:

(WebKit):

Changed to inherit from WorkerMessagingProxy directly.

(WebWorkerClientImpl):

Deleted most methods previously overridden from WorkerContextProxy, etc.

  • src/WorkerAsyncFileSystemChromium.cpp:

(WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
(WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge):

Hold on to, and use, WorkerLoaderProxy rather than WebWorkerBase.

  • src/WorkerAsyncFileSystemChromium.h:

(WebKit):
(WebCore):
(WorkerAsyncFileSystemChromium):

Hold on to WorkerLoaderProxy rather than WebWorkerBase.

LayoutTests:

  • fast/workers/resources/empty-worker.js: Added.
  • fast/workers/resources/worker-document-leak-iframe.html: Added.
  • fast/workers/worker-document-leak-expected.txt: Added.
  • fast/workers/worker-document-leak.html: Added.
Location:
trunk
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138692 r138693  
     12013-01-02  Kenneth Russell  <[email protected]>
     2
     3        [chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=105367
     5
     6        Reviewed by Dmitry Titov.
     7
     8        * fast/workers/resources/empty-worker.js: Added.
     9        * fast/workers/resources/worker-document-leak-iframe.html: Added.
     10        * fast/workers/worker-document-leak-expected.txt: Added.
     11        * fast/workers/worker-document-leak.html: Added.
     12
    1132013-01-02  Ryosuke Niwa  <[email protected]>
    214
  • trunk/Source/WebCore/ChangeLog

    r138691 r138693  
     12013-01-02  Kenneth Russell  <[email protected]>
     2
     3        [chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=105367
     5
     6        Reviewed by Dmitry Titov.
     7
     8        Eliminated a Chromium-specific object wrapping WorkerMessagingProxy in order to fix a
     9        lifetime management bug, which leaked every Document which started a dedicated worker.
     10
     11        Test: fast/workers/worker-document-leak.html
     12
     13        * workers/WorkerLoaderProxy.h:
     14        (WorkerLoaderProxy):
     15            Added Chromium-specific casting method to bridge two now-distinct class hierarchies.
     16        * workers/WorkerMessagingProxy.h:
     17        (WorkerMessagingProxy):
     18            Made destructor protected instead of private to allow subclassing.
     19
    1202013-01-02  Elliott Sprehn  <[email protected]>
    221
  • trunk/Source/WebCore/workers/WorkerLoaderProxy.h

    r113138 r138693  
    3838#include <wtf/PassOwnPtr.h>
    3939
     40#if PLATFORM(CHROMIUM)
     41namespace WebKit {
     42class WebWorkerBase;
     43}
     44#endif // PLATFORM(CHROMIUM)
     45
    4046namespace WebCore {
    4147
     
    5662        // Returns true if the task was posted successfully.
    5763        virtual bool postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutionContext::Task>, const String& mode) = 0;
     64
     65#if PLATFORM(CHROMIUM)
     66        // Spans divergent class hierarchies for dedicated and shared workers.
     67        virtual WebKit::WebWorkerBase* toWebWorkerBase() = 0;
     68#endif
    5869    };
    5970
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.h

    r137318 r138693  
    9090        bool askedToTerminate() const { return m_askedToTerminate; }
    9191
     92    protected:
     93        virtual ~WorkerMessagingProxy();
     94
    9295    private:
    9396        friend class MessageWorkerTask;
     
    9699        friend class WorkerExceptionTask;
    97100        friend class WorkerThreadActivityReportTask;
    98 
    99         virtual ~WorkerMessagingProxy();
    100101
    101102        void workerContextDestroyedInternal();
  • trunk/Source/WebKit/chromium/ChangeLog

    r138690 r138693  
     12013-01-02  Kenneth Russell  <[email protected]>
     2
     3        [chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=105367
     5
     6        Reviewed by Dmitry Titov.
     7
     8        Made WebWorkerClientImpl a subclass of WorkerMessagingProxy rather than an object wrapping
     9        WorkerMessagingProxy. WorkerMessagingProxy manages its own lifetime and it is impossible to
     10        properly synchronize the lifetime of WebWorkerClientImpl separately.
     11
     12        This allowed most of WebWorkerClientImpl to be deleted, but forced a divergence in the class
     13        hierarchies of WebWorkerClientImpl and WebSharedWorkerImpl. Conversion methods were added to
     14        WorkerLoaderProxy and WebWorkerBase to bridge the hierarchies of in-process and
     15        out-of-process workers.
     16
     17        * src/DatabaseObserver.cpp:
     18        (WebCore::DatabaseObserver::canEstablishDatabase):
     19            Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
     20        * src/IDBFactoryBackendProxy.cpp:
     21        (WebKit::AllowIndexedDBMainThreadBridge::signalCompleted):
     22            Adjusted how WorkerLoaderProxy's methods are called.
     23        (WebKit::IDBFactoryBackendProxy::allowIndexedDB):
     24            Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
     25        * src/LocalFileSystemChromium.cpp:
     26        (WebCore::openFileSystemHelper):
     27            Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
     28        * src/WebSharedWorkerImpl.cpp:
     29        (WebKit::WebSharedWorkerImpl::toWebWorkerBase):
     30            Implemented new conversion method.
     31        * src/WebSharedWorkerImpl.h:
     32        (WebSharedWorkerImpl):
     33            Explicitly derive from WorkerLoaderProxy now that WebWorkerBase no longer does.
     34        (WebKit::WebSharedWorkerImpl::workerLoaderProxy):
     35            Added new conversion method.
     36        * src/WebWorkerBase.h:
     37        (WebWorkerBase):
     38            Removed derivation from WorkerLoaderProxy. Added method to convert to WorkerLoaderProxy.
     39        * src/WebWorkerClientImpl.cpp:
     40        (WebKit):
     41            Adjusted comment.
     42        (WebKit::WebWorkerClientImpl::createWorkerContextProxy):
     43            Adjusted whitespace.
     44        (WebKit::WebWorkerClientImpl::terminateWorkerContext):
     45            Eliminated delegation to separate object.
     46        (WebKit::WebWorkerClientImpl::toWebWorkerBase):
     47            Implemented new conversion method.
     48        (WebKit::WebWorkerClientImpl::view):
     49        (WebKit::WebWorkerClientImpl::allowDatabase):
     50        (WebKit::WebWorkerClientImpl::allowFileSystem):
     51        (WebKit::WebWorkerClientImpl::openFileSystem):
     52        (WebKit::WebWorkerClientImpl::allowIndexedDB):
     53            Eliminated delegation to separate object.
     54        (WebKit::WebWorkerClientImpl::WebWorkerClientImpl):
     55        * src/WebWorkerClientImpl.h:
     56        (WebKit):
     57            Changed to inherit from WorkerMessagingProxy directly.
     58        (WebWorkerClientImpl):
     59            Deleted most methods previously overridden from WorkerContextProxy, etc.
     60        * src/WorkerAsyncFileSystemChromium.cpp:
     61        (WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
     62        (WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge):
     63            Hold on to, and use, WorkerLoaderProxy rather than WebWorkerBase.
     64        * src/WorkerAsyncFileSystemChromium.h:
     65        (WebKit):
     66        (WebCore):
     67        (WorkerAsyncFileSystemChromium):
     68            Hold on to WorkerLoaderProxy rather than WebWorkerBase.
     69
    1702013-01-02  James Robinson  <[email protected]>
    271
  • trunk/Source/WebKit/chromium/src/DatabaseObserver.cpp

    r113204 r138693  
    165165#if ENABLE(WORKERS)
    166166        WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
    167         WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
    168         WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
     167        WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerContext->thread()->workerLoaderProxy().toWebWorkerBase());
    169168        WebView* view = webWorker->view();
    170169        if (!view)
  • trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp

    r138221 r138693  
    112112        MutexLocker locker(m_mutex);
    113113        if (m_webWorkerBase)
    114             m_webWorkerBase->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode);
     114            m_webWorkerBase->workerLoaderProxy()->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode);
    115115    }
    116116
     
    173173    } else {
    174174        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
    175         WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(&workerContext->thread()->workerLoaderProxy());
     175        WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(workerContext->thread()->workerLoaderProxy().toWebWorkerBase());
    176176        WorkerRunLoop& runLoop = workerContext->thread()->runLoop();
    177177
  • trunk/Source/WebKit/chromium/src/LocalFileSystemChromium.cpp

    r127757 r138693  
    204204#if ENABLE(WORKERS)
    205205        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
    206         WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
    207         WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
     206        WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerContext->thread()->workerLoaderProxy().toWebWorkerBase());
    208207        if (!allowFileSystemForWorker(webWorker->commonClient()))
    209208            allowed = false;
  • trunk/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp

    r137318 r138693  
    325325}
    326326
     327WebWorkerBase* WebSharedWorkerImpl::toWebWorkerBase()
     328{
     329    return this;
     330}
    327331
    328332
  • trunk/Source/WebKit/chromium/src/WebSharedWorkerImpl.h

    r137318 r138693  
    6262// When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingProxy, this class will
    6363// convert to Chrome data types first and then call the supplied WebCommonWorkerClient.
    64 class WebSharedWorkerImpl : public WebCore::WorkerObjectProxy
    65                           , public WebWorkerBase
    66                           , public WebFrameClient
    67                           , public WebSharedWorker {
     64class WebSharedWorkerImpl
     65    : public WebCore::WorkerObjectProxy
     66    , public WebCore::WorkerLoaderProxy
     67    , public WebWorkerBase
     68    , public WebFrameClient
     69    , public WebSharedWorker {
    6870public:
    6971    explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
     
    8991    virtual bool postTaskForModeToWorkerContext(
    9092        PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode);
     93    virtual WebWorkerBase* toWebWorkerBase() OVERRIDE;
    9194
    9295    // WebFrameClient methods to support resource loading thru the 'shadow page'.
     
    112115
    113116
    114     // NewWebWorkerBase methods:
     117    // WebWorkerBase methods:
     118    WebCore::WorkerLoaderProxy* workerLoaderProxy() { return this; }
    115119    WebCommonWorkerClient* commonClient() { return m_client; }
    116120
  • trunk/Source/WebKit/chromium/src/WebWorkerBase.h

    r103789 r138693  
    4949//
    5050// FIXME: Rename this class into WebWorkerBase, merge existing WebWorkerBase and WebSharedWorker.
    51 class WebWorkerBase : public WebCore::WorkerLoaderProxy {
     51class WebWorkerBase {
    5252public:
     53    virtual WebCore::WorkerLoaderProxy* workerLoaderProxy() = 0;
    5354    virtual WebCommonWorkerClient* commonClient() = 0;
    5455    virtual WebView* view() const = 0;
  • trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp

    r137318 r138693  
    7070namespace WebKit {
    7171
    72 // Chromium-specific wrapper over WorkerMessagingProxy.
    73 // Delegates implementation of Worker{Loader,Context,Object}Proxy to WorkerMessagingProxy.
     72// Chromium-specific decorator of WorkerMessagingProxy.
    7473
    7574// static
     
    8079        WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
    8180        WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker, webFrame);
    82         return proxy; 
    83     } 
     81        return proxy;
     82    }
    8483    ASSERT_NOT_REACHED();
    8584    return 0;
    86 }
    87 
    88 void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode)
    89 {
    90     ASSERT(m_scriptExecutionContext->isDocument());
    91     Document* document = static_cast<Document*>(m_scriptExecutionContext.get());
    92     GroupSettings* settings = 0;
    93     if (document->page())
    94         settings = document->page()->group().groupSettings();
    95     RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
    96                                                                          document->contentSecurityPolicy()->deprecatedHeader(),
    97                                                                          document->contentSecurityPolicy()->deprecatedHeaderType(),
    98                                                                          document->topDocument()->securityOrigin());
    99     m_proxy->workerThreadCreated(thread);
    100     thread->start();
    101     InspectorInstrumentation::didStartWorkerContext(m_scriptExecutionContext.get(), m_proxy, scriptURL);
    10285}
    10386
     
    10588{
    10689    m_webFrame = 0;
    107     m_proxy->terminateWorkerContext();
     90    WebCore::WorkerMessagingProxy::terminateWorkerContext();
    10891}
    10992
    110 void WebWorkerClientImpl::postMessageToWorkerContext(
    111     PassRefPtr<SerializedScriptValue> value,
    112     PassOwnPtr<MessagePortChannelArray> ports)
     93WebWorkerBase* WebWorkerClientImpl::toWebWorkerBase()
    11394{
    114     m_proxy->postMessageToWorkerContext(value, ports);
     95    return this;
    11596}
    11697
    117 bool WebWorkerClientImpl::hasPendingActivity() const
     98WebView* WebWorkerClientImpl::view() const
    11899{
    119     return m_proxy->hasPendingActivity();
     100    if (askedToTerminate())
     101        return 0;
     102    return m_webFrame->view();
    120103}
    121104
    122 void WebWorkerClientImpl::workerObjectDestroyed()
     105bool WebWorkerClientImpl::allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
    123106{
    124     m_proxy->workerObjectDestroyed();
    125 }
    126 
    127 #if ENABLE(INSPECTOR)
    128 void WebWorkerClientImpl::connectToInspector(PageInspector* inspector)
    129 {
    130     m_proxy->connectToInspector(inspector);
    131 }
    132 
    133 void WebWorkerClientImpl::disconnectFromInspector()
    134 {
    135     m_proxy->disconnectFromInspector();
    136 }
    137 
    138 void WebWorkerClientImpl::sendMessageToInspector(const String& message)
    139 {
    140     m_proxy->sendMessageToInspector(message);
    141 }
    142 
    143 void WebWorkerClientImpl::postMessageToPageInspector(const String& message)
    144 {
    145     m_proxy->postMessageToPageInspector(message);
    146 }
    147 
    148 void WebWorkerClientImpl::updateInspectorStateCookie(const String& cookie)
    149 {
    150     m_proxy->updateInspectorStateCookie(cookie);
    151 }
    152 #endif // ENABLE(INSPECTOR)
    153 
    154 
    155 void WebWorkerClientImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task)
    156 {
    157     m_proxy->postTaskToLoader(task);
    158 }
    159 
    160 bool WebWorkerClientImpl::postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
    161 {
    162     return m_proxy->postTaskForModeToWorkerContext(task, mode);
    163 }
    164 
    165 void WebWorkerClientImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> value, PassOwnPtr<MessagePortChannelArray> ports)
    166 {
    167     m_proxy->postMessageToWorkerObject(value, ports);
    168 }
    169 
    170 void WebWorkerClientImpl::confirmMessageFromWorkerObject(bool hasPendingActivity)
    171 {
    172     m_proxy->confirmMessageFromWorkerObject(hasPendingActivity);
    173 }
    174 
    175 void WebWorkerClientImpl::reportPendingActivity(bool hasPendingActivity)
    176 {
    177     m_proxy->reportPendingActivity(hasPendingActivity);
    178 }
    179 
    180 void WebWorkerClientImpl::workerContextClosed()
    181 {
    182     m_proxy->workerContextClosed();
    183 }
    184 
    185 void WebWorkerClientImpl::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL)
    186 {
    187     m_proxy->postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
    188 }
    189 
    190 void WebWorkerClientImpl::postConsoleMessageToWorkerObject(MessageSource source, MessageLevel level, const String& message, int lineNumber, const String& sourceURL)
    191 {
    192     m_proxy->postConsoleMessageToWorkerObject(source, level, message, lineNumber, sourceURL);
    193 }
    194 
    195 void WebWorkerClientImpl::workerContextDestroyed()
    196 {
    197     m_proxy->workerContextDestroyed();
     107    if (askedToTerminate())
     108        return false;
     109    WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
     110    if (!webView)
     111        return false;
     112    return !webView->permissionClient() || webView->permissionClient()->allowDatabase(m_webFrame, name, displayName, estimatedSize);
    198113}
    199114
    200115bool WebWorkerClientImpl::allowFileSystem()
    201116{
    202     if (m_proxy->askedToTerminate())
     117    if (askedToTerminate())
    203118        return false;
    204119    WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
     
    208123}
    209124
    210 void WebWorkerClientImpl::openFileSystem(WebFileSystem::Type type, long long size, bool create, 
     125void WebWorkerClientImpl::openFileSystem(WebFileSystem::Type type, long long size, bool create,
    211126                                         WebFileSystemCallbacks* callbacks)
    212127{
    213     if (m_proxy->askedToTerminate()) {
     128    if (askedToTerminate()) {
    214129        callbacks->didFail(WebFileErrorAbort);
    215130        return;
     
    218133}
    219134
    220 bool WebWorkerClientImpl::allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
    221 {
    222     if (m_proxy->askedToTerminate())
    223         return false;
    224     WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
    225     if (!webView)
    226         return false;
    227     return !webView->permissionClient() || webView->permissionClient()->allowDatabase(m_webFrame, name, displayName, estimatedSize);
    228 }
    229 
    230135bool WebWorkerClientImpl::allowIndexedDB(const WebString& name)
    231136{
    232     if (m_proxy->askedToTerminate())
     137    if (askedToTerminate())
    233138        return false;
    234139    WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
     
    237142    return !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(m_webFrame, name, WebSecurityOrigin());
    238143}
    239  
    240 WebView* WebWorkerClientImpl::view() const
    241 {
    242     if (m_proxy->askedToTerminate())
    243         return 0;
    244     return m_webFrame->view();
    245 }
    246144
    247145WebWorkerClientImpl::WebWorkerClientImpl(Worker* worker, WebFrameImpl* webFrame)
    248     : m_proxy(new WorkerMessagingProxy(worker))
    249     , m_scriptExecutionContext(worker->scriptExecutionContext())
    250     , m_webFrame(webFrame)   
     146    : WebCore::WorkerMessagingProxy(worker)
     147    , m_webFrame(webFrame)
    251148{
    252149}
  • trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.h

    r137318 r138693  
    5555// databases and other related functionality.
    5656//
    57 // In essence, this class wraps WorkerMessagingProxy.
    58 class WebWorkerClientImpl : public WebCore::WorkerContextProxy
    59                           , public WebCore::WorkerObjectProxy
     57// In essence, this class decorates WorkerMessagingProxy.
     58//
     59// It is imperative that this class inherit from WorkerMessagingProxy rather than delegate to an instance of
     60// WorkerMessagingProxy, because that class tracks and reports its activity to outside callers, and manages
     61// its own lifetime, via calls to workerObjectDestroyed, workerContextDestroyed, workerContextClosed, etc. It
     62// is basically impossible to correctly manage the lifetime of this class separately from WorkerMessagingProxy.
     63class WebWorkerClientImpl : public WebCore::WorkerMessagingProxy
    6064                          , public WebWorkerBase
    6165                          , public WebCommonWorkerClient {
     
    6771    // These are called on the thread that created the worker.  In the renderer
    6872    // process, this will be the main WebKit thread.
    69     virtual void startWorkerContext(const WebCore::KURL&,
    70                                     const WTF::String&,
    71                                     const WTF::String&,
    72                                     WebCore::WorkerThreadStartMode) OVERRIDE;
    7373    virtual void terminateWorkerContext() OVERRIDE;
    74     virtual void postMessageToWorkerContext(
    75         PassRefPtr<WebCore::SerializedScriptValue> message,
    76         PassOwnPtr<WebCore::MessagePortChannelArray> channels) OVERRIDE;
    77     virtual bool hasPendingActivity() const OVERRIDE;
    78     virtual void workerObjectDestroyed() OVERRIDE;
    7974
    80 #if ENABLE(INSPECTOR)
    81     virtual void connectToInspector(WebCore::WorkerContextProxy::PageInspector*) OVERRIDE;
    82     virtual void disconnectFromInspector() OVERRIDE;
    83     virtual void sendMessageToInspector(const String&) OVERRIDE;
    84     virtual void postMessageToPageInspector(const String&) OVERRIDE;
    85     virtual void updateInspectorStateCookie(const String&) OVERRIDE;
    86 #endif
    87     // WebCore::WorkerLoaderProxy methods:
    88     virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>) OVERRIDE;
    89     virtual bool postTaskForModeToWorkerContext(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode) OVERRIDE;
     75    // WebCore::WorkerLoaderProxy methods
     76    virtual WebWorkerBase* toWebWorkerBase() OVERRIDE;
    9077
    91     // WebCore::WorkerObjectProxy methods:
    92     virtual void postMessageToWorkerObject(PassRefPtr<WebCore::SerializedScriptValue>, PassOwnPtr<WebCore::MessagePortChannelArray>) OVERRIDE;
    93     virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) OVERRIDE;
     78    // WebWorkerBase methods:
     79    virtual WebCore::WorkerLoaderProxy* workerLoaderProxy() OVERRIDE { return this; }
     80    virtual WebCommonWorkerClient* commonClient() OVERRIDE { return this; }
     81    virtual WebView* view() const OVERRIDE;
    9482
    95     virtual void postConsoleMessageToWorkerObject(WebCore::MessageSource, WebCore::MessageLevel,
    96                                                   const String& message, int lineNumber, const String& sourceURL) OVERRIDE;
    97     virtual void confirmMessageFromWorkerObject(bool) OVERRIDE;
    98     virtual void reportPendingActivity(bool) OVERRIDE;
    99     virtual void workerContextClosed() OVERRIDE;
    100     virtual void workerContextDestroyed() OVERRIDE;
    101 
    102     // WebWorkerClientBase methods:
     83    // WebCommonWorkerClient methods:
    10384    virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) OVERRIDE;
    10485    virtual bool allowFileSystem();
     
    10788    virtual bool allowIndexedDB(const WebString& name) OVERRIDE;
    10889
    109     // WebCommentWorkerBase methods:
    110     virtual WebCommonWorkerClient* commonClient() OVERRIDE { return this; }
    111     virtual WebView* view() const OVERRIDE;
    112 
    11390private:
    11491    WebWorkerClientImpl(WebCore::Worker*, WebFrameImpl*);
    11592    virtual ~WebWorkerClientImpl();
    11693
    117     WebCore::WorkerMessagingProxy* m_proxy;
    118     // Guard against context from being destroyed before a worker exits.
    119     RefPtr<WebCore::ScriptExecutionContext> m_scriptExecutionContext;
    12094    WebFrameImpl* m_webFrame;
    12195};
  • trunk/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp

    r125108 r138693  
    4141#include "WebFileSystemCallbacksImpl.h"
    4242#include "WebFileWriter.h"
    43 #include "WebWorkerBase.h"
    4443#include "WorkerAsyncFileWriterChromium.h"
    4544#include "WorkerContext.h"
     
    6362    ASSERT(m_scriptExecutionContext->isWorkerContext());
    6463
    65     WorkerLoaderProxy* workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy();
    66     m_worker = static_cast<WebWorkerBase*>(workerLoaderProxy);
     64    m_workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy();
    6765}
    6866
     
    195193    m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId()));
    196194
    197     m_bridgeForCurrentOperation = WorkerFileSystemCallbacksBridge::create(m_worker, m_scriptExecutionContext, new WebKit::WebFileSystemCallbacksImpl(callbacks));
     195    m_bridgeForCurrentOperation = WorkerFileSystemCallbacksBridge::create(m_workerLoaderProxy, m_scriptExecutionContext, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    198196    return m_bridgeForCurrentOperation;
    199197}
  • trunk/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h

    r116388 r138693  
    4242class WebFileSystem;
    4343class WebURL;
    44 class WebWorkerBase;
    4544class WorkerFileSystemCallbacksBridge;
    4645}
     
    5150class ScriptExecutionContext;
    5251class WorkerContext;
     52class WorkerLoaderProxy;
    5353
    5454class WorkerAsyncFileSystemChromium : public AsyncFileSystemChromium {
     
    8383
    8484    ScriptExecutionContext* m_scriptExecutionContext;
    85     WebKit::WebWorkerBase* m_worker;
     85    WorkerLoaderProxy* m_workerLoaderProxy;
    8686    WorkerContext* m_workerContext;
    8787    RefPtr<WebKit::WorkerFileSystemCallbacksBridge> m_bridgeForCurrentOperation;
Note: See TracChangeset for help on using the changeset viewer.