This source file includes following definitions.
- m_channel
- connect
- connected
- scriptLoadFailed
- getId
- connect
- documentDetached
#include "config.h"
#include "SharedWorkerRepositoryClientImpl.h"
#include "WebContentSecurityPolicy.h"
#include "WebFrameClient.h"
#include "WebFrameImpl.h"
#include "WebKit.h"
#include "WebSharedWorker.h"
#include "WebSharedWorkerRepositoryClient.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
#include "core/events/Event.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/workers/SharedWorker.h"
#include "core/workers/WorkerScriptLoader.h"
#include "core/workers/WorkerScriptLoaderClient.h"
#include "platform/network/ResourceResponse.h"
#include "public/platform/WebMessagePortChannel.h"
#include "public/platform/WebString.h"
#include "public/platform/WebURL.h"
using namespace WebCore;
namespace blink {
class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener {
public:
SharedWorkerConnector(PassRefPtrWillBeRawPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPtr<WebSharedWorkerConnector> webWorkerConnector)
: m_worker(worker)
, m_url(url)
, m_name(name)
, m_webWorkerConnector(webWorkerConnector)
, m_channel(channel) { }
virtual ~SharedWorkerConnector();
void connect();
private:
virtual void connected() OVERRIDE;
virtual void scriptLoadFailed() OVERRIDE;
RefPtrWillBePersistent<SharedWorker> m_worker;
KURL m_url;
String m_name;
OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector;
OwnPtr<WebMessagePortChannel> m_channel;
};
SharedWorkerConnector::~SharedWorkerConnector()
{
m_worker->unsetPreventGC();
}
void SharedWorkerConnector::connect()
{
m_worker->setPreventGC();
m_webWorkerConnector->connect(m_channel.leakPtr(), this);
}
void SharedWorkerConnector::connected()
{
delete this;
}
void SharedWorkerConnector::scriptLoadFailed()
{
m_worker->dispatchEvent(Event::createCancelable(EventTypeNames::error));
delete this;
}
static WebSharedWorkerRepositoryClient::DocumentID getId(void* document)
{
ASSERT(document);
return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(document);
}
void SharedWorkerRepositoryClientImpl::connect(PassRefPtrWillBeRawPtr<SharedWorker> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const String& name, ExceptionState& exceptionState)
{
ASSERT(m_client);
ASSERT(worker->executionContext()->isDocument());
Document* document = toDocument(worker->executionContext());
OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->createSharedWorkerConnector(url, name, getId(document), worker->executionContext()->contentSecurityPolicy()->deprecatedHeader(), static_cast<blink::WebContentSecurityPolicyType>(worker->executionContext()->contentSecurityPolicy()->deprecatedHeaderType())));
if (!webWorkerConnector) {
exceptionState.throwDOMException(URLMismatchError, "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL ('" + url.elidedString() + "').");
return;
}
SharedWorkerConnector* connector = new SharedWorkerConnector(worker, url, name, port, webWorkerConnector.release());
connector->connect();
}
void SharedWorkerRepositoryClientImpl::documentDetached(Document* document)
{
ASSERT(m_client);
m_client->documentDetached(getId(document));
}
SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWorkerRepositoryClient* client)
: m_client(client)
{
}
}