source: webkit/trunk/JavaScriptCore/wtf/MainThread.h@ 58306

Last change on this file since 58306 was 58266, checked in by [email protected], 15 years ago

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.

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1/*
2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Justin Haygood ([email protected])
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef MainThread_h
31#define MainThread_h
32
33#include <stdint.h>
34
35namespace WTF {
36
37typedef uint32_t ThreadIdentifier;
38typedef void MainThreadFunction(void*);
39
40// Must be called from the main thread.
41void initializeMainThread();
42
43void callOnMainThread(MainThreadFunction*, void* context);
44void callOnMainThreadAndWait(MainThreadFunction*, void* context);
45void setMainThreadCallbacksPaused(bool paused);
46
47bool isMainThread();
48
49// NOTE: these functions are internal to the callOnMainThread implementation.
50void initializeMainThreadPlatform();
51void scheduleDispatchFunctionsOnMainThread();
52void dispatchFunctionsFromMainThread();
53
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
61
62} // namespace WTF
63
64using WTF::callOnMainThread;
65using WTF::callOnMainThreadAndWait;
66using WTF::setMainThreadCallbacksPaused;
67using WTF::isMainThread;
68
69#endif // MainThread_h
Note: See TracBrowser for help on using the repository browser.