summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp b/src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp
index e955f24..11106ee 100644
--- a/src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp
+++ b/src/3rdparty/webkit/WebCore/workers/DefaultSharedWorkerRepository.cpp
@@ -37,6 +37,7 @@
#include "ActiveDOMObject.h"
#include "Document.h"
#include "GenericWorkerTask.h"
+#include "MessageEvent.h"
#include "MessagePort.h"
#include "NotImplemented.h"
#include "PlatformString.h"
@@ -64,7 +65,7 @@ public:
bool isClosing() 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()); }
+ bool matches(const String& name, PassRefPtr<SecurityOrigin> origin, const KURL& urlToMatch) const;
// WorkerLoaderProxy
virtual void postTaskToLoader(PassRefPtr<ScriptExecutionContext::Task>);
@@ -109,6 +110,19 @@ SharedWorkerProxy::SharedWorkerProxy(const String& name, const KURL& url, PassRe
ASSERT(m_origin->hasOneRef());
}
+bool SharedWorkerProxy::matches(const String& name, PassRefPtr<SecurityOrigin> origin, const KURL& urlToMatch) const
+{
+ // If the origins don't match, or the names don't match, then this is not the proxy we are looking for.
+ if (!origin->equal(m_origin.get()))
+ return false;
+
+ // If the names are both empty, compares the URLs instead per the Web Workers spec.
+ if (name.isEmpty() && m_name.isEmpty())
+ return urlToMatch == url();
+
+ return name == m_name;
+}
+
void SharedWorkerProxy::postTaskToLoader(PassRefPtr<ScriptExecutionContext::Task> task)
{
MutexLocker lock(m_workerDocumentsLock);
@@ -219,8 +233,10 @@ private:
port->entangle(m_channel.release());
ASSERT(scriptContext->isWorkerContext());
WorkerContext* workerContext = static_cast<WorkerContext*>(scriptContext);
+ // Since close() stops the thread event loop, this should not ever get called while closing.
+ ASSERT(!workerContext->isClosing());
ASSERT(workerContext->isSharedWorkerContext());
- workerContext->toSharedWorkerContext()->dispatchConnect(port);
+ workerContext->toSharedWorkerContext()->dispatchEvent(createConnectEvent(port));
}
OwnPtr<MessagePortChannel> m_channel;
@@ -259,18 +275,19 @@ void SharedWorkerScriptLoader::load(const KURL& url)
// Stay alive until the load finishes.
setPendingActivity(this);
+ m_worker->setPendingActivity(m_worker.get());
}
void SharedWorkerScriptLoader::notifyFinished()
{
// Hand off the just-loaded code to the repository to start up the worker thread.
if (m_scriptLoader->failed())
- m_worker->dispatchLoadErrorEvent();
+ m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true));
else
DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), m_port.release());
- // This frees this object - must be the last action in this function.
- unsetPendingActivity(this);
+ m_worker->unsetPendingActivity(m_worker.get());
+ unsetPendingActivity(this); // This frees this object - must be the last action in this function.
}
DefaultSharedWorkerRepository& DefaultSharedWorkerRepository::instance()
@@ -365,7 +382,7 @@ PassRefPtr<SharedWorkerProxy> DefaultSharedWorkerRepository::getProxy(const Stri
// 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))
+ if (!m_proxies[i]->isClosing() && m_proxies[i]->matches(name, origin, url))
return m_proxies[i];
}
// Proxy is not in the repository currently - create a new one.