diff options
author | Steve Block <steveblock@google.com> | 2009-10-23 12:43:55 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-10-27 11:12:06 +0000 |
commit | 3a209a6ece975c026508762103516b7d0e55c18a (patch) | |
tree | ac5d37ae7266755cf0462ac1ff54d50ef9e8daaa | |
parent | 1e13e466217c7ffb96f5cde0ad0ab8606c0c2481 (diff) | |
download | external_webkit-3a209a6ece975c026508762103516b7d0e55c18a.zip external_webkit-3a209a6ece975c026508762103516b7d0e55c18a.tar.gz external_webkit-3a209a6ece975c026508762103516b7d0e55c18a.tar.bz2 |
Adds ScriptController::initializeThreading(), to allow initializeThreading() to be used with both JSC and V8 without the use of ifdefs.
See https://bugs.webkit.org/show_bug.cgi?id=30678
This has now been upstreamed to webkit.org, so submitting to Android to avoid future merge conflicts.
Change-Id: Ia17a9f02060f04b11a8bffa367164162775516ba
-rw-r--r-- | V8Binding/V8Binding.derived.mk | 1 | ||||
-rw-r--r-- | V8Binding/binding/InitializeThreading.cpp | 45 | ||||
-rw-r--r-- | V8Binding/binding/InitializeThreading.h | 40 | ||||
-rw-r--r-- | WebCore/bindings/js/ScriptController.cpp | 6 | ||||
-rw-r--r-- | WebCore/bindings/js/ScriptController.h | 4 | ||||
-rw-r--r-- | WebCore/bindings/v8/ScriptController.cpp | 9 | ||||
-rw-r--r-- | WebCore/bindings/v8/ScriptController.h | 3 | ||||
-rw-r--r-- | WebCore/loader/icon/IconDatabase.cpp | 13 | ||||
-rw-r--r-- | WebCore/storage/Database.cpp | 10 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 8 | ||||
-rw-r--r-- | perf/main.cpp | 12 |
11 files changed, 29 insertions, 122 deletions
diff --git a/V8Binding/V8Binding.derived.mk b/V8Binding/V8Binding.derived.mk index aec9982..0c21a1d 100644 --- a/V8Binding/V8Binding.derived.mk +++ b/V8Binding/V8Binding.derived.mk @@ -174,7 +174,6 @@ WEBCORE_SRC_FILES := $(WEBCORE_SRC_FILES) \ endif LOCAL_SRC_FILES := \ - binding/InitializeThreading.cpp \ jni/jni_class.cpp \ jni/jni_instance.cpp \ jni/jni_npobject.cpp \ diff --git a/V8Binding/binding/InitializeThreading.cpp b/V8Binding/binding/InitializeThreading.cpp deleted file mode 100644 index 8577369..0000000 --- a/V8Binding/binding/InitializeThreading.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "InitializeThreading.h" -#include <wtf/Threading.h> - -namespace V8 { - -void initializeThreading() { - static bool initializedThreading = false; - if (!initializedThreading) { - WTF::initializeThreading(); - initializedThreading = true; - } -} - -} // namespace JSC - - diff --git a/V8Binding/binding/InitializeThreading.h b/V8Binding/binding/InitializeThreading.h deleted file mode 100644 index 47b3957..0000000 --- a/V8Binding/binding/InitializeThreading.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef InitializeThreading_h -#define InitializeThreading_h - -namespace V8 { - - // This function must be called from the main thread. It is safe to call it repeatedly. - // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly. - void initializeThreading(); -} - -#endif // InitializeThreading_h - diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 6de9b75..45f8c75 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -38,12 +38,18 @@ #include "npruntime_impl.h" #include "runtime_root.h" #include <debugger/Debugger.h> +#include <runtime/InitializeThreading.h> #include <runtime/JSLock.h> using namespace JSC; namespace WebCore { +void ScriptController::initializeThreading() +{ + JSC::initializeThreading(); +} + ScriptController::ScriptController(Frame* frame) : m_frame(frame) , m_handlerLineNumber(0) diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index 56e8f0c..9ae10fb 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -80,6 +80,10 @@ public: return m_windowShell->window(); } + // This function must be called from the main thread. It is safe to call it repeatedly. + // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly. + static void initializeThreading(); + ScriptValue evaluate(const ScriptSourceCode&); void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&); diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index d2c1db2..85af072 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -60,6 +60,15 @@ namespace WebCore { +void ScriptController::initializeThreading() +{ + static bool initializedThreading = false; + if (!initializedThreading) { + WTF::initializeThreading(); + initializedThreading = true; + } +} + void ScriptController::setFlags(const char* string, int length) { v8::V8::SetFlagsFromString(string, length); diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h index 9658b05..ec15103 100644 --- a/WebCore/bindings/v8/ScriptController.h +++ b/WebCore/bindings/v8/ScriptController.h @@ -59,6 +59,9 @@ namespace WebCore { // or this accessor should be made JSProxy* V8Proxy* proxy() { return m_proxy.get(); } + // This function must be called from the main thread. It is safe to call it repeatedly. + static void initializeThreading(); + // Evaluate a script file in the environment of this proxy. // If succeeded, 'succ' is set to true and result is returned // as a string. diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp index 8982cda..5a9bfaa 100644 --- a/WebCore/loader/icon/IconDatabase.cpp +++ b/WebCore/loader/icon/IconDatabase.cpp @@ -36,6 +36,7 @@ #include "IconRecord.h" #include "IntSize.h" #include "Logging.h" +#include "ScriptController.h" #include "SQLiteStatement.h" #include "SQLiteTransaction.h" #include "SuddenTermination.h" @@ -43,12 +44,6 @@ #include <wtf/MainThread.h> #include <wtf/StdLibExtras.h> -#if USE(JSC) -#include <runtime/InitializeThreading.h> -#elif USE(V8) -#include "InitializeThreading.h" -#endif - // For methods that are meant to support API from the main thread - should not be called internally #define ASSERT_NOT_SYNC_THREAD() ASSERT(!m_syncThreadRunning || !IS_ICON_SYNC_THREAD()) @@ -98,11 +93,7 @@ static IconDatabaseClient* defaultClient() IconDatabase* iconDatabase() { if (!sharedIconDatabase) { -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); sharedIconDatabase = new IconDatabase; } return sharedIconDatabase; diff --git a/WebCore/storage/Database.cpp b/WebCore/storage/Database.cpp index 3a8225b..403e132 100644 --- a/WebCore/storage/Database.cpp +++ b/WebCore/storage/Database.cpp @@ -46,6 +46,7 @@ #include "NotImplemented.h" #include "Page.h" #include "OriginQuotaManager.h" +#include "ScriptController.h" #include "SQLiteDatabase.h" #include "SQLiteFileSystem.h" #include "SQLiteStatement.h" @@ -57,9 +58,6 @@ #if USE(JSC) #include "JSDOMWindow.h" -#include <runtime/InitializeThreading.h> -#elif USE(V8) -#include "InitializeThreading.h" #endif namespace WebCore { @@ -165,11 +163,7 @@ Database::Database(Document* document, const String& name, const String& expecte if (m_name.isNull()) m_name = ""; -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); m_guid = guidForOriginAndName(m_securityOrigin->toString(), name); diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 803f1b1..d6aa3f6 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -63,10 +63,8 @@ #if USE(JSC) #include "GCController.h" #include "JSDOMWindow.h" -#include <runtime/InitializeThreading.h> #include <runtime/JSLock.h> #elif USE(V8) -#include "InitializeThreading.h" #include "jni_npobject.h" #include "jni_instance.h" #endif // USE(JSC) @@ -867,11 +865,7 @@ static void CallPolicyFunction(JNIEnv* env, jobject obj, jint func, jint decisio static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAssetManager, jobject historyList) { -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter); diff --git a/perf/main.cpp b/perf/main.cpp index 927f55e..e3cb5b3 100644 --- a/perf/main.cpp +++ b/perf/main.cpp @@ -39,11 +39,6 @@ #include "FrameView.h" #include "GraphicsContext.h" #include "HistoryItem.h" -#if USE(JSC) -#include "InitializeThreading.h" -#elif USE(V8) -#include "V8InitializeThreading.h" -#endif #include "InspectorClientAndroid.h" #include "Intercept.h" #include "IntRect.h" @@ -53,6 +48,7 @@ #include "Page.h" #include "PlatformGraphicsContext.h" #include "ResourceRequest.h" +#include "ScriptController.h" #include "SelectionController.h" #include "Settings.h" #include "SharedBuffer.h" @@ -121,11 +117,7 @@ int main(int argc, char** argv) { LOGE("Please supply a file to read\n"); return 1; } -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); // Setting this allows data: urls to load from a local file. FrameLoader::setLocalLoadPolicy(FrameLoader::AllowLocalLoadsForAll); |