Commit 90b52e84 authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=22066
        Implement Worker global object

        * DerivedSources.make: Added WorkerLocation IDL and JSWorkerContext lookup table.

        * WebCore.xcodeproj/project.pbxproj: Only adding files to Mac project for now, as Worker
        support is still disabled by default.

        * bindings/js/JSDOMGlobalObject.cpp: (WebCore::toJSDOMGlobalObject): Implemented Worker case.

        * bindings/js/JSMessageChannelConstructor.cpp:
        (WebCore::JSMessageChannelConstructor::JSMessageChannelConstructor): Ditto.

        * bindings/js/JSWorkerContext.cpp: Added.
        * bindings/js/JSWorkerContext.h: Added.
        * bindings/js/WorkerScriptController.cpp: Added.
        * bindings/js/WorkerScriptController.h: Added.
        * dom/WorkerContext.cpp: Added.
        * dom/WorkerContext.h: Added.
        Added an implementation of worker contexts.

        * dom/DedicatedWorker.cpp:
        (WebCore::DedicatedWorker::startLoad): Fixed a lifetime bug I saw on my tests.
        (WebCore::DedicatedWorker::notifyFinished): Create a thread. Currently, object ownership
        and lifetime is not clear at all.

        * dom/WorkerLocation.cpp: Added.
        * dom/WorkerLocation.h: Added.
        * dom/WorkerLocation.idl: Added.
        Added WorkerLocation, which is one of the objects available to workers.

        * dom/WorkerThread.cpp: Added.
        (WebCore::WorkerThread::WorkerThread):
        (WebCore::WorkerThread::start):
        (WebCore::WorkerThread::workerThreadStart):
        (WebCore::WorkerThread::workerThread):
        * dom/WorkerThread.h: Added.
        (WebCore::WorkerThread::create):
        Run some code in a worker thread (no message loop yet).



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d4ff35ba
2008-11-05 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=22066
Implement Worker global object
* DerivedSources.make: Added WorkerLocation IDL and JSWorkerContext lookup table.
* WebCore.xcodeproj/project.pbxproj: Only adding files to Mac project for now, as Worker
support is still disabled by default.
* bindings/js/JSDOMGlobalObject.cpp: (WebCore::toJSDOMGlobalObject): Implemented Worker case.
* bindings/js/JSMessageChannelConstructor.cpp:
(WebCore::JSMessageChannelConstructor::JSMessageChannelConstructor): Ditto.
* bindings/js/JSWorkerContext.cpp: Added.
* bindings/js/JSWorkerContext.h: Added.
* bindings/js/WorkerScriptController.cpp: Added.
* bindings/js/WorkerScriptController.h: Added.
* dom/WorkerContext.cpp: Added.
* dom/WorkerContext.h: Added.
Added an implementation of worker contexts.
* dom/DedicatedWorker.cpp:
(WebCore::DedicatedWorker::startLoad): Fixed a lifetime bug I saw on my tests.
(WebCore::DedicatedWorker::notifyFinished): Create a thread. Currently, object ownership
and lifetime is not clear at all.
* dom/WorkerLocation.cpp: Added.
* dom/WorkerLocation.h: Added.
* dom/WorkerLocation.idl: Added.
Added WorkerLocation, which is one of the objects available to workers.
* dom/WorkerThread.cpp: Added.
(WebCore::WorkerThread::WorkerThread):
(WebCore::WorkerThread::start):
(WebCore::WorkerThread::workerThreadStart):
(WebCore::WorkerThread::workerThread):
* dom/WorkerThread.h: Added.
(WebCore::WorkerThread::create):
Run some code in a worker thread (no message loop yet).
2008-11-05 Antti Koivisto <antti@apple.com>
Reviewed by Dan Bernstein.
......@@ -359,6 +359,7 @@ DOM_CLASSES = \
WebKitCSSTransformValue \
WebKitTransitionEvent \
WheelEvent \
WorkerLocation \
XMLHttpRequest \
XMLHttpRequestException \
XMLHttpRequestProgressEvent \
......@@ -379,6 +380,7 @@ all : \
\
JSDOMWindowBase.lut.h \
JSRGBColor.lut.h \
JSWorkerContext.lut.h \
\
JSJavaScriptCallFrame.h \
\
......
......@@ -4151,6 +4151,8 @@
E1A302BC0DE8370300C52F2C /* StringBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A302BB0DE8370300C52F2C /* StringBuilder.h */; };
E1A302C10DE8376900C52F2C /* StringBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A302C00DE8376900C52F2C /* StringBuilder.cpp */; };
E1A5F99B0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */; };
E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A643F10EC0972500779668 /* WorkerScriptController.h */; };
E1A643FD0EC097A000779668 /* WorkerScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A643FC0EC097A000779668 /* WorkerScriptController.cpp */; };
E1ACAF4C0E791AAF0087D12B /* DOMMessagePort.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1ACAF4A0E791AAF0087D12B /* DOMMessagePort.mm */; };
E1ACAF4D0E791AAF0087D12B /* DOMMessagePort.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ACAF4B0E791AAF0087D12B /* DOMMessagePort.h */; };
E1ADECBF0E76ACF1004A1A5E /* MessagePort.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ADECBD0E76ACF1004A1A5E /* MessagePort.h */; };
......@@ -4163,8 +4165,19 @@
E1ADEDDB0E76BD93004A1A5E /* JSMessagePort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1ADEDD90E76BD93004A1A5E /* JSMessagePort.cpp */; };
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */; };
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */; };
E1C2C4240EACE0BC007E61FB /* WorkerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C2C4230EACE0BC007E61FB /* WorkerThread.h */; };
E1C2C4290EACE0E0007E61FB /* WorkerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C2C4280EACE0E0007E61FB /* WorkerThread.cpp */; };
E1C2C43E0EAD0133007E61FB /* WorkerContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C2C43D0EAD0133007E61FB /* WorkerContext.h */; };
E1C2C4420EAD017B007E61FB /* WorkerContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C2C4410EAD017B007E61FB /* WorkerContext.cpp */; };
E1C362BC0EAF29FB007410BC /* WorkerLocation.idl in Resources */ = {isa = PBXBuildFile; fileRef = E1C362BB0EAF29FB007410BC /* WorkerLocation.idl */; };
E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */; };
E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C362EE0EAF2AA9007410BC /* JSWorkerLocation.cpp */; };
E1C363010EAF2CC6007410BC /* WorkerLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C363000EAF2CC6007410BC /* WorkerLocation.h */; };
E1C363060EAF2D07007410BC /* WorkerLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C363050EAF2D07007410BC /* WorkerLocation.cpp */; };
E1C36C030EB076D6007410BC /* JSDOMGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1C36CBD0EB08062007410BC /* JSDOMGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C36CBC0EB08062007410BC /* JSDOMGlobalObject.cpp */; };
E1C36D340EB0A094007410BC /* JSWorkerContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C36D320EB0A094007410BC /* JSWorkerContext.cpp */; };
E1C36D350EB0A094007410BC /* JSWorkerContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C36D330EB0A094007410BC /* JSWorkerContext.h */; };
E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */; };
E1C4DE6E0EA75C650023CCD6 /* ActiveDOMObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */; };
E1C8BE5D0E8BD15A0064CB7D /* JSDedicatedWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C8BE5C0E8BD15A0064CB7D /* JSDedicatedWorker.cpp */; };
......@@ -8761,6 +8774,8 @@
E1A302BB0DE8370300C52F2C /* StringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilder.h; sourceTree = "<group>"; };
E1A302C00DE8376900C52F2C /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageChannelCustom.cpp; sourceTree = "<group>"; };
E1A643F10EC0972500779668 /* WorkerScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptController.h; sourceTree = "<group>"; };
E1A643FC0EC097A000779668 /* WorkerScriptController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerScriptController.cpp; sourceTree = "<group>"; };
E1ACAF4A0E791AAF0087D12B /* DOMMessagePort.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMMessagePort.mm; sourceTree = "<group>"; };
E1ACAF4B0E791AAF0087D12B /* DOMMessagePort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMMessagePort.h; sourceTree = "<group>"; };
E1ADECBD0E76ACF1004A1A5E /* MessagePort.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = MessagePort.h; sourceTree = "<group>"; };
......@@ -8775,8 +8790,19 @@
E1ADEDD90E76BD93004A1A5E /* JSMessagePort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessagePort.cpp; sourceTree = "<group>"; };
E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTUnicodeSort.cpp; sourceTree = "<group>"; };
E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTUnicodeSort.h; sourceTree = "<group>"; };
E1C2C4230EACE0BC007E61FB /* WorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerThread.h; sourceTree = "<group>"; };
E1C2C4280EACE0E0007E61FB /* WorkerThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerThread.cpp; sourceTree = "<group>"; };
E1C2C43D0EAD0133007E61FB /* WorkerContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerContext.h; sourceTree = "<group>"; };
E1C2C4410EAD017B007E61FB /* WorkerContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerContext.cpp; sourceTree = "<group>"; };
E1C362BB0EAF29FB007410BC /* WorkerLocation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WorkerLocation.idl; sourceTree = "<group>"; };
E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerLocation.h; sourceTree = "<group>"; };
E1C362EE0EAF2AA9007410BC /* JSWorkerLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerLocation.cpp; sourceTree = "<group>"; };
E1C363000EAF2CC6007410BC /* WorkerLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerLocation.h; sourceTree = "<group>"; };
E1C363050EAF2D07007410BC /* WorkerLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerLocation.cpp; sourceTree = "<group>"; };
E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGlobalObject.h; sourceTree = "<group>"; };
E1C36CBC0EB08062007410BC /* JSDOMGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGlobalObject.cpp; sourceTree = "<group>"; };
E1C36D320EB0A094007410BC /* JSWorkerContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContext.cpp; sourceTree = "<group>"; };
E1C36D330EB0A094007410BC /* JSWorkerContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContext.h; sourceTree = "<group>"; };
E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMObject.h; sourceTree = "<group>"; };
E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActiveDOMObject.cpp; sourceTree = "<group>"; };
E1C8BE440E8BCCBB0064CB7D /* DedicatedWorker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DedicatedWorker.idl; sourceTree = "<group>"; };
......@@ -12880,6 +12906,8 @@
BC3452410D7E00EA0016574A /* JSRGBColor.cpp */,
BC3452420D7E00EA0016574A /* JSRGBColor.h */,
B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */,
E1C36D320EB0A094007410BC /* JSWorkerContext.cpp */,
E1C36D330EB0A094007410BC /* JSWorkerContext.h */,
BC348BE70DB80354004ABAB9 /* JSXMLHttpRequestConstructor.cpp */,
BC348BE80DB80354004ABAB9 /* JSXMLHttpRequestConstructor.h */,
BCE99EC10DCA624100182683 /* JSXSLTProcessorConstructor.cpp */,
......@@ -12894,6 +12922,8 @@
65488D6A0DD5A83D009D83B2 /* StringSourceProvider.h */,
BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
E1A643F10EC0972500779668 /* WorkerScriptController.h */,
E1A643FC0EC097A000779668 /* WorkerScriptController.cpp */,
);
path = js;
sourceTree = "<group>";
......@@ -13354,6 +13384,8 @@
children = (
E1C8BE5C0E8BD15A0064CB7D /* JSDedicatedWorker.cpp */,
E1CAA5C50E8BD23600A73ECA /* JSDedicatedWorker.h */,
E1C362EE0EAF2AA9007410BC /* JSWorkerLocation.cpp */,
E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */,
);
name = Threads;
sourceTree = "<group>";
......@@ -14020,6 +14052,13 @@
85031B3A0A44EFC700F992E0 /* WheelEvent.cpp */,
85031B3B0A44EFC700F992E0 /* WheelEvent.h */,
93EEC1F709C2877700C515D1 /* WheelEvent.idl */,
E1C2C4410EAD017B007E61FB /* WorkerContext.cpp */,
E1C2C43D0EAD0133007E61FB /* WorkerContext.h */,
E1C363050EAF2D07007410BC /* WorkerLocation.cpp */,
E1C363000EAF2CC6007410BC /* WorkerLocation.h */,
E1C362BB0EAF29FB007410BC /* WorkerLocation.idl */,
E1C2C4280EACE0E0007E61FB /* WorkerThread.cpp */,
E1C2C4230EACE0BC007E61FB /* WorkerThread.h */,
F523D30902DE4476018635CA /* XMLTokenizer.cpp */,
F523D30A02DE4476018635CA /* XMLTokenizer.h */,
54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */,
......@@ -16154,6 +16193,11 @@
BCE659A90EA927B9007E4533 /* ThemeTypes.h in Headers */,
BCE659E60EA92FB2007E4533 /* ThemeMac.h in Headers */,
E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */,
E1C2C4240EACE0BC007E61FB /* WorkerThread.h in Headers */,
E1C2C43E0EAD0133007E61FB /* WorkerContext.h in Headers */,
E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */,
E1C363010EAF2CC6007410BC /* WorkerLocation.h in Headers */,
E1C36D350EB0A094007410BC /* JSWorkerContext.h in Headers */,
FEAB90130EA51B9C006348C3 /* GeolocationService.h in Headers */,
BCE65BEB0EACDF16007E4533 /* Length.h in Headers */,
BCFF64910EAD15C200C1D6F7 /* LengthBox.h in Headers */,
......@@ -16161,6 +16205,7 @@
E1C36C030EB076D6007410BC /* JSDOMGlobalObject.h in Headers */,
0FC705210EB1815600B90AD8 /* AtomicStringHash.h in Headers */,
E11C9D9B0EB3681200E409DB /* ScriptExecutionContext.h in Headers */,
E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -16275,6 +16320,7 @@
85136CA80AED665900F90A3D /* westResizeCursor.png in Resources */,
1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */,
1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
E1C362BC0EAF29FB007410BC /* WorkerLocation.idl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -18057,11 +18103,17 @@
939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
BCE659E90EA92FFA007E4533 /* ThemeMac.mm in Sources */,
E1C4DE6E0EA75C650023CCD6 /* ActiveDOMObject.cpp in Sources */,
E1C2C4290EACE0E0007E61FB /* WorkerThread.cpp in Sources */,
E1C2C4420EAD017B007E61FB /* WorkerContext.cpp in Sources */,
E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */,
E1C363060EAF2D07007410BC /* WorkerLocation.cpp in Sources */,
E1C36D340EB0A094007410BC /* JSWorkerContext.cpp in Sources */,
FEAB90120EA51B9C006348C3 /* GeolocationService.cpp in Sources */,
BCE65BEA0EACDF16007E4533 /* Length.cpp in Sources */,
BCE65D320EAD1211007E4533 /* Theme.cpp in Sources */,
E1C36CBD0EB08062007410BC /* JSDOMGlobalObject.cpp in Sources */,
E11C9DB00EB3699500E409DB /* ScriptExecutionContext.cpp in Sources */,
E1A643FD0EC097A000779668 /* WorkerScriptController.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -30,6 +30,8 @@
#include "Document.h"
#include "JSDOMWindow.h"
#include "JSEventListener.h"
#include "JSWorkerContext.h"
#include "WorkerContext.h"
using namespace JSC;
......@@ -161,7 +163,12 @@ JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionCo
if (scriptExecutionContext->isDocument())
return toJSDOMWindow(static_cast<Document*>(scriptExecutionContext)->frame());
// Not implemented yet.
#if ENABLE(WORKERS)
if (scriptExecutionContext->isWorkerContext())
return static_cast<WorkerContext*>(scriptExecutionContext)->script()->workerContextWrapper();
#endif
ASSERT_NOT_REACHED();
return 0;
}
......
......@@ -29,6 +29,7 @@
#include "Document.h"
#include "JSDocument.h"
#include "JSMessageChannel.h"
#include "JSWorkerContext.h"
#include "MessageChannel.h"
using namespace JSC;
......@@ -43,8 +44,10 @@ JSMessageChannelConstructor::JSMessageChannelConstructor(ExecState* exec, Script
{
if (m_scriptExecutionContext->isDocument())
m_contextWrapper = toJS(exec, static_cast<Document*>(scriptExecutionContext));
#if ENABLE(WORKERS)
else if (m_scriptExecutionContext->isWorkerContext())
; // Not yet implemented.
m_contextWrapper = toJSDOMGlobalObject(scriptExecutionContext);
#endif
else
ASSERT_NOT_REACHED();
......
/*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
* 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"
#if ENABLE(WORKERS)
#include "JSWorkerContext.h"
#include "JSDOMBinding.h"
#include "JSMessageChannelConstructor.h"
#include "JSMessagePort.h"
#include "JSWorkerLocation.h"
#include "WorkerContext.h"
#include "WorkerLocation.h"
using namespace JSC;
namespace WebCore {
JSValue* jsWorkerContextLocation(ExecState*, const Identifier&, const PropertySlot&);
JSValue* jsWorkerContextMessageChannel(ExecState*, const Identifier&, const PropertySlot&);
void setJSWorkerContextMessageChannel(ExecState*, JSObject*, JSValue*);
JSValue* jsWorkerContextMessagePort(ExecState*, const Identifier&, const PropertySlot&);
void setJSWorkerContextMessagePort(ExecState*, JSObject*, JSValue*);
JSValue* jsWorkerContextWorkerLocation(ExecState*, const Identifier&, const PropertySlot&);
void setJSWorkerContextWorkerLocation(ExecState*, JSObject*, JSValue*);
}
/*
@begin JSWorkerContextPrototypeTable
# close jsWorkerContextPrototypeFunctionClose DontDelete|Function 0
# MessagePort methods?
@end
*/
/*
@begin JSWorkerContextTable
location jsWorkerContextLocation DontDelete|ReadOnly
# onclose jsWorkerContextOnclose DontDelete
# onconnect jsWorkerContextOnconnect DontDelete
# onmessage and other MessagePort attributes?
MessageChannel jsWorkerContextMessageChannel DontDelete
MessagePort jsWorkerContextMessagePort DontDelete
WorkerLocation jsWorkerContextWorkerLocation DontDelete
# XMLHttpRequest jsWorkerContextXMLHttpRequest DontDelete
# Database
@end
*/
#include "JSWorkerContext.lut.h"
namespace WebCore {
ASSERT_CLASS_FITS_IN_CELL(JSWorkerContext)
static inline PassRefPtr<StructureID> createJSWorkerContextStructureID(JSGlobalData* globalData)
{
return JSWorkerContext::createStructureID(new (globalData) JSWorkerContextPrototype(JSWorkerContextPrototype::createStructureID(jsNull())));
}
JSWorkerContext::JSWorkerContext(PassRefPtr<WorkerContext> impl)
: JSDOMGlobalObject(createJSWorkerContextStructureID(Heap::heap(this)->globalData()), new JSDOMGlobalObjectData, this)
, m_impl(impl)
{
GlobalPropertyInfo staticGlobals[] = {
GlobalPropertyInfo(Identifier(globalExec(), "self"), this, DontDelete | ReadOnly),
};
addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
}
JSWorkerContext::~JSWorkerContext()
{
}
ScriptExecutionContext* JSWorkerContext::scriptExecutionContext() const
{
return m_impl.get();
}
void JSWorkerContext::mark()
{
Base::mark();
markActiveObjectsForContext(*globalData(), scriptExecutionContext());
}
static const HashTable* getJSWorkerContextTable(ExecState* exec)
{
return getHashTableForGlobalData(exec->globalData(), &JSWorkerContextTable);
}
const ClassInfo JSWorkerContext::s_info = { "WorkerContext", 0, 0, getJSWorkerContextTable };
JSObject* JSWorkerContext::createPrototype(ExecState* exec)
{
return new (exec) JSWorkerContextPrototype(JSWorkerLocationPrototype::createStructureID(exec->lexicalGlobalObject()->objectPrototype()));
}
bool JSWorkerContext::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticValueSlot<JSWorkerContext, Base>(exec, getJSWorkerContextTable(exec), this, propertyName, slot);
}
JSValue* jsWorkerContextLocation(JSC::ExecState* exec, const Identifier&, const PropertySlot& slot)
{
WorkerContext* imp = static_cast<WorkerContext*>(static_cast<JSWorkerContext*>(asObject(slot.slotBase()))->impl());
return toJS(exec, imp->location());
}
JSValue* jsWorkerContextMessageChannel(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
return getDOMConstructor<JSMessageChannelConstructor>(exec, static_cast<JSWorkerContext*>(asObject(slot.slotBase())));
}
JSValue* jsWorkerContextMessagePort(ExecState* exec, const Identifier&, const PropertySlot&)
{
return JSMessagePort::getConstructor(exec);
}
JSValue* jsWorkerContextWorkerLocation(ExecState* exec, const Identifier&, const PropertySlot&)
{
return JSWorkerLocation::getConstructor(exec);
}
static const HashTable* getJSWorkerContextPrototypeTable(ExecState* exec)
{
return getHashTableForGlobalData(exec->globalData(), &JSWorkerContextPrototypeTable);
}
const ClassInfo JSWorkerContextPrototype::s_info = { "WorkerContextPrototype", 0, 0, getJSWorkerContextPrototypeTable };
JSObject* JSWorkerContextPrototype::self(ExecState* exec)
{
return getDOMPrototype<JSWorkerContext>(exec);
}
bool JSWorkerContextPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticFunctionSlot<JSObject>(exec, getJSWorkerContextPrototypeTable(exec), this, propertyName, slot);
}
void setJSWorkerContextMessageChannel(ExecState*, JSObject*, JSValue*)
{
// FIXME: Do we need to override put for global constructors, like JSDOMWindowBase does?
ASSERT_NOT_REACHED();
}
void setJSWorkerContextMessagePort(ExecState*, JSObject*, JSValue*)
{
ASSERT_NOT_REACHED();
}
void setJSWorkerContextWorkerLocation(ExecState*, JSObject*, JSValue*)
{
ASSERT_NOT_REACHED();
}
} // namespace WebCore
#endif // ENABLE(WORKERS)
/*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
* 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 JSWorkerContext_h
#define JSWorkerContext_h
#if ENABLE(WORKERS)
#include "JSDOMGlobalObject.h"
namespace WebCore {
class WorkerContext;
class JSWorkerContext : public JSDOMGlobalObject {
typedef JSDOMGlobalObject Base;
public:
JSWorkerContext(PassRefPtr<WorkerContext>);
virtual ~JSWorkerContext();
static JSC::JSObject* createPrototype(JSC::ExecState*);
virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
static const JSC::ClassInfo s_info;
static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* prototype)
{
return JSC::StructureID::create(prototype, JSC::TypeInfo(JSC::ObjectType));
}
WorkerContext* impl() const { return m_impl.get(); }
virtual ScriptExecutionContext* scriptExecutionContext() const;
virtual void mark();
private:
RefPtr<WorkerContext> m_impl;
};
class JSWorkerContextPrototype : public JSC::JSObject {
public:
static JSC::JSObject* self(JSC::ExecState*);
JSWorkerContextPrototype(PassRefPtr<JSC::StructureID> structure) : JSC::JSObject(structure) { }
virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
static const JSC::ClassInfo s_info;
virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* prototype)
{
return JSC::StructureID::create(prototype, JSC::TypeInfo(JSC::ObjectType));
}
};
} // namespace WebCore
#endif // ENABLE(WORKERS)
#endif // JSWorkerContext_h
/*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
* 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"
#if ENABLE(WORKERS)
#include "WorkerScriptController.h"
#include "JSWorkerContext.h"
#include "WorkerContext.h"
#include <kjs/SourceCode.h>
#include <runtime/Completion.h>
#include <runtime/Interpreter.h>
#include <runtime/JSLock.h>
using namespace JSC;
namespace WebCore {
WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
: m_globalData(JSGlobalData::create())
, m_workerContext(workerContext)
{
}
WorkerScriptController::~WorkerScriptController()
{
m_workerContextWrapper = 0; // Unprotect the global object.
ASSERT(!m_globalData->heap.protectedObjectCount());
ASSERT(!m_globalData->heap.isBusy());
m_globalData->heap.destroy();
}
void WorkerScriptController::initScript()
{
ASSERT(!m_workerContextWrapper);
JSLock lock(false);
m_workerContextWrapper = new (m_globalData.get()) JSWorkerContext(m_workerContext);
}
JSValue* WorkerScriptController::evaluate(const String& sourceURL, int baseLine, const String& code)
{
ExecState* exec = m_workerContextWrapper->globalExec();
m_workerContextWrapper->startTimeoutCheck();
Completion comp = Interpreter::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), makeSource(code, sourceURL, baseLine), m_workerContextWrapper);
m_workerContextWrapper->stopTimeoutCheck();
if (comp.complType() == Normal || comp.complType() == ReturnValue)
return comp.value();
// FIXME: send exceptions to console.
if (comp.complType() == Throw)
fprintf(stderr, "%s\n", comp.value()->toString(exec).UTF8String().c_str());
return noValue();
}
} // namespace WebCore
#endif // ENABLE(WORKERS)
/*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
* 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 WorkerScriptController_h
#define WorkerScriptController_h
#if ENABLE(WORKERS)
#include <runtime/Protect.h>