Commit 0a1d68fc authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-04-27 Michael Nordman <michaeln@google.com>

        Reviewed by Dmitry Titov.

        [Chromium] Add two things to the webkit API to support appcaches in workers.
        1) WebURLRequest TargetTypes for worker and shared worker main resources.
        2) Factory method on class WebCommonWorkerClient to
           createApplicationCacheHost() for the associated worker.

        https://bugs.webkit.org/show_bug.cgi?id=38147

        * public/WebCommonWorkerClient.h: add the factory method
        * public/WebURLRequest.h: add the TargetTypes
        * src/WebWorkerBase.cpp: call the embedder's factory when needed
        (WebKit::WebWorkerBase::didCreateDataSource)
        (WebKit::WebWorkerBase::createApplicationCacheHost)
        * src/WebWorkerBase.h: ditto
        * src/WebWorkerClientImpl.h: add a stub impl of the factory method
        (WebKit::WebWorkerClientImpl::createApplicationCacheHost):
2010-04-27  Michael Nordman  <michaeln@google.com>

        Reviewed by Dmitry Titov.

        [Chromium] Add two things to the webkit API to support appcaches in workers.
        1) WebURLRequest TargetTypes for worker and shared worker main resources.
        2) Factory method on class WebCommonWorkerClient to
           createApplicationCacheHost() for the associated worker.

        https://bugs.webkit.org/show_bug.cgi?id=38147

        * DumpRenderTree/chromium/TestWebWorker.h add a stub impl of the factory method
        (TestWebWorker::createApplicationCacheHost):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8d9ea0cd
