[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d
eric at webkit.org
eric at webkit.org
Thu Dec 3 13:31:07 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit f847c40c1541e7f068bd5cdc10d6daddd24303b9
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 10 18:49:07 2009 +0000
2009-11-10 Yaar Schnitman <yaar at chromium.org>
Reviewed by Dimitri Glazkov.
Up-streaming Chromium API src files: NotificationPresenterImpl...SharedWorkerRepository
https://bugs.webkit.org/show_bug.cgi?id=31276
* src/NotificationPresenterImpl.cpp: Added.
(WebKit::VoidCallbackClient::VoidCallbackClient):
(WebKit::VoidCallbackClient::permissionRequestComplete):
(WebKit::NotificationPresenterImpl::initialize):
(WebKit::NotificationPresenterImpl::isInitialized):
(WebKit::NotificationPresenterImpl::show):
(WebKit::NotificationPresenterImpl::cancel):
(WebKit::NotificationPresenterImpl::notificationObjectDestroyed):
(WebKit::NotificationPresenterImpl::checkPermission):
(WebKit::NotificationPresenterImpl::requestPermission):
* src/NotificationPresenterImpl.h: Added.
(WebKit::NotificationPresenterImpl::NotificationPresenterImpl):
* src/PlatformMessagePortChannel.cpp: Added.
(WebCore::MessagePortChannel::create):
(WebCore::MessagePortChannel::createChannel):
(WebCore::MessagePortChannel::MessagePortChannel):
(WebCore::MessagePortChannel::~MessagePortChannel):
(WebCore::MessagePortChannel::entangleIfOpen):
(WebCore::MessagePortChannel::disentangle):
(WebCore::MessagePortChannel::postMessageToRemote):
(WebCore::MessagePortChannel::tryGetMessageFromRemote):
(WebCore::MessagePortChannel::close):
(WebCore::MessagePortChannel::isConnectedTo):
(WebCore::MessagePortChannel::hasPendingActivity):
(WebCore::MessagePortChannel::locallyEntangledPort):
(WebCore::PlatformMessagePortChannel::create):
(WebCore::PlatformMessagePortChannel::PlatformMessagePortChannel):
(WebCore::PlatformMessagePortChannel::~PlatformMessagePortChannel):
(WebCore::PlatformMessagePortChannel::createChannel):
(WebCore::PlatformMessagePortChannel::messageAvailable):
(WebCore::PlatformMessagePortChannel::entangleIfOpen):
(WebCore::PlatformMessagePortChannel::disentangle):
(WebCore::PlatformMessagePortChannel::postMessageToRemote):
(WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote):
(WebCore::PlatformMessagePortChannel::close):
(WebCore::PlatformMessagePortChannel::isConnectedTo):
(WebCore::PlatformMessagePortChannel::hasPendingActivity):
(WebCore::PlatformMessagePortChannel::setEntangledChannel):
(WebCore::PlatformMessagePortChannel::webChannelRelease):
* src/PlatformMessagePortChannel.h: Added.
* src/ResourceHandle.cpp: Added.
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
(WebCore::ResourceHandleInternal::start):
(WebCore::ResourceHandleInternal::cancel):
(WebCore::ResourceHandleInternal::setDefersLoading):
(WebCore::ResourceHandleInternal::allowStoredCredentials):
(WebCore::ResourceHandleInternal::willSendRequest):
(WebCore::ResourceHandleInternal::didSendData):
(WebCore::ResourceHandleInternal::didReceiveResponse):
(WebCore::ResourceHandleInternal::didReceiveData):
(WebCore::ResourceHandleInternal::didFinishLoading):
(WebCore::ResourceHandleInternal::didFail):
(WebCore::ResourceHandle::ResourceHandle):
(WebCore::ResourceHandle::create):
(WebCore::ResourceHandle::request):
(WebCore::ResourceHandle::client):
(WebCore::ResourceHandle::setClient):
(WebCore::ResourceHandle::setDefersLoading):
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::clearAuthentication):
(WebCore::ResourceHandle::cancel):
(WebCore::ResourceHandle::~ResourceHandle):
(WebCore::ResourceHandle::bufferedData):
(WebCore::ResourceHandle::loadsBlocked):
(WebCore::ResourceHandle::supportsBufferedData):
(WebCore::ResourceHandle::loadResourceSynchronously):
(WebCore::ResourceHandle::willLoadFromCache):
* src/SharedWorkerRepository.cpp: Added.
(WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader):
(WebCore::SharedWorkerScriptLoader::load):
(WebCore::getWebPort):
(WebCore::SharedWorkerScriptLoader::notifyFinished):
(WebCore::SharedWorkerScriptLoader::sendConnect):
(WebCore::SharedWorkerScriptLoader::contextDestroyed):
(WebCore::SharedWorkerScriptLoader::connected):
(WebCore::SharedWorkerRepository::isAvailable):
(WebCore::getId):
(WebCore::SharedWorkerRepository::connect):
(WebCore::SharedWorkerRepository::documentDetached):
(WebCore::SharedWorkerRepository::hasSharedWorkers):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 2ab78c9..0b88d29 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -2,6 +2,95 @@
Reviewed by Dimitri Glazkov.
+ Up-streaming Chromium API src files: NotificationPresenterImpl...SharedWorkerRepository
+
+ https://bugs.webkit.org/show_bug.cgi?id=31276
+
+ * src/NotificationPresenterImpl.cpp: Added.
+ (WebKit::VoidCallbackClient::VoidCallbackClient):
+ (WebKit::VoidCallbackClient::permissionRequestComplete):
+ (WebKit::NotificationPresenterImpl::initialize):
+ (WebKit::NotificationPresenterImpl::isInitialized):
+ (WebKit::NotificationPresenterImpl::show):
+ (WebKit::NotificationPresenterImpl::cancel):
+ (WebKit::NotificationPresenterImpl::notificationObjectDestroyed):
+ (WebKit::NotificationPresenterImpl::checkPermission):
+ (WebKit::NotificationPresenterImpl::requestPermission):
+ * src/NotificationPresenterImpl.h: Added.
+ (WebKit::NotificationPresenterImpl::NotificationPresenterImpl):
+ * src/PlatformMessagePortChannel.cpp: Added.
+ (WebCore::MessagePortChannel::create):
+ (WebCore::MessagePortChannel::createChannel):
+ (WebCore::MessagePortChannel::MessagePortChannel):
+ (WebCore::MessagePortChannel::~MessagePortChannel):
+ (WebCore::MessagePortChannel::entangleIfOpen):
+ (WebCore::MessagePortChannel::disentangle):
+ (WebCore::MessagePortChannel::postMessageToRemote):
+ (WebCore::MessagePortChannel::tryGetMessageFromRemote):
+ (WebCore::MessagePortChannel::close):
+ (WebCore::MessagePortChannel::isConnectedTo):
+ (WebCore::MessagePortChannel::hasPendingActivity):
+ (WebCore::MessagePortChannel::locallyEntangledPort):
+ (WebCore::PlatformMessagePortChannel::create):
+ (WebCore::PlatformMessagePortChannel::PlatformMessagePortChannel):
+ (WebCore::PlatformMessagePortChannel::~PlatformMessagePortChannel):
+ (WebCore::PlatformMessagePortChannel::createChannel):
+ (WebCore::PlatformMessagePortChannel::messageAvailable):
+ (WebCore::PlatformMessagePortChannel::entangleIfOpen):
+ (WebCore::PlatformMessagePortChannel::disentangle):
+ (WebCore::PlatformMessagePortChannel::postMessageToRemote):
+ (WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote):
+ (WebCore::PlatformMessagePortChannel::close):
+ (WebCore::PlatformMessagePortChannel::isConnectedTo):
+ (WebCore::PlatformMessagePortChannel::hasPendingActivity):
+ (WebCore::PlatformMessagePortChannel::setEntangledChannel):
+ (WebCore::PlatformMessagePortChannel::webChannelRelease):
+ * src/PlatformMessagePortChannel.h: Added.
+ * src/ResourceHandle.cpp: Added.
+ (WebCore::ResourceHandleInternal::ResourceHandleInternal):
+ (WebCore::ResourceHandleInternal::start):
+ (WebCore::ResourceHandleInternal::cancel):
+ (WebCore::ResourceHandleInternal::setDefersLoading):
+ (WebCore::ResourceHandleInternal::allowStoredCredentials):
+ (WebCore::ResourceHandleInternal::willSendRequest):
+ (WebCore::ResourceHandleInternal::didSendData):
+ (WebCore::ResourceHandleInternal::didReceiveResponse):
+ (WebCore::ResourceHandleInternal::didReceiveData):
+ (WebCore::ResourceHandleInternal::didFinishLoading):
+ (WebCore::ResourceHandleInternal::didFail):
+ (WebCore::ResourceHandle::ResourceHandle):
+ (WebCore::ResourceHandle::create):
+ (WebCore::ResourceHandle::request):
+ (WebCore::ResourceHandle::client):
+ (WebCore::ResourceHandle::setClient):
+ (WebCore::ResourceHandle::setDefersLoading):
+ (WebCore::ResourceHandle::start):
+ (WebCore::ResourceHandle::clearAuthentication):
+ (WebCore::ResourceHandle::cancel):
+ (WebCore::ResourceHandle::~ResourceHandle):
+ (WebCore::ResourceHandle::bufferedData):
+ (WebCore::ResourceHandle::loadsBlocked):
+ (WebCore::ResourceHandle::supportsBufferedData):
+ (WebCore::ResourceHandle::loadResourceSynchronously):
+ (WebCore::ResourceHandle::willLoadFromCache):
+ * src/SharedWorkerRepository.cpp: Added.
+ (WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader):
+ (WebCore::SharedWorkerScriptLoader::load):
+ (WebCore::getWebPort):
+ (WebCore::SharedWorkerScriptLoader::notifyFinished):
+ (WebCore::SharedWorkerScriptLoader::sendConnect):
+ (WebCore::SharedWorkerScriptLoader::contextDestroyed):
+ (WebCore::SharedWorkerScriptLoader::connected):
+ (WebCore::SharedWorkerRepository::isAvailable):
+ (WebCore::getId):
+ (WebCore::SharedWorkerRepository::connect):
+ (WebCore::SharedWorkerRepository::documentDetached):
+ (WebCore::SharedWorkerRepository::hasSharedWorkers):
+
+2009-11-10 Yaar Schnitman <yaar at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
Up-streaming Chromium API src files: GraphicContext3D...MediaPlaterPrivateChromium
https://bugs.webkit.org/show_bug.cgi?id=31276
diff --git a/WebKit/chromium/src/NotificationPresenterImpl.cpp b/WebKit/chromium/src/NotificationPresenterImpl.cpp
new file mode 100644
index 0000000..6b22319
--- /dev/null
+++ b/WebKit/chromium/src/NotificationPresenterImpl.cpp
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "NotificationPresenterImpl.h"
+
+#if ENABLE(NOTIFICATIONS)
+
+#include "Notification.h"
+#include "SecurityOrigin.h"
+
+#include "WebNotification.h"
+#include "WebNotificationPermissionCallback.h"
+#include "WebNotificationPresenter.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class VoidCallbackClient : public WebNotificationPermissionCallback {
+public:
+ VoidCallbackClient(PassRefPtr<VoidCallback> callback)
+ : m_callback(callback)
+ {
+ }
+
+ virtual void permissionRequestComplete()
+ {
+ if (m_callback)
+ m_callback->handleEvent();
+ delete this;
+ }
+
+private:
+ RefPtr<VoidCallback> m_callback;
+};
+
+void NotificationPresenterImpl::initialize(WebNotificationPresenter* presenter)
+{
+ m_presenter = presenter;
+}
+
+bool NotificationPresenterImpl::isInitialized()
+{
+ return !!m_presenter;
+}
+
+bool NotificationPresenterImpl::show(Notification* notification)
+{
+ return m_presenter->show(PassRefPtr<Notification>(notification));
+}
+
+void NotificationPresenterImpl::cancel(Notification* notification)
+{
+ m_presenter->cancel(PassRefPtr<Notification>(notification));
+}
+
+void NotificationPresenterImpl::notificationObjectDestroyed(Notification* notification)
+{
+ m_presenter->objectDestroyed(PassRefPtr<Notification>(notification));
+}
+
+NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(SecurityOrigin* origin)
+{
+ int result = m_presenter->checkPermission(origin->toString());
+ return static_cast<NotificationPresenter::Permission>(result);
+}
+
+void NotificationPresenterImpl::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback)
+{
+ m_presenter->requestPermission(origin->toString(), new VoidCallbackClient(callback));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS)
diff --git a/WebKit/chromium/src/NotificationPresenterImpl.h b/WebKit/chromium/src/NotificationPresenterImpl.h
new file mode 100644
index 0000000..4afe9dc
--- /dev/null
+++ b/WebKit/chromium/src/NotificationPresenterImpl.h
@@ -0,0 +1,69 @@
+/*
+ * 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 NotificationPresenterImpl_h
+#define NotificationPresenterImpl_h
+
+#include "NotificationPresenter.h"
+#include "VoidCallback.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+#if ENABLE(NOTIFICATIONS)
+
+namespace WebKit {
+
+class WebNotificationPresenter;
+
+class NotificationPresenterImpl : public WebCore::NotificationPresenter {
+public:
+ NotificationPresenterImpl() : m_presenter(0) { }
+
+ void initialize(WebNotificationPresenter* presenter);
+ bool isInitialized();
+
+ // WebCore::NotificationPresenter implementation.
+ virtual bool show(WebCore::Notification* object);
+ virtual void cancel(WebCore::Notification* object);
+ virtual void notificationObjectDestroyed(WebCore::Notification* object);
+ virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::SecurityOrigin* origin);
+ virtual void requestPermission(WebCore::SecurityOrigin* origin, WTF::PassRefPtr<WebCore::VoidCallback> callback);
+
+private:
+ // WebNotificationPresenter that this object delegates to.
+ WebNotificationPresenter* m_presenter;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS)
+
+#endif
diff --git a/WebKit/chromium/src/PlatformMessagePortChannel.cpp b/WebKit/chromium/src/PlatformMessagePortChannel.cpp
new file mode 100644
index 0000000..f8c41d3
--- /dev/null
+++ b/WebKit/chromium/src/PlatformMessagePortChannel.cpp
@@ -0,0 +1,258 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "PlatformMessagePortChannel.h"
+
+#include "MessagePort.h"
+#include "ScriptExecutionContext.h"
+#include "SerializedScriptValue.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMessagePortChannel.h"
+#include "WebString.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+PassOwnPtr<MessagePortChannel> MessagePortChannel::create(PassRefPtr<PlatformMessagePortChannel> channel)
+{
+ return new MessagePortChannel(channel);
+}
+
+void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2)
+{
+ PlatformMessagePortChannel::createChannel(port1, port2);
+}
+
+MessagePortChannel::MessagePortChannel(PassRefPtr<PlatformMessagePortChannel> channel)
+ : m_channel(channel)
+{
+}
+
+MessagePortChannel::~MessagePortChannel()
+{
+ // Make sure we close our platform channel when the base is freed, to keep the channel objects from leaking.
+ m_channel->close();
+}
+
+bool MessagePortChannel::entangleIfOpen(MessagePort* port)
+{
+ return m_channel->entangleIfOpen(port);
+}
+
+void MessagePortChannel::disentangle()
+{
+ m_channel->disentangle();
+}
+
+void MessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message)
+{
+ m_channel->postMessageToRemote(message);
+}
+
+bool MessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>& result)
+{
+ return m_channel->tryGetMessageFromRemote(result);
+}
+
+void MessagePortChannel::close()
+{
+ m_channel->close();
+}
+
+bool MessagePortChannel::isConnectedTo(MessagePort* port)
+{
+ return m_channel->isConnectedTo(port);
+}
+
+bool MessagePortChannel::hasPendingActivity()
+{
+ return m_channel->hasPendingActivity();
+}
+
+MessagePort* MessagePortChannel::locallyEntangledPort(const ScriptExecutionContext* context)
+{
+ // This is just an optimization, so return 0 always.
+ return 0;
+}
+
+
+PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create()
+{
+ return adoptRef(new PlatformMessagePortChannel());
+}
+
+PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create(
+ WebMessagePortChannel* channel)
+{
+ return adoptRef(new PlatformMessagePortChannel(channel));
+}
+
+
+PlatformMessagePortChannel::PlatformMessagePortChannel()
+ : m_localPort(0)
+{
+ m_webChannel = webKitClient()->createMessagePortChannel();
+ if (m_webChannel)
+ m_webChannel->setClient(this);
+}
+
+PlatformMessagePortChannel::PlatformMessagePortChannel(WebMessagePortChannel* channel)
+ : m_localPort(0)
+ , m_webChannel(channel)
+{
+}
+
+PlatformMessagePortChannel::~PlatformMessagePortChannel()
+{
+ if (m_webChannel)
+ m_webChannel->destroy();
+}
+
+void PlatformMessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2)
+{
+ // Create proxies for each endpoint.
+ RefPtr<PlatformMessagePortChannel> channel1 = PlatformMessagePortChannel::create();
+ RefPtr<PlatformMessagePortChannel> channel2 = PlatformMessagePortChannel::create();
+
+ // Entangle the two endpoints.
+ channel1->setEntangledChannel(channel2);
+ channel2->setEntangledChannel(channel1);
+
+ // Now entangle the proxies with the appropriate local ports.
+ port1->entangle(MessagePortChannel::create(channel2));
+ port2->entangle(MessagePortChannel::create(channel1));
+}
+
+void PlatformMessagePortChannel::messageAvailable()
+{
+ MutexLocker lock(m_mutex);
+ if (m_localPort)
+ m_localPort->messageAvailable();
+}
+
+bool PlatformMessagePortChannel::entangleIfOpen(MessagePort* port)
+{
+ MutexLocker lock(m_mutex);
+ m_localPort = port;
+ return true;
+}
+
+void PlatformMessagePortChannel::disentangle()
+{
+ MutexLocker lock(m_mutex);
+ m_localPort = 0;
+}
+
+void PlatformMessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message)
+{
+ if (!m_localPort || !m_webChannel)
+ return;
+
+ WebString messageString = message->message()->toString();
+ OwnPtr<WebCore::MessagePortChannelArray> channels = message->channels();
+ WebMessagePortChannelArray* webChannels = 0;
+ if (channels.get() && channels->size()) {
+ webChannels = new WebMessagePortChannelArray(channels->size());
+ for (size_t i = 0; i < channels->size(); ++i) {
+ WebCore::PlatformMessagePortChannel* platformChannel = (*channels)[i]->channel();
+ (*webChannels)[i] = platformChannel->webChannelRelease();
+ (*webChannels)[i]->setClient(0);
+ }
+ }
+ m_webChannel->postMessage(messageString, webChannels);
+}
+
+bool PlatformMessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>& result)
+{
+ if (!m_webChannel)
+ return false;
+
+ WebString message;
+ WebMessagePortChannelArray webChannels;
+ bool rv = m_webChannel->tryGetMessage(&message, webChannels);
+ if (rv) {
+ OwnPtr<MessagePortChannelArray> channels;
+ if (webChannels.size()) {
+ channels = new MessagePortChannelArray(webChannels.size());
+ for (size_t i = 0; i < webChannels.size(); ++i) {
+ RefPtr<PlatformMessagePortChannel> platformChannel = create(webChannels[i]);
+ webChannels[i]->setClient(platformChannel.get());
+ (*channels)[i] = MessagePortChannel::create(platformChannel);
+ }
+ }
+ RefPtr<SerializedScriptValue> serializedMessage = SerializedScriptValue::create(message);
+ result = MessagePortChannel::EventData::create(serializedMessage.release(), channels.release());
+ }
+
+ return rv;
+}
+
+void PlatformMessagePortChannel::close()
+{
+ MutexLocker lock(m_mutex);
+ // Disentangle ourselves from the other end. We still maintain a reference to m_webChannel,
+ // since previously-existing messages should still be delivered.
+ m_localPort = 0;
+ m_entangledChannel = 0;
+}
+
+bool PlatformMessagePortChannel::isConnectedTo(MessagePort* port)
+{
+ MutexLocker lock(m_mutex);
+ return m_entangledChannel && m_entangledChannel->m_localPort == port;
+}
+
+bool PlatformMessagePortChannel::hasPendingActivity()
+{
+ MutexLocker lock(m_mutex);
+ return m_localPort;
+}
+
+void PlatformMessagePortChannel::setEntangledChannel(PassRefPtr<PlatformMessagePortChannel> remote)
+{
+ if (m_webChannel)
+ m_webChannel->entangle(remote->m_webChannel);
+
+ MutexLocker lock(m_mutex);
+ m_entangledChannel = remote;
+}
+
+WebMessagePortChannel* PlatformMessagePortChannel::webChannelRelease()
+{
+ WebMessagePortChannel* rv = m_webChannel;
+ m_webChannel = 0;
+ return rv;
+}
+
+} // namespace WebCore
diff --git a/WebKit/chromium/src/PlatformMessagePortChannel.h b/WebKit/chromium/src/PlatformMessagePortChannel.h
new file mode 100644
index 0000000..05e8397
--- /dev/null
+++ b/WebKit/chromium/src/PlatformMessagePortChannel.h
@@ -0,0 +1,96 @@
+/*
+ * 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 PlatformMessagePortChannel_h
+#define PlatformMessagePortChannel_h
+
+// FIXME: This relative path is a temporary hack to support using this
+// header from webkit/glue.
+#include "../public/WebMessagePortChannelClient.h"
+
+#include "MessagePortChannel.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
+
+namespace WebKit {
+class WebMessagePortChannel;
+}
+
+namespace WebCore {
+
+class MessagePort;
+
+// PlatformMessagePortChannel is a platform-dependent interface to the remote side of a message channel.
+class PlatformMessagePortChannel : public ThreadSafeShared<PlatformMessagePortChannel>,
+ public WebKit::WebMessagePortChannelClient {
+public:
+ static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>);
+ static PassRefPtr<PlatformMessagePortChannel> create();
+ static PassRefPtr<PlatformMessagePortChannel> create(WebKit::WebMessagePortChannel*);
+
+ // APIs delegated from MessagePortChannel.h
+ bool entangleIfOpen(MessagePort*);
+ void disentangle();
+ void postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData>);
+ bool tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>&);
+ void close();
+ bool isConnectedTo(MessagePort* port);
+ bool hasPendingActivity();
+
+ // Releases ownership of the contained web channel.
+ WebKit::WebMessagePortChannel* webChannelRelease();
+
+ ~PlatformMessagePortChannel();
+
+private:
+ PlatformMessagePortChannel();
+ PlatformMessagePortChannel(WebKit::WebMessagePortChannel*);
+
+ void setEntangledChannel(PassRefPtr<PlatformMessagePortChannel>);
+
+ // WebKit::WebMessagePortChannelClient implementation
+ virtual void messageAvailable();
+
+ // Mutex used to ensure exclusive access to the object internals.
+ Mutex m_mutex;
+
+ // Pointer to our entangled pair - cleared when close() is called.
+ RefPtr<PlatformMessagePortChannel> m_entangledChannel;
+
+ // The port we are connected to - this is the port that is notified when new messages arrive.
+ MessagePort* m_localPort;
+
+ WebKit::WebMessagePortChannel* m_webChannel;
+};
+
+} // namespace WebCore
+
+#endif // PlatformMessagePortChannel_h
diff --git a/WebKit/chromium/src/ResourceHandle.cpp b/WebKit/chromium/src/ResourceHandle.cpp
new file mode 100644
index 0000000..6cecd1d
--- /dev/null
+++ b/WebKit/chromium/src/ResourceHandle.cpp
@@ -0,0 +1,284 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "ResourceHandle.h"
+
+#include "ResourceHandleClient.h"
+#include "ResourceRequest.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebURLError.h"
+#include "WebURLLoader.h"
+#include "WebURLLoaderClient.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+#include "WrappedResourceRequest.h"
+#include "WrappedResourceResponse.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+// ResourceHandleInternal -----------------------------------------------------
+
+class ResourceHandleInternal : public WebURLLoaderClient {
+public:
+ ResourceHandleInternal(const ResourceRequest& request, ResourceHandleClient* client)
+ : m_request(request)
+ , m_owner(0)
+ , m_client(client)
+ {
+ }
+
+ void start();
+ void cancel();
+ void setDefersLoading(bool);
+ bool allowStoredCredentials() const;
+
+ // WebURLLoaderClient methods:
+ virtual void willSendRequest(WebURLLoader*, WebURLRequest&, const WebURLResponse&);
+ virtual void didSendData(
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
+ virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&);
+ virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength);
+ virtual void didFinishLoading(WebURLLoader*);
+ virtual void didFail(WebURLLoader*, const WebURLError&);
+
+ ResourceRequest m_request;
+ ResourceHandle* m_owner;
+ ResourceHandleClient* m_client;
+ OwnPtr<WebURLLoader> m_loader;
+};
+
+void ResourceHandleInternal::start()
+{
+ m_loader.set(webKitClient()->createURLLoader());
+ ASSERT(m_loader.get());
+
+ WrappedResourceRequest wrappedRequest(m_request);
+ wrappedRequest.setAllowStoredCredentials(allowStoredCredentials());
+ m_loader->loadAsynchronously(wrappedRequest, this);
+}
+
+void ResourceHandleInternal::cancel()
+{
+ m_loader->cancel();
+
+ // Do not make any further calls to the client.
+ m_client = 0;
+}
+
+void ResourceHandleInternal::setDefersLoading(bool value)
+{
+ m_loader->setDefersLoading(value);
+}
+
+bool ResourceHandleInternal::allowStoredCredentials() const
+{
+ return m_client && m_client->shouldUseCredentialStorage(m_owner);
+}
+
+void ResourceHandleInternal::willSendRequest(
+ WebURLLoader*, WebURLRequest& request, const WebURLResponse& response)
+{
+ ASSERT(m_client);
+ ASSERT(!request.isNull());
+ ASSERT(!response.isNull());
+ m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse());
+}
+
+void ResourceHandleInternal::didSendData(
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+{
+ ASSERT(m_client);
+ m_client->didSendData(m_owner, bytesSent, totalBytesToBeSent);
+}
+
+void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
+{
+ ASSERT(m_client);
+ ASSERT(!response.isNull());
+ m_client->didReceiveResponse(m_owner, response.toResourceResponse());
+}
+
+void ResourceHandleInternal::didReceiveData(
+ WebURLLoader*, const char* data, int dataLength)
+{
+ ASSERT(m_client);
+
+ // FIXME(yurys): it looks like lengthReceived is always the same as
+ // dataLength and that the latter parameter can be eliminated.
+ // See WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=31019
+ m_client->didReceiveData(m_owner, data, dataLength, dataLength);
+}
+
+void ResourceHandleInternal::didFinishLoading(WebURLLoader*)
+{
+ ASSERT(m_client);
+ m_client->didFinishLoading(m_owner);
+}
+
+void ResourceHandleInternal::didFail(WebURLLoader*, const WebURLError& error)
+{
+ ASSERT(m_client);
+ m_client->didFail(m_owner, error);
+}
+
+// ResourceHandle -------------------------------------------------------------
+
+ResourceHandle::ResourceHandle(const ResourceRequest& request,
+ ResourceHandleClient* client,
+ bool defersLoading,
+ bool shouldContentSniff,
+ bool mightDownloadFromHandle)
+ : d(new ResourceHandleInternal(request, client))
+{
+ d->m_owner = this;
+
+ // FIXME: Figure out what to do with the bool params.
+}
+
+PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request,
+ ResourceHandleClient* client,
+ Frame* deprecated,
+ bool defersLoading,
+ bool shouldContentSniff,
+ bool mightDownloadFromHandle)
+{
+ RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle(
+ request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle));
+
+ if (newHandle->start(deprecated))
+ return newHandle.release();
+
+ return 0;
+}
+
+const ResourceRequest& ResourceHandle::request() const
+{
+ return d->m_request;
+}
+
+ResourceHandleClient* ResourceHandle::client() const
+{
+ return d->m_client;
+}
+
+void ResourceHandle::setClient(ResourceHandleClient* client)
+{
+ d->m_client = client;
+}
+
+void ResourceHandle::setDefersLoading(bool value)
+{
+ d->setDefersLoading(value);
+}
+
+bool ResourceHandle::start(Frame* deprecated)
+{
+ d->start();
+ return true;
+}
+
+void ResourceHandle::clearAuthentication()
+{
+}
+
+void ResourceHandle::cancel()
+{
+ d->cancel();
+}
+
+ResourceHandle::~ResourceHandle()
+{
+ d->m_owner = 0;
+}
+
+PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
+{
+ return 0;
+}
+
+bool ResourceHandle::loadsBlocked()
+{
+ return false; // This seems to be related to sync XMLHttpRequest...
+}
+
+// static
+bool ResourceHandle::supportsBufferedData()
+{
+ return false; // The loader will buffer manually if it needs to.
+}
+
+// static
+void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
+ StoredCredentials storedCredentials,
+ ResourceError& error,
+ ResourceResponse& response,
+ Vector<char>& data,
+ Frame* deprecated)
+{
+ OwnPtr<WebURLLoader> loader(webKitClient()->createURLLoader());
+ ASSERT(loader.get());
+
+ WrappedResourceRequest requestIn(request);
+ requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials);
+ WrappedResourceResponse responseOut(response);
+ WebURLError errorOut;
+ WebData dataOut;
+
+ loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
+
+ error = errorOut;
+ data.clear();
+ data.append(dataOut.data(), dataOut.size());
+}
+
+// static
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
+{
+ // This method is used to determine if a POST request can be repeated from
+ // cache, but you cannot really know until you actually try to read from the
+ // cache. Even if we checked now, something else could come along and wipe
+ // out the cache entry by the time we fetch it.
+ //
+ // So, we always say yes here, which allows us to generate an ERR_CACHE_MISS
+ // if the request cannot be serviced from cache. We force the 'DontLoad'
+ // cache policy at this point to ensure that we never hit the network for
+ // this request.
+ //
+ ASSERT(request.httpMethod() == "POST");
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+ return true;
+}
+
+} // namespace WebCore
diff --git a/WebKit/chromium/src/SharedWorkerRepository.cpp b/WebKit/chromium/src/SharedWorkerRepository.cpp
new file mode 100644
index 0000000..f67a7dd
--- /dev/null
+++ b/WebKit/chromium/src/SharedWorkerRepository.cpp
@@ -0,0 +1,197 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "SharedWorkerRepository.h"
+
+#include "Event.h"
+#include "EventNames.h"
+#include "MessagePortChannel.h"
+#include "PlatformMessagePortChannel.h"
+#include "ScriptExecutionContext.h"
+#include "SharedWorker.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMessagePortChannel.h"
+#include "WebSharedWorker.h"
+#include "WebSharedWorkerRepository.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WorkerScriptLoader.h"
+#include "WorkerScriptLoaderClient.h"
+
+namespace WebCore {
+
+class Document;
+using WebKit::WebFrameImpl;
+using WebKit::WebMessagePortChannel;
+using WebKit::WebSharedWorker;
+using WebKit::WebSharedWorkerRepository;
+
+// Callback class that keeps the SharedWorker and WebSharedWorker objects alive while loads are potentially happening, and also translates load errors into error events on the worker.
+class SharedWorkerScriptLoader : private WorkerScriptLoaderClient, private WebSharedWorker::ConnectListener, private ActiveDOMObject {
+public:
+ SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker)
+ : ActiveDOMObject(worker->scriptExecutionContext(), this)
+ , m_worker(worker)
+ , m_url(url)
+ , m_name(name)
+ , m_webWorker(webWorker)
+ , m_port(port)
+ {
+ }
+
+ void load();
+ virtual void contextDestroyed();
+private:
+ // WorkerScriptLoaderClient callback
+ virtual void notifyFinished();
+
+ virtual void connected();
+
+ void sendConnect();
+
+ RefPtr<SharedWorker> m_worker;
+ KURL m_url;
+ String m_name;
+ OwnPtr<WebSharedWorker> m_webWorker;
+ OwnPtr<MessagePortChannel> m_port;
+ WorkerScriptLoader m_scriptLoader;
+};
+
+void SharedWorkerScriptLoader::load()
+{
+ // If the shared worker is not yet running, load the script resource for it, otherwise just send it a connect event.
+ if (m_webWorker->isStarted())
+ sendConnect();
+ else
+ m_scriptLoader.loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this);
+}
+
+// Extracts a WebMessagePortChannel from a MessagePortChannel.
+static WebMessagePortChannel* getWebPort(PassOwnPtr<MessagePortChannel> port)
+{
+ // Extract the WebMessagePortChannel to send to the worker.
+ PlatformMessagePortChannel* platformChannel = port->channel();
+ WebMessagePortChannel* webPort = platformChannel->webChannelRelease();
+ webPort->setClient(0);
+ return webPort;
+}
+
+void SharedWorkerScriptLoader::notifyFinished()
+{
+ if (m_scriptLoader.failed()) {
+ m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true));
+ delete this;
+ } else {
+ // Pass the script off to the worker, then send a connect event.
+ m_webWorker->startWorkerContext(m_url, m_name, m_worker->scriptExecutionContext()->userAgent(m_url), m_scriptLoader.script());
+ sendConnect();
+ }
+}
+
+void SharedWorkerScriptLoader::sendConnect()
+{
+ // Send the connect event off, and linger until it is done sending.
+ m_webWorker->connect(getWebPort(m_port.release()), this);
+}
+
+void SharedWorkerScriptLoader::contextDestroyed()
+{
+ ActiveDOMObject::contextDestroyed();
+ delete this;
+}
+
+void SharedWorkerScriptLoader::connected()
+{
+ // Connect event has been sent, so free ourselves (this releases the SharedWorker so it can be freed as well if unreferenced).
+ delete this;
+}
+
+bool SharedWorkerRepository::isAvailable()
+{
+ // Allow the WebKitClient to determine if SharedWorkers are available.
+ return WebKit::webKitClient()->sharedWorkerRepository();
+}
+
+static WebSharedWorkerRepository::DocumentID getId(void* document)
+{
+ ASSERT(document);
+ return reinterpret_cast<WebSharedWorkerRepository::DocumentID>(document);
+}
+
+void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionCode& ec)
+{
+ // This should not be callable unless there's a SharedWorkerRepository for
+ // this context (since isAvailable() should have returned null).
+ ASSERT(WebKit::webKitClient()->sharedWorkerRepository());
+
+ // No nested workers (for now) - connect() should only be called from document context.
+ ASSERT(worker->scriptExecutionContext()->isDocument());
+ Document* document = static_cast<Document*>(worker->scriptExecutionContext());
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ OwnPtr<WebSharedWorker> webWorker;
+ webWorker = webFrame->client()->createSharedWorker(webFrame, url, name, getId(document));
+
+ if (!webWorker) {
+ // Existing worker does not match this url, so return an error back to the caller.
+ ec = URL_MISMATCH_ERR;
+ return;
+ }
+
+ // The loader object manages its own lifecycle (and the lifecycles of the two worker objects).
+ // It will free itself once loading is completed.
+ SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url, name, port.release(), webWorker.release());
+ loader->load();
+}
+
+void SharedWorkerRepository::documentDetached(Document* document)
+{
+ WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository();
+ if (repo)
+ repo->documentDetached(getId(document));
+}
+
+bool SharedWorkerRepository::hasSharedWorkers(Document* document)
+{
+ WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository();
+ return repo && repo->hasSharedWorkers(getId(document));
+}
+
+
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list