2009-02-24 David Levin <levin@chromium.org>
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2009 18:54:04 +0000 (18:54 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2009 18:54:04 +0000 (18:54 +0000)
        Reviewed by Alexey Proskuryakov.

        Bug 24090: WorkerThreadableLoader needs to be able to post tasks for a mode.
        <https://bugs.webkit.org/show_bug.cgi?id=24090>

        No observable change in behavior, so no test.

        * dom/WorkerMessagingProxy.cpp:
        (WebCore::WorkerMessagingProxy::postMessageToWorkerContext):
        (WebCore::WorkerMessagingProxy::postTaskToWorkerContext):
        Fixed the bug that m_unconfirmedMessageCount was getting incremented for non-message tasks.

        (WebCore::WorkerMessagingProxy::postTaskForModeToWorkerContext):

        * dom/WorkerMessagingProxy.h:
        * loader/ThreadableLoader.cpp:
        (WebCore::ThreadableLoader::create):
        * loader/WorkerThreadableLoader.cpp:
        (WebCore::WorkerThreadableLoader::WorkerThreadableLoader):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didSendData):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveData):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveAuthenticationCancellation):
        Changed these methods to post task using a mode.

        * loader/WorkerThreadableLoader.h:
        (WebCore::WorkerThreadableLoader::create):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41184 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/dom/WorkerMessagingProxy.cpp
WebCore/dom/WorkerMessagingProxy.h
WebCore/loader/ThreadableLoader.cpp
WebCore/loader/WorkerThreadableLoader.cpp
WebCore/loader/WorkerThreadableLoader.h

index 1214b3665d86d8206c8ac061957bc559b47cbb84..eb6dfb8ce7e3ed8c45828f7b07c2bc89cfd04875 100644 (file)
@@ -1,3 +1,37 @@
+2009-02-24  David Levin  <levin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Bug 24090: WorkerThreadableLoader needs to be able to post tasks for a mode.
+        <https://bugs.webkit.org/show_bug.cgi?id=24090>
+
+        No observable change in behavior, so no test.
+
+        * dom/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::postMessageToWorkerContext):
+        (WebCore::WorkerMessagingProxy::postTaskToWorkerContext):
+        Fixed the bug that m_unconfirmedMessageCount was getting incremented for non-message tasks.
+
+        (WebCore::WorkerMessagingProxy::postTaskForModeToWorkerContext):
+
+        * dom/WorkerMessagingProxy.h:
+        * loader/ThreadableLoader.cpp:
+        (WebCore::ThreadableLoader::create):
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::WorkerThreadableLoader):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didSendData):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveData):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveAuthenticationCancellation):
+        Changed these methods to post task using a mode.
+
+        * loader/WorkerThreadableLoader.h:
+        (WebCore::WorkerThreadableLoader::create):
+
 2009-02-24  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin Adler.
index 8d6260755d0bd322479d2d8ef2265f83067e3213..facb08cefe52d52bfbb4fb857379c0c98f7fc297 100644 (file)
@@ -210,19 +210,28 @@ void WorkerMessagingProxy::postMessageToWorkerObject(const String& message)
 
 void WorkerMessagingProxy::postMessageToWorkerContext(const String& message)
 {
-    postTaskToWorkerContext(MessageWorkerContextTask::create(message));
+    if (m_askedToTerminate)
+        return;
+
+    if (m_workerThread) {
+        ++m_unconfirmedMessageCount;
+        m_workerThread->runLoop().postTask(MessageWorkerContextTask::create(message));
+    } else
+        m_queuedEarlyTasks.append(MessageWorkerContextTask::create(message));
 }
 
 void WorkerMessagingProxy::postTaskToWorkerContext(PassRefPtr<ScriptExecutionContext::Task> task)
+{
+    postTaskForModeToWorkerContext(task, WorkerRunLoop::defaultMode());
+}
+
+void WorkerMessagingProxy::postTaskForModeToWorkerContext(PassRefPtr<ScriptExecutionContext::Task> task, const String& mode)
 {
     if (m_askedToTerminate)
         return;
 
-    if (m_workerThread) {
-        ++m_unconfirmedMessageCount;
-        m_workerThread->runLoop().postTask(task);
-    } else
-        m_queuedEarlyTasks.append(task);
+    ASSERT(m_workerThread);
+    m_workerThread->runLoop().postTaskForMode(task, mode);
 }
 
 void WorkerMessagingProxy::postTaskToWorkerObject(PassRefPtr<ScriptExecutionContext::Task> task)
index 3602171c8f72717ce017ff6a942cfc060d187966..3c85876c909037a23d9d30e489736b120b99c5e0 100644 (file)
@@ -66,6 +66,7 @@ namespace WebCore {
 
         void postTaskToWorkerObject(PassRefPtr<ScriptExecutionContext::Task>);
         void postTaskToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>);
