summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp
index 622da7056..741a2692f 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp
@@ -32,6 +32,7 @@
#include "JSWorkerContextBase.h"
#include "JSDedicatedWorkerContext.h"
+#include "JSSharedWorkerContext.h"
#include "JSWorkerContext.h"
#include "WorkerContext.h"
@@ -43,7 +44,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSWorkerContextBase);
const ClassInfo JSWorkerContextBase::s_info = { "WorkerContext", 0, 0, 0 };
-JSWorkerContextBase::JSWorkerContextBase(PassRefPtr<JSC::Structure> structure, PassRefPtr<WorkerContext> impl)
+JSWorkerContextBase::JSWorkerContextBase(NonNullPassRefPtr<JSC::Structure> structure, PassRefPtr<WorkerContext> impl)
: JSDOMGlobalObject(structure, new JSDOMGlobalObjectData, this)
, m_impl(impl)
{
@@ -83,10 +84,26 @@ JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSValue value)
return 0;
}
+#if ENABLE(SHARED_WORKERS)
+JSSharedWorkerContext* toJSSharedWorkerContext(JSValue value)
+{
+ if (!value.isObject())
+ return 0;
+ const ClassInfo* classInfo = asObject(value)->classInfo();
+ if (classInfo == &JSSharedWorkerContext::s_info)
+ return static_cast<JSSharedWorkerContext*>(asObject(value));
+ return 0;
+}
+#endif
+
JSWorkerContext* toJSWorkerContext(JSValue value)
{
- // When we support shared workers, we'll add code to test for SharedWorkerContext too.
- return toJSDedicatedWorkerContext(value);
+ JSWorkerContext* context = toJSDedicatedWorkerContext(value);
+#if ENABLE(SHARED_WORKERS)
+ if (!context)
+ context = toJSSharedWorkerContext(value);
+#endif
+ return context;
}
} // namespace WebCore