2010-04-27 Michael Nordman <michaeln@google.com>
Reviewed by Dmitry Titov.
[Chromium] Add two things to the webkit API to support appcaches in workers.
1) WebURLRequest TargetTypes for worker and shared worker main resources.
2) Factory method on class WebCommonWorkerClient to
createApplicationCacheHost() for the associated worker.
https://bugs.webkit.org/show_bug.cgi?id=38147
* public/WebCommonWorkerClient.h: add the factory method
* public/WebURLRequest.h: add the TargetTypes
* src/WebWorkerBase.cpp: call the embedder's factory when needed
(WebKit::WebWorkerBase::didCreateDataSource)
(WebKit::WebWorkerBase::createApplicationCacheHost)
* src/WebWorkerBase.h: ditto
* src/WebWorkerClientImpl.h: add a stub impl of the factory method
(WebKit::WebWorkerClientImpl::createApplicationCacheHost):
2010-04-27 Kent Tamura <tkent@chromium.org>
Reviewed by Shinichiro Hamaji.
......
......@@ -33,6 +33,8 @@
namespace WebKit {
class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebNotificationPresenter;
class WebString;
class WebWorker;
......@@ -74,6 +76,9 @@ public:
// they are created via the WebSharedWorkerRepository.
virtual WebWorker* createWorker(WebWorkerClient* client) = 0;
// Called on the main webkit thread in the worker process during initialization.
virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) = 0;
protected:
~WebCommonWorkerClient() { }
};
......
......@@ -67,7 +67,9 @@ public:
TargetIsFontResource = 5,
TargetIsImage = 6,
TargetIsObject = 7,
TargetIsMedia = 8
TargetIsMedia = 8,
TargetIsWorker = 9,
TargetIsSharedWorker = 10
};
~WebURLRequest() { reset(); }
......
......@@ -51,30 +51,6 @@ namespace WebKit {
#if ENABLE(WORKERS)
// Dummy WebViewDelegate - we only need it in Worker process to load a
// 'shadow page' which will initialize WebCore loader.
class WorkerWebFrameClient : public WebFrameClient {
public:
// Tell the loader to load the data into the 'shadow page' synchronously,
// so we can grab the resulting Document right after load.
virtual void didCreateDataSource(WebFrame* frame, WebDataSource* ds)
{
static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false);
}
// Lazy allocate and leak this instance.
static WorkerWebFrameClient* sharedInstance()
{
static WorkerWebFrameClient client;
return &client;
}
private:
WorkerWebFrameClient()
{
}
};
// This function is called on the main thread to force to initialize some static
// values used in WebKit before any worker thread is started. This is because in
// our worker processs, we do not run any WebKit code in main thread and thus
......@@ -103,6 +79,9 @@ WebWorkerBase::WebWorkerBase()
WebWorkerBase::~WebWorkerBase()
{
ASSERT(m_webView);
WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
if (webFrame)
webFrame->setClient(0);
m_webView->close();
}
......@@ -122,7 +101,7 @@ void WebWorkerBase::initializeLoader(const WebURL& url)
// infrastructure.
ASSERT(!m_webView);
m_webView = WebView::create(0);
m_webView->initializeMainFrame(WorkerWebFrameClient::sharedInstance());
m_webView->initializeMainFrame(this);
WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
......@@ -151,6 +130,20 @@ void WebWorkerBase::invokeTaskMethod(void* param)
delete task;
}
void WebWorkerBase::didCreateDataSource(WebFrame*, WebDataSource* ds)
{
// Tell the loader to load the data into the 'shadow page' synchronously,
// so we can grab the resulting Document right after load.
static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false);
}
WebApplicationCacheHost* WebWorkerBase::createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient* appcacheHostClient)
{
if (commonClient())
return commonClient()->createApplicationCacheHost(appcacheHostClient);
return 0;
}
// WorkerObjectProxy -----------------------------------------------------------
void WebWorkerBase::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message,
......
......@@ -34,6 +34,7 @@
#if ENABLE(WORKERS)
#include "ScriptExecutionContext.h"
#include "WebFrameClient.h"
#include "WorkerLoaderProxy.h"
#include "WorkerObjectProxy.h"
#include <wtf/PassOwnPtr.h>
......@@ -44,6 +45,8 @@ class WorkerThread;
}
namespace WebKit {
class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebCommonWorkerClient;
class WebSecurityOrigin;
class WebString;
......@@ -56,7 +59,8 @@ class WebWorkerClient;
// code used by both implementation classes, including implementations of the
// WorkerObjectProxy and WorkerLoaderProxy interfaces.
class WebWorkerBase : public WebCore::WorkerObjectProxy
, public WebCore::WorkerLoaderProxy {
, public WebCore::WorkerLoaderProxy
, public WebFrameClient {
public:
WebWorkerBase();
virtual ~WebWorkerBase();
......@@ -80,6 +84,10 @@ public:
virtual void postTaskForModeToWorkerContext(
PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WebCore::String& mode);
// WebFrameClient methods to support resource loading thru the 'shadow page'.
virtual void didCreateDataSource(WebFrame*, WebDataSource*);
virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient*);
// Executes the given task on the main thread.
static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
......
......@@ -94,6 +94,7 @@ public:
// FIXME: Notifications not yet supported in workers.
return 0;
}
virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) { return 0; }
private:
virtual ~WebWorkerClientImpl();
......
2010-04-27 Michael Nordman <michaeln@google.com>
Reviewed by Dmitry Titov.
[Chromium] Add two things to the webkit API to support appcaches in workers.
1) WebURLRequest TargetTypes for worker and shared worker main resources.
2) Factory method on class WebCommonWorkerClient to
createApplicationCacheHost() for the associated worker.
https://bugs.webkit.org/show_bug.cgi?id=38147
* DumpRenderTree/chromium/TestWebWorker.h add a stub impl of the factory method
(TestWebWorker::createApplicationCacheHost):
2010-04-27 Adam Barth <abarth@webkit.org>
 
Reviewed by Eric Seidel.
......@@ -79,6 +79,7 @@ public:
}
virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient*) { return 0; }
virtual WebKit::WebNotificationPresenter* notificationPresenter() { return 0; }
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebApplicationCacheHostClient*) { return 0; }
private:
~TestWebWorker() {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment