summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/bindings/js/ScriptController.cpp6
-rw-r--r--WebCore/bindings/js/ScriptController.h4
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp9
-rw-r--r--WebCore/bindings/v8/ScriptController.h3
-rw-r--r--WebCore/loader/icon/IconDatabase.cpp13
-rw-r--r--WebCore/storage/Database.cpp10
6 files changed, 26 insertions, 19 deletions
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);