Ignore:
Timestamp:
Nov 19, 2009, 4:53:38 PM (16 years ago)
Author:
[email protected]
Message:

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=31690
Make SocketStreamHandleCFNet work on Windows

  • WebCore.vcproj/WebCore.vcproj: Added LoaderRunLoopCF.
  • platform/network/ResourceHandle.h: Removed loaderRunLoop().
  • platform/network/cf/LoaderRunLoopCF.cpp: Added. (WebCore::emptyPerform): (WebCore::runLoaderThread): (WebCore::loaderRunLoop):
  • platform/network/cf/LoaderRunLoopCF.h: Added. Moved the run loop that we use for CFNetwork from ResourceHandle to its own file, because it's needed for more than just resource loading.
  • platform/network/cf/ResourceHandleCFNet.cpp: Use loaderRunLoop() from its new location.
  • platform/network/cf/DNSCFNet.cpp: (WebCore::DNSResolveQueue::resolve): Ditto.
  • platform/network/cf/SocketStreamHandle.h: Added static callbacks for forwarding events to main thread.
  • platform/network/cf/SocketStreamHandleCFNet.cpp: (WebCore::SocketStreamHandle::SocketStreamHandle): Use loaderRunLoop() on Windows instead of inoperable main run loop.

(WebCore::MainThreadEventCallbackInfo::MainThreadEventCallbackInfo):
(WebCore::SocketStreamHandle::readStreamCallback):
(WebCore::SocketStreamHandle::writeStreamCallback):
(WebCore::SocketStreamHandle::readStreamCallbackMainThread):
(WebCore::SocketStreamHandle::writeStreamCallbackMainThread):
Forward stream events to main thread on Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/MainThread.cpp

    r46598 r51222  
    4040    MainThreadFunction* function;
    4141    void* context;
     42    ThreadCondition* syncFlag;
    4243
    43     FunctionWithContext(MainThreadFunction* function = 0, void* context = 0)
     44    FunctionWithContext(MainThreadFunction* function = 0, void* context = 0, ThreadCondition* syncFlag = 0)
    4445        : function(function)
    4546        , context(context)
     47        , syncFlag(syncFlag)
    4648    {
    4749    }
     
    9395
    9496        invocation.function(invocation.context);
     97        if (invocation.syncFlag)
     98            invocation.syncFlag->signal();
    9599
    96100        // If we are running accumulated functions for too long so UI may become unresponsive, we need to
     
    118122}
    119123
     124void callOnMainThreadAndWait(MainThreadFunction* function, void* context)
     125{
     126    ASSERT(function);
     127
     128    if (isMainThread()) {
     129        function(context);
     130        return;
     131    }
     132
     133    ThreadCondition syncFlag;
     134    Mutex& functionQueueMutex = mainThreadFunctionQueueMutex();
     135    MutexLocker locker(functionQueueMutex);
     136    functionQueue().append(FunctionWithContext(function, context, &syncFlag));
     137    if (functionQueue().size() == 1)
     138        scheduleDispatchFunctionsOnMainThread();
     139    syncFlag.wait(functionQueueMutex);
     140}
     141
    120142void setMainThreadCallbacksPaused(bool paused)
    121143{
Note: See TracChangeset for help on using the changeset viewer.