diff options
Diffstat (limited to 'Source/web/WebSharedWorkerImpl.cpp')
-rw-r--r-- | Source/web/WebSharedWorkerImpl.cpp | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/Source/web/WebSharedWorkerImpl.cpp b/Source/web/WebSharedWorkerImpl.cpp index be97906b1..3730ae759 100644 --- a/Source/web/WebSharedWorkerImpl.cpp +++ b/Source/web/WebSharedWorkerImpl.cpp @@ -46,10 +46,9 @@ #include "WorkerFileSystemClient.h" #include "core/dom/CrossThreadTask.h" #include "core/dom/Document.h" -#include "core/events/MessageEvent.h" +#include "core/dom/ExecutionContext.h" #include "core/dom/MessagePortChannel.h" -#include "core/dom/ScriptExecutionContext.h" -#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h" +#include "core/events/MessageEvent.h" #include "core/html/HTMLFormElement.h" #include "core/inspector/WorkerDebuggerAgent.h" #include "core/inspector/WorkerInspectorController.h" @@ -92,6 +91,7 @@ static void initializeWebKitStaticValues() WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) : m_webView(0) + , m_mainFrame(0) , m_askedToTerminate(false) , m_client(client) , m_pauseWorkerContextOnStart(false) @@ -102,10 +102,11 @@ WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) WebSharedWorkerImpl::~WebSharedWorkerImpl() { ASSERT(m_webView); - WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); - if (webFrame) - webFrame->setClient(0); + // Detach the client before closing the view to avoid getting called back. + toWebFrameImpl(m_mainFrame)->setClient(0); + m_webView->close(); + m_mainFrame->close(); } void WebSharedWorkerImpl::stopWorkerThread() @@ -127,7 +128,8 @@ void WebSharedWorkerImpl::initializeLoader(const WebURL& url) m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled()); // FIXME: Settings information should be passed to the Worker process from Browser process when the worker // is created (similar to RenderThread::OnCreateNewView). - m_webView->initializeMainFrame(this); + m_mainFrame = WebFrame::create(this); + m_webView->setMainFrame(m_mainFrame); WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); @@ -165,7 +167,7 @@ void WebSharedWorkerImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptV message->toWireString(), channels)); } -void WebSharedWorkerImpl::postMessageTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::postMessageTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, String message, PassOwnPtr<MessagePortChannelArray> channels) @@ -174,10 +176,8 @@ void WebSharedWorkerImpl::postMessageTask(ScriptExecutionContext* context, return; WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); - for (size_t i = 0; i < webChannels.size(); ++i) { - webChannels[i] = (*channels)[i]->channel()->webChannelRelease(); - webChannels[i]->setClient(0); - } + for (size_t i = 0; i < webChannels.size(); ++i) + webChannels[i] = (*channels)[i]->webChannelRelease(); thisPtr->client()->postMessageToWorkerObject(message, webChannels); } @@ -193,7 +193,7 @@ void WebSharedWorkerImpl::postExceptionToWorkerObject(const String& errorMessage sourceURL)); } -void WebSharedWorkerImpl::postExceptionTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::postExceptionTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, const String& errorMessage, int lineNumber, const String& sourceURL) @@ -215,7 +215,7 @@ void WebSharedWorkerImpl::postConsoleMessageToWorkerObject(MessageSource source, WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this), source, level, message, lineNumber, sourceURL)); } -void WebSharedWorkerImpl::postConsoleMessageTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::postConsoleMessageTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, int source, int level, @@ -233,7 +233,7 @@ void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToPageInspectorTask, AllowCrossThreadAccess(this), message)); } -void WebSharedWorkerImpl::postMessageToPageInspectorTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& message) +void WebSharedWorkerImpl::postMessageToPageInspectorTask(ExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& message) { if (!thisPtr->client()) return; @@ -245,7 +245,7 @@ void WebSharedWorkerImpl::updateInspectorStateCookie(const WTF::String& cookie) WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&updateInspectorStateCookieTask, AllowCrossThreadAccess(this), cookie)); } -void WebSharedWorkerImpl::updateInspectorStateCookieTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& cookie) +void WebSharedWorkerImpl::updateInspectorStateCookieTask(ExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& cookie) { if (!thisPtr->client()) return; @@ -258,7 +258,7 @@ void WebSharedWorkerImpl::confirmMessageFromWorkerObject(bool hasPendingActivity hasPendingActivity)); } -void WebSharedWorkerImpl::confirmMessageTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::confirmMessageTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, bool hasPendingActivity) { @@ -274,7 +274,7 @@ void WebSharedWorkerImpl::reportPendingActivity(bool hasPendingActivity) hasPendingActivity)); } -void WebSharedWorkerImpl::reportPendingActivityTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::reportPendingActivityTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr, bool hasPendingActivity) { @@ -289,7 +289,7 @@ void WebSharedWorkerImpl::workerGlobalScopeClosed() AllowCrossThreadAccess(this))); } -void WebSharedWorkerImpl::workerGlobalScopeClosedTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::workerGlobalScopeClosedTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr) { if (thisPtr->client()) @@ -304,7 +304,7 @@ void WebSharedWorkerImpl::workerGlobalScopeDestroyed() AllowCrossThreadAccess(this))); } -void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ScriptExecutionContext* context, +void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ExecutionContext* context, WebSharedWorkerImpl* thisPtr) { if (thisPtr->client()) @@ -315,14 +315,14 @@ void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ScriptExecutionContext* // WorkerLoaderProxy ----------------------------------------------------------- -void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task) +void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) { ASSERT(m_loadingDocument->isDocument()); m_loadingDocument->postTask(task); } bool WebSharedWorkerImpl::postTaskForModeToWorkerGlobalScope( - PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) + PassOwnPtr<ExecutionContextTask> task, const String& mode) { m_workerThread->runLoop().postTaskForMode(task, mode); return true; @@ -343,20 +343,14 @@ bool WebSharedWorkerImpl::isStarted() void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel, ConnectListener* listener) { - // Convert the WebMessagePortChanel to a WebCore::MessagePortChannel. - RefPtr<PlatformMessagePortChannel> platform_channel = - PlatformMessagePortChannel::create(webChannel); - webChannel->setClient(platform_channel.get()); - OwnPtr<MessagePortChannel> channel = - MessagePortChannel::create(platform_channel); - + RefPtr<MessagePortChannel> channel = MessagePortChannel::create(webChannel); workerThread()->runLoop().postTask( createCallbackTask(&connectTask, channel.release())); if (listener) listener->connected(); } -void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPtr<MessagePortChannel> channel) +void WebSharedWorkerImpl::connectTask(ExecutionContext* context, PassRefPtr<MessagePortChannel> channel) { // Wrap the passed-in channel in a MessagePort, and send it off via a connect event. RefPtr<MessagePort> port = MessagePort::create(*context); @@ -394,7 +388,7 @@ void WebSharedWorkerImpl::pauseWorkerContextOnStart() m_pauseWorkerContextOnStart = true; } -static void resumeWorkerContextTask(ScriptExecutionContext* context, bool) +static void resumeWorkerContextTask(ExecutionContext* context, bool) { toWorkerGlobalScope(context)->workerInspectorController()->resume(); } @@ -406,7 +400,7 @@ void WebSharedWorkerImpl::resumeWorkerContext() workerThread()->runLoop().postTaskForMode(createCallbackTask(resumeWorkerContextTask, true), WorkerDebuggerAgent::debuggerTaskMode); } -static void connectToWorkerContextInspectorTask(ScriptExecutionContext* context, bool) +static void connectToWorkerContextInspectorTask(ExecutionContext* context, bool) { toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend(); } @@ -416,7 +410,7 @@ void WebSharedWorkerImpl::attachDevTools() workerThread()->runLoop().postTaskForMode(createCallbackTask(connectToWorkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); } -static void reconnectToWorkerContextInspectorTask(ScriptExecutionContext* context, const String& savedState) +static void reconnectToWorkerContextInspectorTask(ExecutionContext* context, const String& savedState) { WorkerInspectorController* ic = toWorkerGlobalScope(context)->workerInspectorController(); ic->restoreInspectorStateFromCookie(savedState); @@ -428,7 +422,7 @@ void WebSharedWorkerImpl::reattachDevTools(const WebString& savedState) workerThread()->runLoop().postTaskForMode(createCallbackTask(reconnectToWorkerContextInspectorTask, String(savedState)), WorkerDebuggerAgent::debuggerTaskMode); } -static void disconnectFromWorkerContextInspectorTask(ScriptExecutionContext* context, bool) +static void disconnectFromWorkerContextInspectorTask(ExecutionContext* context, bool) { toWorkerGlobalScope(context)->workerInspectorController()->disconnectFrontend(); } @@ -438,7 +432,7 @@ void WebSharedWorkerImpl::detachDevTools() workerThread()->runLoop().postTaskForMode(createCallbackTask(disconnectFromWorkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode); } -static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, const String& message) +static void dispatchOnInspectorBackendTask(ExecutionContext* context, const String& message) { toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFromFrontend(message); } |