+        void postTaskForModeToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>, const String& mode);
 
         void workerThreadCreated(PassRefPtr<WorkerThread>);
 
index 17b51e59eb147d1fa1f542a111dba2233a563c39..9939bcee856c64255d15098f036800a1d542b8b0 100644 (file)
@@ -37,6 +37,7 @@
 #include "FrameLoader.h"
 #include "ScriptExecutionContext.h"
 #include "WorkerContext.h"
+#include "WorkerRunLoop.h"
 #include "WorkerThreadableLoader.h"
 
 namespace WebCore {
@@ -48,7 +49,7 @@ PassRefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext* co
 
 #if ENABLE(WORKERS)
     if (context->isWorkerContext())
-        return WorkerThreadableLoader::create(static_cast<WorkerContext*>(context), client, request, callbacksSetting, contentSniff);
+        return WorkerThreadableLoader::create(static_cast<WorkerContext*>(context), client, WorkerRunLoop::defaultMode(), request, callbacksSetting, contentSniff);
 #endif // ENABLE(WORKERS)
 
     ASSERT(context->isDocument());
index 83728224ce39e3429fac3e914ec0753bed9a6a88..d801c2c5c21c9b84270cadbfec79e08b66ff2465 100644 (file)
@@ -52,9 +52,10 @@ using namespace std;
 namespace WebCore {
 
 // FIXME: The assumption that we can upcast worker object proxy to WorkerMessagingProxy will not be true in multi-process implementation.
-WorkerThreadableLoader::WorkerThreadableLoader(WorkerContext* workerContext, ThreadableLoaderClient* client, const ResourceRequest& request, LoadCallbacks callbacksSetting, ContentSniff contentSniff)
+WorkerThreadableLoader::WorkerThreadableLoader(WorkerContext* workerContext, ThreadableLoaderClient* client, const String& taskMode, const ResourceRequest& request, LoadCallbacks callbacksSetting,
+                                               ContentSniff contentSniff)
     : m_workerContext(workerContext)
-    , m_bridge(*(new MainThreadBridge(client, *(static_cast<WorkerMessagingProxy*>(m_workerContext->thread()->workerObjectProxy())), request, callbacksSetting, contentSniff)))
+    , m_bridge(*(new MainThreadBridge(client, *(static_cast<WorkerMessagingProxy*>(m_workerContext->thread()->workerObjectProxy())), taskMode, request, callbacksSetting, contentSniff)))
 {
 }
 
@@ -68,9 +69,11 @@ void WorkerThreadableLoader::cancel()
     m_bridge.cancel();
 }
 
-WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClient* workerClient, WorkerMessagingProxy& messagingProxy, const ResourceRequest& request, LoadCallbacks callbacksSetting, ContentSniff contentSniff)
+WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClient* workerClient, WorkerMessagingProxy& messagingProxy, const String& taskMode, const ResourceRequest& request,
+                                                           LoadCallbacks callbacksSetting, ContentSniff contentSniff)
     : m_workerClientWrapper(ThreadableLoaderClientWrapper::create(workerClient))
     , m_messagingProxy(messagingProxy)
+    , m_taskMode(taskMode.copy())
 {
     ASSERT(workerClient);
     m_messagingProxy.postTaskToWorkerObject(createCallbackTask(&MainThreadBridge::mainThreadCreateLoader, this, request, callbacksSetting, contentSniff));
@@ -149,7 +152,7 @@ static void workerContextDidSendData(ScriptExecutionContext* context, RefPtr<Thr
 
 void WorkerThreadableLoader::MainThreadBridge::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
 {
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidSendData, m_workerClientWrapper, bytesSent, totalBytesToBeSent));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidSendData, m_workerClientWrapper, bytesSent, totalBytesToBeSent), m_taskMode);
 }
 
 static void workerContextDidReceiveResponse(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, auto_ptr<CrossThreadResourceResponseData> responseData)
@@ -161,7 +164,7 @@ static void workerContextDidReceiveResponse(ScriptExecutionContext* context, Ref
 
 void WorkerThreadableLoader::MainThreadBridge::didReceiveResponse(const ResourceResponse& response)
 {
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidReceiveResponse, m_workerClientWrapper, response));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveResponse, m_workerClientWrapper, response), m_taskMode);
 }
 
 static void workerContextDidReceiveData(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, auto_ptr<Vector<char> > vectorData)
