summaryrefslogtreecommitdiffstats
path: root/WebCore/workers
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/workers')
-rw-r--r--WebCore/workers/DedicatedWorkerContext.cpp17
-rw-r--r--WebCore/workers/DedicatedWorkerContext.h6
-rw-r--r--WebCore/workers/DedicatedWorkerThread.cpp2
-rw-r--r--WebCore/workers/DefaultSharedWorkerRepository.cpp141
-rw-r--r--WebCore/workers/DefaultSharedWorkerRepository.h28
-rw-r--r--WebCore/workers/SharedWorkerContext.cpp12
-rw-r--r--WebCore/workers/SharedWorkerContext.h5
-rw-r--r--WebCore/workers/SharedWorkerRepository.h8
-rw-r--r--WebCore/workers/SharedWorkerThread.cpp8
-rw-r--r--WebCore/workers/SharedWorkerThread.h4
-rw-r--r--WebCore/workers/Worker.cpp2
-rw-r--r--WebCore/workers/WorkerContext.cpp30
-rw-r--r--WebCore/workers/WorkerContext.h10
-rw-r--r--WebCore/workers/WorkerContext.idl7
-rw-r--r--WebCore/workers/WorkerObjectProxy.h15
-rw-r--r--WebCore/workers/WorkerReportingProxy.h61
-rw-r--r--WebCore/workers/WorkerScriptLoader.cpp17
-rw-r--r--WebCore/workers/WorkerScriptLoader.h4
-rw-r--r--WebCore/workers/WorkerThread.cpp3
-rw-r--r--WebCore/workers/WorkerThread.h15
20 files changed, 102 insertions, 293 deletions
diff --git a/WebCore/workers/DedicatedWorkerContext.cpp b/WebCore/workers/DedicatedWorkerContext.cpp
index 6e5a317..ae5c547 100644
--- a/WebCore/workers/DedicatedWorkerContext.cpp
+++ b/WebCore/workers/DedicatedWorkerContext.cpp
@@ -46,6 +46,23 @@ DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& us
{
}
+DedicatedWorkerContext::~DedicatedWorkerContext()
+{
+ ASSERT(currentThread() == thread()->threadID());
+ // Notify parent worker we are going away. This can free the WorkerThread object, so do not access it after this.
+ thread()->workerObjectProxy().workerContextDestroyed();
+}
+
+void DedicatedWorkerContext::forwardException(const String& errorMessage, int lineNumber, const String& sourceURL)
+{
+ thread()->workerObjectProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
+}
+
+void DedicatedWorkerContext::addMessage(MessageDestination destination, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
+{
+ thread()->workerObjectProxy().postConsoleMessageToWorkerObject(destination, source, type, level, message, lineNumber, sourceURL);
+}
+
void DedicatedWorkerContext::postMessage(const String& message, ExceptionCode& ec)
{
postMessage(message, 0, ec);
diff --git a/WebCore/workers/DedicatedWorkerContext.h b/WebCore/workers/DedicatedWorkerContext.h
index be9be0b..e974cef 100644
--- a/WebCore/workers/DedicatedWorkerContext.h
+++ b/WebCore/workers/DedicatedWorkerContext.h
@@ -46,12 +46,18 @@ namespace WebCore {
{
return adoptRef(new DedicatedWorkerContext(url, userAgent, thread));
}
+ virtual ~DedicatedWorkerContext();
virtual bool isDedicatedWorkerContext() const { return true; }
// Overridden to allow us to check our pending activity after executing imported script.
virtual void importScripts(const Vector<String>& urls, const String& callerURL, int callerLine, ExceptionCode&);
+ // ScriptExecutionContext
+ virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
+
+ virtual void forwardException(const String& errorMessage, int lineNumber, const String& sourceURL);
+
// EventTarget
virtual DedicatedWorkerContext* toDedicatedWorkerContext() { return this; }
void postMessage(const String&, ExceptionCode&);
diff --git a/WebCore/workers/DedicatedWorkerThread.cpp b/WebCore/workers/DedicatedWorkerThread.cpp
index d4789a1..0905843 100644
--- a/WebCore/workers/DedicatedWorkerThread.cpp
+++ b/WebCore/workers/DedicatedWorkerThread.cpp
@@ -45,7 +45,7 @@ PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scri
}
DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy)
- : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy)
+ : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy)
, m_workerObjectProxy(workerObjectProxy)
{
}
diff --git a/WebCore/workers/DefaultSharedWorkerRepository.cpp b/WebCore/workers/DefaultSharedWorkerRepository.cpp
index e55d3e1..1c1ed4c 100644
--- a/WebCore/workers/DefaultSharedWorkerRepository.cpp
+++ b/WebCore/workers/DefaultSharedWorkerRepository.cpp
@@ -35,7 +35,6 @@
#include "DefaultSharedWorkerRepository.h"
#include "ActiveDOMObject.h"
-#include "Document.h"
#include "MessagePort.h"
#include "NotImplemented.h"
#include "PlatformString.h"
@@ -43,118 +42,52 @@
#include "SecurityOriginHash.h"
#include "SharedWorker.h"
#include "SharedWorkerContext.h"
-#include "SharedWorkerRepository.h"
#include "SharedWorkerThread.h"
#include "WorkerLoaderProxy.h"
-#include "WorkerReportingProxy.h"
#include "WorkerScriptLoader.h"
#include "WorkerScriptLoaderClient.h"
-#include <wtf/HashSet.h>
+
#include <wtf/Threading.h>
namespace WebCore {
-class SharedWorkerProxy : public ThreadSafeShared<SharedWorkerProxy>, public WorkerLoaderProxy, public WorkerReportingProxy {
+class SharedWorkerProxy : public ThreadSafeShared<SharedWorkerProxy>, public WorkerLoaderProxy {
public:
- static PassRefPtr<SharedWorkerProxy> create(const String& name, const KURL& url, PassRefPtr<SecurityOrigin> origin) { return adoptRef(new SharedWorkerProxy(name, url, origin)); }
+ static PassRefPtr<SharedWorkerProxy> create(const String& name, const KURL& url) { return adoptRef(new SharedWorkerProxy(name, url)); }
void setThread(PassRefPtr<SharedWorkerThread> thread) { m_thread = thread; }
SharedWorkerThread* thread() { return m_thread.get(); }
- bool isClosing() const { return m_closing; }
- void close();
+ bool closing() const { return m_closing; }
KURL url() const { return m_url.copy(); }
String name() const { return m_name.copy(); }
- bool matches(const String& name, PassRefPtr<SecurityOrigin> origin) const { return name == m_name && origin->equal(m_origin.get()); }
// WorkerLoaderProxy
// FIXME: Implement WorkerLoaderProxy APIs by proxying to an active document.
virtual void postTaskToLoader(PassRefPtr<ScriptExecutionContext::Task>) { notImplemented(); }
virtual void postTaskForModeToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>, const String&) { notImplemented(); }
- // WorkerReportingProxy
- virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL);
- virtual void postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL);
- virtual void workerContextClosed();
- virtual void workerContextDestroyed();
-
// Updates the list of the worker's documents, per section 4.5 of the WebWorkers spec.
void addToWorkerDocuments(ScriptExecutionContext*);
-
- bool isInWorkerDocuments(Document* document) { return m_workerDocuments.contains(document); }
-
- // Removes a detached document from the list of worker's documents. May set the closing flag if this is the last document in the list.
- void documentDetached(Document*);
-
private:
- SharedWorkerProxy(const String& name, const KURL&, PassRefPtr<SecurityOrigin>);
+ SharedWorkerProxy(const String& name, const KURL&);
bool m_closing;
String m_name;
KURL m_url;
- // The thread is freed when the proxy is destroyed, so we need to make sure that the proxy stays around until the SharedWorkerContext exits.
RefPtr<SharedWorkerThread> m_thread;
- RefPtr<SecurityOrigin> m_origin;
- HashSet<Document*> m_workerDocuments;
};
-SharedWorkerProxy::SharedWorkerProxy(const String& name, const KURL& url, PassRefPtr<SecurityOrigin> origin)
+SharedWorkerProxy::SharedWorkerProxy(const String& name, const KURL& url)
: m_closing(false)
, m_name(name.copy())
, m_url(url.copy())
- , m_origin(origin)
-{
- // We should be the sole owner of the SecurityOrigin, as we will free it on another thread.
- ASSERT(m_origin->hasOneRef());
-}
-
-void SharedWorkerProxy::postExceptionToWorkerObject(const String&, int, const String&)
-{
- // FIXME: Log exceptions to all parent documents.
- notImplemented();
-}
-
-void SharedWorkerProxy::postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String&, int, const String&)
{
- // FIXME: Log console messages to all parent documents.
- notImplemented();
-}
-
-void SharedWorkerProxy::workerContextClosed()
-{
- m_closing = true;
-}
-
-void SharedWorkerProxy::workerContextDestroyed()
-{
- // The proxy may be freed by this call, so do not reference it any further.
- DefaultSharedWorkerRepository::instance().removeProxy(this);
}
void SharedWorkerProxy::addToWorkerDocuments(ScriptExecutionContext* context)
{
// Nested workers are not yet supported, so passed-in context should always be a Document.
ASSERT(context->isDocument());
- ASSERT(!isClosing());
- Document* document = static_cast<Document*>(context);
- m_workerDocuments.add(document);
-}
-
-void SharedWorkerProxy::documentDetached(Document* document)
-{
- if (isClosing())
- return;
- // Remove the document from our set (if it's there) and if that was the last document in the set, mark the proxy as closed.
- m_workerDocuments.remove(document);
- if (!m_workerDocuments.size())
- close();
-}
-
-void SharedWorkerProxy::close()
-{
- ASSERT(!isClosing());
- m_closing = true;
- // Stop the worker thread - the proxy will stay around until we get workerThreadExited() notification.
- if (m_thread)
- m_thread->stop();
+ // FIXME: track referring documents so we can shutdown the thread when the last one exits and remove the proxy from the cache.
}
class SharedWorkerConnectTask : public ScriptExecutionContext::Task {
@@ -239,12 +172,12 @@ DefaultSharedWorkerRepository& DefaultSharedWorkerRepository::instance()
void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel> port)
{
MutexLocker lock(m_lock);
- if (proxy.isClosing())
+ if (proxy.closing())
return;
// Another loader may have already started up a thread for this proxy - if so, just send a connect to the pre-existing thread.
if (!proxy.thread()) {
- RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy, proxy);
+ RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy);
proxy.setThread(thread);
thread->start();
}
@@ -256,44 +189,6 @@ void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr
DefaultSharedWorkerRepository::instance().connectToWorker(worker, port, url, name, ec);
}
-void SharedWorkerRepository::documentDetached(Document* document)
-{
- DefaultSharedWorkerRepository::instance().documentDetached(document);
-}
-
-bool SharedWorkerRepository::hasSharedWorkers(Document* document)
-{
- return DefaultSharedWorkerRepository::instance().hasSharedWorkers(document);
-}
-
-bool DefaultSharedWorkerRepository::hasSharedWorkers(Document* document)
-{
- MutexLocker lock(m_lock);
- for (unsigned i = 0; i < m_proxies.size(); i++) {
- if (m_proxies[i]->isInWorkerDocuments(document))
- return true;
- }
- return false;
-}
-
-void DefaultSharedWorkerRepository::removeProxy(SharedWorkerProxy* proxy)
-{
- MutexLocker lock(m_lock);
- for (unsigned i = 0; i < m_proxies.size(); i++) {
- if (proxy == m_proxies[i].get()) {
- m_proxies.remove(i);
- return;
- }
- }
-}
-
-void DefaultSharedWorkerRepository::documentDetached(Document* document)
-{
- MutexLocker lock(m_lock);
- for (unsigned i = 0; i < m_proxies.size(); i++)
- m_proxies[i]->documentDetached(document);
-}
-
void DefaultSharedWorkerRepository::connectToWorker(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionCode& ec)
{
MutexLocker lock(m_lock);
@@ -321,14 +216,18 @@ PassRefPtr<SharedWorkerProxy> DefaultSharedWorkerRepository::getProxy(const Stri
// Look for an existing worker, and create one if it doesn't exist.
// Items in the cache are freed on another thread, so copy the URL before creating the origin, to make sure no references to external strings linger.
RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url.copy());
- for (unsigned i = 0; i < m_proxies.size(); i++) {
- if (!m_proxies[i]->isClosing() && m_proxies[i]->matches(name, origin))
- return m_proxies[i];
+ SharedWorkerNameMap* nameMap = m_cache.get(origin);
+ if (!nameMap) {
+ nameMap = new SharedWorkerNameMap();
+ m_cache.set(origin, nameMap);
+ }
+
+ RefPtr<SharedWorkerProxy> proxy = nameMap->get(name);
+ if (!proxy.get()) {
+ proxy = SharedWorkerProxy::create(name, url);
+ nameMap->set(proxy->name(), proxy);
}
- // Proxy is not in the repository currently - create a new one.
- RefPtr<SharedWorkerProxy> proxy = SharedWorkerProxy::create(name, url, origin.release());
- m_proxies.append(proxy);
- return proxy.release();
+ return proxy;
}
DefaultSharedWorkerRepository::DefaultSharedWorkerRepository()
diff --git a/WebCore/workers/DefaultSharedWorkerRepository.h b/WebCore/workers/DefaultSharedWorkerRepository.h
index c2eaff4..0b4e66c 100644
--- a/WebCore/workers/DefaultSharedWorkerRepository.h
+++ b/WebCore/workers/DefaultSharedWorkerRepository.h
@@ -33,24 +33,22 @@
#if ENABLE(SHARED_WORKERS)
-#include "ExceptionCode.h"
+#include "SharedWorkerRepository.h"
#include "StringHash.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Threading.h>
namespace WebCore {
- class Document;
class KURL;
- class MessagePortChannel;
class ScriptExecutionContext;
- class SharedWorker;
+ class SecurityOrigin;
class SharedWorkerProxy;
- class String;
+
+ struct SecurityOriginHash;
+ struct SecurityOriginTraits;
// Platform-specific implementation of the SharedWorkerRepository static interface.
class DefaultSharedWorkerRepository : public Noncopyable {
@@ -61,14 +59,6 @@ namespace WebCore {
// Internal implementation of SharedWorkerRepository::connect()
void connectToWorker(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionCode&);
- // Notification that a document has been detached.
- void documentDetached(Document*);
-
- // Removes the passed SharedWorkerProxy from the repository.
- void removeProxy(SharedWorkerProxy*);
-
- bool hasSharedWorkers(Document*);
-
static DefaultSharedWorkerRepository& instance();
private:
DefaultSharedWorkerRepository();
@@ -78,9 +68,11 @@ namespace WebCore {
// Mutex used to protect internal data structures.
Mutex m_lock;
- // List of shared workers. Expectation is that there will be a limited number of shared workers, and so tracking them in a Vector is more efficient than nested HashMaps.
- typedef Vector<RefPtr<SharedWorkerProxy> > SharedWorkerProxyRepository;
- SharedWorkerProxyRepository m_proxies;
+ typedef HashMap<String, RefPtr<SharedWorkerProxy> > SharedWorkerNameMap;
+ typedef HashMap<RefPtr<SecurityOrigin>, SharedWorkerNameMap*, SecurityOriginHash> SharedWorkerProxyCache;
+
+ // Items in this cache may be freed on another thread, so all keys and values must be either copied before insertion or thread safe.
+ SharedWorkerProxyCache m_cache;
};
} // namespace WebCore
diff --git a/WebCore/workers/SharedWorkerContext.cpp b/WebCore/workers/SharedWorkerContext.cpp
index ef35a60..2c50d94 100644
--- a/WebCore/workers/SharedWorkerContext.cpp
+++ b/WebCore/workers/SharedWorkerContext.cpp
@@ -39,6 +39,7 @@
#include "MessageEvent.h"
#include "NotImplemented.h"
#include "SharedWorkerThread.h"
+#include "WorkerObjectProxy.h"
namespace WebCore {
@@ -52,6 +53,17 @@ SharedWorkerContext::~SharedWorkerContext()
{
}
+void SharedWorkerContext::forwardException(const String&, int, const String&)
+{
+ // FIXME: forward to console (do not need to report to parent context).
+}
+
+void SharedWorkerContext::addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String&, unsigned, const String&)
+{
+ // FIXME: forward to console.
+ notImplemented();
+}
+
void SharedWorkerContext::dispatchConnect(PassRefPtr<MessagePort> port)
{
// Since close() stops the thread event loop, this should not ever get called while closing.
diff --git a/WebCore/workers/SharedWorkerContext.h b/WebCore/workers/SharedWorkerContext.h
index d6956cd..a7e4133 100644
--- a/WebCore/workers/SharedWorkerContext.h
+++ b/WebCore/workers/SharedWorkerContext.h
@@ -50,6 +50,11 @@ namespace WebCore {
virtual bool isSharedWorkerContext() const { return true; }
+ // ScriptExecutionContext
+ virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
+
+ virtual void forwardException(const String& errorMessage, int lineNumber, const String& sourceURL);
+
// EventTarget
virtual SharedWorkerContext* toSharedWorkerContext() { return this; }
diff --git a/WebCore/workers/SharedWorkerRepository.h b/WebCore/workers/SharedWorkerRepository.h
index 96d2fb1..84acf77 100644
--- a/WebCore/workers/SharedWorkerRepository.h
+++ b/WebCore/workers/SharedWorkerRepository.h
@@ -34,12 +34,12 @@
#if ENABLE(SHARED_WORKERS)
#include "ExceptionCode.h"
+
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
- class Document;
class KURL;
class MessagePortChannel;
class SharedWorker;
@@ -50,12 +50,6 @@ namespace WebCore {
public:
// Connects the passed SharedWorker object with the specified worker thread, creating a new thread if necessary.
static void connect(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionCode&);
-
- // Invoked when a document has been detached.
- static void documentDetached(Document*);
-
- // Returns true if the passed document is associated with any SharedWorkers.
- static bool hasSharedWorkers(Document*);
private:
SharedWorkerRepository() { }
};
diff --git a/WebCore/workers/SharedWorkerThread.cpp b/WebCore/workers/SharedWorkerThread.cpp
index ded4834..40bb2de 100644
--- a/WebCore/workers/SharedWorkerThread.cpp
+++ b/WebCore/workers/SharedWorkerThread.cpp
@@ -38,13 +38,13 @@
namespace WebCore {
-PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy)
+PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy)
{
- return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy));
+ return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy));
}
-SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy)
- : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy)
+SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy)
+ : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy)
, m_name(name.copy())
{
}
diff --git a/WebCore/workers/SharedWorkerThread.h b/WebCore/workers/SharedWorkerThread.h
index d96fd2a..15838d7 100644
--- a/WebCore/workers/SharedWorkerThread.h
+++ b/WebCore/workers/SharedWorkerThread.h
@@ -38,14 +38,14 @@ namespace WebCore {
class SharedWorkerThread : public WorkerThread {
public:
- static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&);
+ static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&);
~SharedWorkerThread();
protected:
virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String&);
private:
- SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&);
+ SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&);
String m_name;
};
diff --git a/WebCore/workers/Worker.cpp b/WebCore/workers/Worker.cpp
index d4d0e9b..a906134 100644
--- a/WebCore/workers/Worker.cpp
+++ b/WebCore/workers/Worker.cpp
@@ -58,7 +58,7 @@ Worker::Worker(const String& url, ScriptExecutionContext* context, ExceptionCode
return;
m_scriptLoader = new WorkerScriptLoader();
- m_scriptLoader->loadAsynchronously(scriptExecutionContext(), scriptURL, DenyCrossOriginRequests, this);
+ m_scriptLoader->loadAsynchronously(scriptExecutionContext(), scriptURL, DenyCrossOriginRedirect, this);
setPendingActivity(this); // The worker context does not exist while loading, so we must ensure that the worker object is not collected, as well as its event listeners.
}
diff --git a/WebCore/workers/WorkerContext.cpp b/WebCore/workers/WorkerContext.cpp
index 3cb1733..722588f 100644
--- a/WebCore/workers/WorkerContext.cpp
+++ b/WebCore/workers/WorkerContext.cpp
@@ -50,10 +50,6 @@
#include "XMLHttpRequestException.h"
#include <wtf/RefPtr.h>
-#if ENABLE(NOTIFICATIONS)
-#include "NotificationCenter.h"
-#endif
-
namespace WebCore {
WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread)
@@ -68,12 +64,6 @@ WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThr
WorkerContext::~WorkerContext()
{
- ASSERT(currentThread() == thread()->threadID());
-#if ENABLE(NOTIFICATIONS)
- m_notifications.clear();
-#endif
- // Notify proxy that we are going away. This can free the WorkerThread object, so do not access it after this.
- thread()->workerReportingProxy().workerContextDestroyed();
}
ScriptExecutionContext* WorkerContext::scriptExecutionContext() const
@@ -119,8 +109,6 @@ void WorkerContext::close()
return;
m_closing = true;
- // Notify parent that this context is closed.
- thread()->workerReportingProxy().workerContextClosed();
m_thread->stop();
}
@@ -256,7 +244,7 @@ void WorkerContext::importScripts(const Vector<String>& urls, const String& call
for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++it) {
WorkerScriptLoader scriptLoader;
- scriptLoader.loadSynchronously(scriptExecutionContext(), *it, AllowCrossOriginRequests);
+ scriptLoader.loadSynchronously(scriptExecutionContext(), *it, AllowCrossOriginRedirect);
// If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps.
if (scriptLoader.failed()) {
@@ -283,22 +271,8 @@ void WorkerContext::reportException(const String& errorMessage, int lineNumber,
errorHandled = onerror()->reportError(errorMessage, sourceURL, lineNumber);
if (!errorHandled)
- thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
-}
-
-void WorkerContext::addMessage(MessageDestination destination, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
-{
- thread()->workerReportingProxy().postConsoleMessageToWorkerObject(destination, source, type, level, message, lineNumber, sourceURL);
-}
-
-#if ENABLE(NOTIFICATIONS)
-NotificationCenter* WorkerContext::webkitNotifications() const
-{
- if (!m_notifications)
- m_notifications = NotificationCenter::create(scriptExecutionContext(), m_thread->getNotificationPresenter());
- return m_notifications.get();
+ forwardException(errorMessage, lineNumber, sourceURL);
}
-#endif
} // namespace WebCore
diff --git a/WebCore/workers/WorkerContext.h b/WebCore/workers/WorkerContext.h
index 2131a7c..aa47475 100644
--- a/WebCore/workers/WorkerContext.h
+++ b/WebCore/workers/WorkerContext.h
@@ -41,7 +41,6 @@
namespace WebCore {
- class NotificationCenter;
class ScheduledAction;
class WorkerLocation;
class WorkerNavigator;
@@ -49,6 +48,7 @@ namespace WebCore {
class WorkerContext : public RefCounted<WorkerContext>, public ScriptExecutionContext, public EventTarget {
public:
+
virtual ~WorkerContext();
virtual bool isWorkerContext() const { return true; }
@@ -103,11 +103,8 @@ namespace WebCore {
// ScriptExecutionContext
virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
- virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
-#if ENABLE(NOTIFICATIONS)
- NotificationCenter* webkitNotifications() const;
-#endif
+ virtual void forwardException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
// These methods are used for GC marking. See JSWorkerContext::markChildren(MarkStack&) in
// JSWorkerContextCustom.cpp.
@@ -142,9 +139,6 @@ namespace WebCore {
RefPtr<EventListener> m_onerrorListener;
EventListenersMap m_eventListeners;
-#if ENABLE_NOTIFICATIONS
- mutable RefPtr<NotificationCenter> m_notifications;
-#endif
bool m_closing;
};
diff --git a/WebCore/workers/WorkerContext.idl b/WebCore/workers/WorkerContext.idl
index 6a4a7fa..2404d22 100644
--- a/WebCore/workers/WorkerContext.idl
+++ b/WebCore/workers/WorkerContext.idl
@@ -69,10 +69,6 @@ module threads {
boolean dispatchEvent(in Event evt)
raises(EventException);
-#if defined(ENABLE_NOTIFICATIONS) && ENABLE_NOTIFICATIONS
- // Notification interface
- readonly attribute NotificationCenter webkitNotifications;
-#endif
// Constructors
attribute MessageEventConstructor MessageEvent;
@@ -81,9 +77,6 @@ module threads {
#if ENABLE_CHANNEL_MESSAGING
attribute [JSCCustomGetter] MessageChannelConstructor MessageChannel;
#endif
-#if ENABLE_EVENTSOURCE
- attribute [JSCCustomGetter] EventSourceConstructor EventSource;
-#endif
attribute [JSCCustomGetter] XMLHttpRequestConstructor XMLHttpRequest;
};
diff --git a/WebCore/workers/WorkerObjectProxy.h b/WebCore/workers/WorkerObjectProxy.h
index 586e7a0..c5f4456 100644
--- a/WebCore/workers/WorkerObjectProxy.h
+++ b/WebCore/workers/WorkerObjectProxy.h
@@ -33,24 +33,31 @@
#if ENABLE(WORKERS)
-#include "WorkerReportingProxy.h"
+#include "Console.h"
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class MessagePortChannel;
+ class String;
// A proxy to talk to the worker object.
- class WorkerObjectProxy : public WorkerReportingProxy {
+ class WorkerObjectProxy {
public:
+ virtual ~WorkerObjectProxy() {}
+
virtual void postMessageToWorkerObject(const String&, PassOwnPtr<MessagePortChannel>) = 0;
+ virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
+
+ virtual void postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL) = 0;
+
virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
+
virtual void reportPendingActivity(bool hasPendingActivity) = 0;
- // No need to notify the parent page context when dedicated workers are closing.
- virtual void workerContextClosed() { }
+ virtual void workerContextDestroyed() = 0;
};
} // namespace WebCore
diff --git a/WebCore/workers/WorkerReportingProxy.h b/WebCore/workers/WorkerReportingProxy.h
deleted file mode 100644
index f0447c8..0000000
--- a/WebCore/workers/WorkerReportingProxy.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2009 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER 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 WorkerReportingProxy_h
-#define WorkerReportingProxy_h
-
-#if ENABLE(WORKERS)
-
-#include "Console.h"
-
-namespace WebCore {
-
- class String;
-
- // APIs used by workers to report console activity.
- class WorkerReportingProxy {
- public:
- virtual ~WorkerReportingProxy() {}
-
- virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
-
- virtual void postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL) = 0;
-
- // Invoked when close() is invoked on the worker context.
- virtual void workerContextClosed() = 0;
-
- // Invoked when the thread has stopped.
- virtual void workerContextDestroyed() = 0;
- };
-} // namespace WebCore
-
-#endif // ENABLE(WORKERS)
-
-#endif // WorkerReportingProxy_h
diff --git a/WebCore/workers/WorkerScriptLoader.cpp b/WebCore/workers/WorkerScriptLoader.cpp
index 52baf2d..0162b26 100644
--- a/WebCore/workers/WorkerScriptLoader.cpp
+++ b/WebCore/workers/WorkerScriptLoader.cpp
@@ -50,7 +50,7 @@ WorkerScriptLoader::WorkerScriptLoader()
{
}
-void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy)
+void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const KURL& url, CrossOriginRedirectPolicy crossOriginRedirectPolicy)
{
m_url = url;
@@ -59,15 +59,10 @@ void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti
return;
ASSERT(scriptExecutionContext->isWorkerContext());
-
- ThreadableLoaderOptions options;
- options.allowCredentials = true;
- options.crossOriginRequestPolicy = crossOriginRequestPolicy;
-
- WorkerThreadableLoader::loadResourceSynchronously(static_cast<WorkerContext*>(scriptExecutionContext), *request, *this, options);
+ WorkerThreadableLoader::loadResourceSynchronously(static_cast<WorkerContext*>(scriptExecutionContext), *request, *this, AllowStoredCredentials, crossOriginRedirectPolicy);
}
-void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecutionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, WorkerScriptLoaderClient* client)
+void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecutionContext, const KURL& url, CrossOriginRedirectPolicy crossOriginRedirectPolicy, WorkerScriptLoaderClient* client)
{
ASSERT(client);
m_client = client;
@@ -77,11 +72,7 @@ void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecut
if (!request)
return;
- ThreadableLoaderOptions options;
- options.allowCredentials = true;
- options.crossOriginRequestPolicy = crossOriginRequestPolicy;
-
- m_threadableLoader = ThreadableLoader::create(scriptExecutionContext, this, *request, options);
+ m_threadableLoader = ThreadableLoader::create(scriptExecutionContext, this, *request, DoNotSendLoadCallbacks, DoNotSniffContent, AllowStoredCredentials, crossOriginRedirectPolicy);
}
PassOwnPtr<ResourceRequest> WorkerScriptLoader::createResourceRequest()
diff --git a/WebCore/workers/WorkerScriptLoader.h b/WebCore/workers/WorkerScriptLoader.h
index 47623f6..2924ec8 100644
--- a/WebCore/workers/WorkerScriptLoader.h
+++ b/WebCore/workers/WorkerScriptLoader.h
@@ -46,8 +46,8 @@ namespace WebCore {
public:
WorkerScriptLoader();
- void loadSynchronously(ScriptExecutionContext*, const KURL&, CrossOriginRequestPolicy);
- void loadAsynchronously(ScriptExecutionContext*, const KURL&, CrossOriginRequestPolicy, WorkerScriptLoaderClient*);
+ void loadSynchronously(ScriptExecutionContext*, const KURL&, CrossOriginRedirectPolicy);
+ void loadAsynchronously(ScriptExecutionContext*, const KURL&, CrossOriginRedirectPolicy, WorkerScriptLoaderClient*);
void notifyError();
diff --git a/WebCore/workers/WorkerThread.cpp b/WebCore/workers/WorkerThread.cpp
index 752c178..86a5fa8 100644
--- a/WebCore/workers/WorkerThread.cpp
+++ b/WebCore/workers/WorkerThread.cpp
@@ -61,10 +61,9 @@ WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const St
{
}
-WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy)
+WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy)
: m_threadID(0)
, m_workerLoaderProxy(workerLoaderProxy)
- , m_workerReportingProxy(workerReportingProxy)
, m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode))
{
}
diff --git a/WebCore/workers/WorkerThread.h b/WebCore/workers/WorkerThread.h
index 5d861e1..a6b22dc 100644
--- a/WebCore/workers/WorkerThread.h
+++ b/WebCore/workers/WorkerThread.h
@@ -37,11 +37,9 @@
namespace WebCore {
class KURL;
- class NotificationPresenter;
class String;
class WorkerContext;
class WorkerLoaderProxy;
- class WorkerReportingProxy;
struct WorkerThreadStartupData;
class WorkerThread : public RefCounted<WorkerThread> {
@@ -54,10 +52,9 @@ namespace WebCore {
ThreadIdentifier threadID() const { return m_threadID; }
WorkerRunLoop& runLoop() { return m_runLoop; }
WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
- WorkerReportingProxy& workerReportingProxy() const { return m_workerReportingProxy; }
protected:
- WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&);
+ WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&);
// Factory method for creating a new worker context for the thread.
virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL& url, const String& userAgent) = 0;
@@ -67,11 +64,6 @@ namespace WebCore {
WorkerContext* workerContext() { return m_workerContext.get(); }
-#if ENABLE(NOTIFICATIONS)
- NotificationPresenter* getNotificationPresenter() { return m_notificationPresenter; }
- void setNotificationPresenter(NotificationPresenter* presenter) { m_notificationPresenter = presenter; }
-#endif
-
private:
// Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
static void* workerThreadStart(void*);
@@ -80,16 +72,11 @@ namespace WebCore {
ThreadIdentifier m_threadID;
WorkerRunLoop m_runLoop;
WorkerLoaderProxy& m_workerLoaderProxy;
- WorkerReportingProxy& m_workerReportingProxy;
RefPtr<WorkerContext> m_workerContext;
Mutex m_threadCreationMutex;
OwnPtr<WorkerThreadStartupData> m_startupData;
-
-#if ENABLE(NOTIFICATIONS)
- NotificationPresenter* m_notificationPresenter;
-#endif
};
} // namespace WebCore