Ignore:
Timestamp:
Apr 26, 2010, 3:38:55 PM (15 years ago)
Author:
[email protected]
Message:

Fix for https://bugs.webkit.org/show_bug.cgi?id=38097
Disentangle initializing the main thread from initializing threading

Reviewed by Maciej Stachowiak.

JavaScriptCore:

This is the first step in getting rid of the WEB_THREAD #define and
paving the way to allowing mac both WebKit and WebKit2 to use the same
WebCore.

  • JavaScriptCore.exp: Export initializeMainThread and initializeMainThreadToProcessMainThread.
  • JavaScriptCore.xcodeproj/project.pbxproj: Sort files.
  • wtf/MainThread.cpp:

(WTF::mainThreadInitializationMutex):
(WTF::mainThreadFunctionQueueMutex):
(WTF::initializeMainThread):
(WTF::deprecatedInitializeMainThread):

  • wtf/MainThread.h:

Added Mac only initializeMainThreadToProcessMainThread which sets up callOnMainThread
and isMainThead calls to assume that WebCore's main thread is also the
process's main thread. Since it is possible that both initializeMainThread
and initializeMainThreadToProcessMainThread could be called, the first one called
wins (either will work).

  • wtf/Threading.h: Moved to top of file.
  • wtf/ThreadingPthreads.cpp:

(WTF::initializeThreading): Remove call to initializeMainThread.

  • wtf/ThreadingWin.cpp:

(WTF::initializeThreading): Ditto.

  • wtf/gtk/ThreadingGtk.cpp:

(WTF::initializeThreading): Ditto.

  • wtf/mac/MainThreadMac.mm:

(WTF::initializeMainThreadPlatform):
(WTF::initializeMainThreadToProcessMainThread):
(WTF::scheduleDispatchFunctionsOnMainThread):
(WTF::isMainThread):
Add runtime switch between the old behavior of using the system's main
thread and a stored pointer to the main thread. Tiger always uses the
system's main thread.

  • wtf/qt/ThreadingQt.cpp:

(WTF::initializeThreading): Remove call to initializeMainThread.

  • wtf/win/MainThreadWin.cpp:

(WTF::initializeMainThreadPlatform): Add call to initializeCurrentThreadInternal
removed from initializeThreading.

WebCore:

  • WebCore.xcodeproj/project.pbxproj: Sort files.
  • accessibility/mac/AccessibilityObjectWrapper.mm: Remove unnessary

+initialize method. The AccessibilityObjectWrapper has no data members
that need to be derefed, so it does not need to be finalized on the main
thread.

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::initializeThreading): Add call to initializeMainThread.

  • bindings/objc/WebScriptObject.mm:

(+[WebScriptObject initialize]): Add call to initializeMainThreadToProcessMainThread.

  • bindings/v8/ScriptController.cpp:

(WebCore::ScriptController::initializeThreading): Add call to initializeMainThread.

  • platform/mac/SharedBufferMac.mm:

(+[WebCoreSharedBufferData initialize]): Add call to initializeMainThreadToProcessMainThread.

WebKit/chromium:

  • src/WebKit.cpp:

(WebKit::initialize): Add call to initializeMainThread.

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::WebViewImpl): Ditto.

WebKit/gtk:

  • webkit/webkitprivate.cpp:

(webkit_init): Add call to initializeMainThread.

WebKit/mac:

Calls initializeMainThreadToProcessMainThread since there is no way to ensure
that the initialize method will be called on the main thread.

  • Carbon/CarbonWindowAdapter.mm:

(+[CarbonWindowAdapter initialize]): Add call to initializeMainThreadToProcessMainThread.

  • History/WebBackForwardList.mm:

(+[WebBackForwardList initialize]): Ditto.

  • History/WebHistoryItem.mm:

(+[WebHistoryItem initialize]): Ditto.

  • Misc/WebElementDictionary.mm:

(+[WebElementDictionary initialize]): Ditto.

  • Misc/WebIconDatabase.mm:

(+[WebIconDatabase initialize]): Ditto.

  • Plugins/Hosted/WebHostedNetscapePluginView.mm:

(+[WebHostedNetscapePluginView initialize]): Ditto.

  • Plugins/WebBaseNetscapePluginView.mm:

(+[WebBaseNetscapePluginView initialize]): Ditto.

  • Plugins/WebBasePluginPackage.mm:

(+[WebBasePluginPackage initialize]): Ditto.

  • Plugins/WebNetscapePluginView.mm:

(+[WebNetscapePluginView initialize]): Ditto.

  • WebCoreSupport/WebEditorClient.mm:

(+[WebEditCommand initialize]): Ditto.

  • WebCoreSupport/WebFrameLoaderClient.mm:

(+[WebFramePolicyListener initialize]): Ditto.

  • WebView/WebArchive.mm:

(+[WebArchivePrivate initialize]): Ditto.

  • WebView/WebDataSource.mm:

(+[WebDataSourcePrivate initialize]): Ditto.

  • WebView/WebHTMLView.mm:

(+[WebHTMLViewPrivate initialize]): Ditto.
(+[WebHTMLView initialize]): Ditto.

  • WebView/WebResource.mm:

(+[WebResourcePrivate initialize]): Ditto.

  • WebView/WebTextIterator.mm:

(+[WebTextIteratorPrivate initialize]): Ditto.

  • WebView/WebView.mm:
  • WebView/WebViewData.mm: Ditto.

(+[WebViewPrivate initialize]): Ditto.

WebKit/qt:

  • Api/qwebpage.cpp:

(QWebPagePrivate::QWebPagePrivate): Add call to initializeMainThread.

WebKit/win:

  • WebKitClassFactory.cpp:

(WebKitClassFactory::WebKitClassFactory): Add call to initializeMainThread.

  • WebView.cpp:

(WebView::WebView): Ditto.

WebKit/wx:

  • WebView.cpp:

(wxWebView::Create): Add call to initializeMainThread.

WebKit2:

  • UIProcess/Launcher/mac/WebProcessLauncher.mm:

(WebKit::webThreadBody): Add call to initializeMainThread.

  • UIProcess/Launcher/win/WebProcessLauncher.cpp:

(WebKit::webThreadBody): Ditto.

  • WebProcess/Launching/mac/WebProcessMain.mm:

(main): Ditto.

  • WebProcess/win/WebProcessMain.cpp:

(WebKit::WebProcessMain): Ditto.

File:
1 edited

Legend:

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

    r58179 r58266  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Justin Haygood ([email protected])
    44 *
     
    3131#define MainThread_h
    3232
     33#include <stdint.h>
     34
    3335namespace WTF {
    3436
    35 class Mutex;
    36 
     37typedef uint32_t ThreadIdentifier;
    3738typedef void MainThreadFunction(void*);
    3839
     40// Must be called from the main thread.
     41void initializeMainThread();
     42
    3943void callOnMainThread(MainThreadFunction*, void* context);
    40 
    41 // Blocks the thread until the call finishes on the main thread. Misusing this can easily cause deadlocks.
    4244void callOnMainThreadAndWait(MainThreadFunction*, void* context);
    43 
    4445void setMainThreadCallbacksPaused(bool paused);
    4546
    46 // Must be called from the main thread (Darwin is an exception to this rule).
    47 void initializeMainThread();
     47bool isMainThread();
    4848
    49 // These functions are internal to the callOnMainThread implementation.
     49// NOTE: these functions are internal to the callOnMainThread implementation.
    5050void initializeMainThreadPlatform();
    5151void scheduleDispatchFunctionsOnMainThread();
    52 Mutex& mainThreadFunctionQueueMutex();
    5352void dispatchFunctionsFromMainThread();
    5453
    55 bool isMainThread();
     54#if PLATFORM(MAC)
     55// This version of initializeMainThread sets up the main thread as corresponding
     56// to the process's main thread, and not necessarily the thread that calls this
     57// function. It should only be used as a legacy aid for Mac WebKit.
     58void initializeMainThreadToProcessMainThread();
     59void initializeMainThreadToProcessMainThreadPlatform();
     60#endif
    5661
    5762} // namespace WTF
Note: See TracChangeset for help on using the changeset viewer.