@@ -174,7 +177,7 @@ void WorkerThreadableLoader::MainThreadBridge::didReceiveData(const char* data,
 {
     auto_ptr<Vector<char> > vector(new Vector<char>(lengthReceived)); // needs to be an auto_ptr for usage with createCallbackTask.
     memcpy(vector->data(), data, lengthReceived);
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidReceiveData, m_workerClientWrapper, vector));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveData, m_workerClientWrapper, vector), m_taskMode);
 }
 
 static void workerContextDidFinishLoading(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, int identifier)
@@ -185,7 +188,7 @@ static void workerContextDidFinishLoading(ScriptExecutionContext* context, RefPt
 
 void WorkerThreadableLoader::MainThreadBridge::didFinishLoading(int identifier)
 {
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidFinishLoading, m_workerClientWrapper, identifier));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidFinishLoading, m_workerClientWrapper, identifier), m_taskMode);
 }
 
 static void workerContextDidFail(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, const ResourceError& error)
@@ -196,7 +199,7 @@ static void workerContextDidFail(ScriptExecutionContext* context, RefPtr<Threada
 
 void WorkerThreadableLoader::MainThreadBridge::didFail(const ResourceError& error)
 {
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidFail, m_workerClientWrapper, error));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidFail, m_workerClientWrapper, error), m_taskMode);
 }
 
 static void workerContextDidFailRedirectCheck(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper)
@@ -207,7 +210,7 @@ static void workerContextDidFailRedirectCheck(ScriptExecutionContext* context, R
 
 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck()
 {
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidFailRedirectCheck, m_workerClientWrapper));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidFailRedirectCheck, m_workerClientWrapper), m_taskMode);
 }
 
 static void workerContextDidReceiveAuthenticationCancellation(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, auto_ptr<CrossThreadResourceResponseData> responseData)
@@ -219,7 +222,7 @@ static void workerContextDidReceiveAuthenticationCancellation(ScriptExecutionCon
 
 void WorkerThreadableLoader::MainThreadBridge::didReceiveAuthenticationCancellation(const ResourceResponse& response)
 {
-    m_messagingProxy.postTaskToWorkerContext(createCallbackTask(&workerContextDidReceiveAuthenticationCancellation, m_workerClientWrapper, response));
+    m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveAuthenticationCancellation, m_workerClientWrapper, response), m_taskMode);
 }
 
 } // namespace WebCore
index ab6b62c9473a6dc99774e44b6fbd265647c97896..f997e10c64ddb0b9321c8a150b604aee2f924552 100644 (file)
@@ -33,6 +33,7 @@
 
 #if ENABLE(WORKERS)
 
+#include "PlatformString.h"
 #include "ThreadableLoader.h"
 #include "ThreadableLoaderClient.h"
 #include "ThreadableLoaderClientWrapper.h"
@@ -54,9 +55,9 @@ namespace WebCore {
 
     class WorkerThreadableLoader : public RefCounted<WorkerThreadableLoader>, public ThreadableLoader {
     public:
-        static PassRefPtr<WorkerThreadableLoader> create(WorkerContext* worker, ThreadableLoaderClient* client, const ResourceRequest& request, LoadCallbacks callbacksSetting, ContentSniff contentSniff)
+        static PassRefPtr<WorkerThreadableLoader> create(WorkerContext* worker, ThreadableLoaderClient* client, const String& taskMode, const ResourceRequest& request, LoadCallbacks callbacksSetting, ContentSniff contentSniff)
         {
-            return adoptRef(new WorkerThreadableLoader(worker, client, request, callbacksSetting, contentSniff));
+            return adoptRef(new WorkerThreadableLoader(worker, client, taskMode, request, callbacksSetting, contentSniff));
         }
 
         ~WorkerThreadableLoader();
@@ -93,7 +94,7 @@ namespace WebCore {
         class MainThreadBridge : ThreadableLoaderClient {
         public:
             // All executed on the worker context's thread.
-            MainThreadBridge(ThreadableLoaderClient*, WorkerMessagingProxy&, const ResourceRequest&, LoadCallbacks, ContentSniff);
+            MainThreadBridge(ThreadableLoaderClient*, WorkerMessagingProxy&, const String& taskMode, const ResourceRequest&, LoadCallbacks, ContentSniff);
             void cancel();
             void destroy();
 
@@ -124,9 +125,12 @@ namespace WebCore {
 
             // May be used on either thread.
             WorkerMessagingProxy& m_messagingProxy;
+
+            // For use on the main thread.
+            String m_taskMode;
         };
 
-        WorkerThreadableLoader(WorkerContext*, ThreadableLoaderClient*, const ResourceRequest&, LoadCallbacks, ContentSniff);
+        WorkerThreadableLoader(WorkerContext*, ThreadableLoaderClient*, const String& taskMode, const ResourceRequest&, LoadCallbacks, ContentSniff);
 
         RefPtr<WorkerContext> m_workerContext;
         MainThreadBridge& m_bridge;