Chromium Code Reviews| Index: Source/web/WebEmbeddedWorkerImpl.cpp |
| diff --git a/Source/web/WebEmbeddedWorkerImpl.cpp b/Source/web/WebEmbeddedWorkerImpl.cpp |
| index cdb106d78d2bc16450927c5b03f7895529bb1c8b..99b9c73460b479993c7909cbaae2d7544c905fdb 100644 |
| --- a/Source/web/WebEmbeddedWorkerImpl.cpp |
| +++ b/Source/web/WebEmbeddedWorkerImpl.cpp |
| @@ -31,6 +31,7 @@ |
| #include "config.h" |
| #include "WebEmbeddedWorkerImpl.h" |
| +#include "ServiceWorkerGlobalScopeProxy.h" |
| #include "WebDataSourceImpl.h" |
| #include "WebFrameImpl.h" |
| #include "WebServiceWorkerContextClient.h" |
| @@ -42,9 +43,11 @@ |
| #include "core/loader/FrameLoadRequest.h" |
| #include "core/loader/SubstituteData.h" |
| #include "core/workers/WorkerClients.h" |
| +#include "core/workers/WorkerLoaderProxy.h" |
| #include "core/workers/WorkerScriptLoader.h" |
| #include "core/workers/WorkerScriptLoaderClient.h" |
| #include "core/workers/WorkerThreadStartupData.h" |
| +#include "modules/serviceworkers/ServiceWorkerThread.h" |
| #include "platform/NotImplemented.h" |
| #include "platform/SharedBuffer.h" |
| #include "wtf/Functional.h" |
| @@ -77,6 +80,7 @@ public: |
| } |
| bool failed() const { return m_scriptLoader->failed(); } |
| + const KURL& url() const { return m_scriptLoader->responseURL(); } |
| String script() const { return m_scriptLoader->script(); } |
| private: |
| @@ -93,6 +97,36 @@ private: |
| Closure m_callback; |
| }; |
| +class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { |
| +public: |
| + static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl* embeddedWorker) |
| + { |
| + return adoptPtr(new LoaderProxy(embeddedWorker)); |
| + } |
| + |
| + virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) OVERRIDE |
| + { |
| + m_embeddedWorker->m_loadingContext->postTask(task); |
| + } |
| + |
| + virtual bool postTaskForModeToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask> task, const String& mode) OVERRIDE |
| + { |
| + if (m_embeddedWorker->m_askedToTerminate |
| + || !m_embeddedWorker->m_workerThread) |
|
adamk
2013/12/05 22:50:12
Nit: This linebreak looks funny in Blink
kinuko
2013/12/09 12:24:20
Concatenated the lines.
|
| + return false; |
| + return m_embeddedWorker->m_workerThread->runLoop().postTaskForMode(task, mode); |
| + } |
| + |
| +private: |
| + explicit LoaderProxy(WebEmbeddedWorkerImpl* embeddedWorker) |
| + : m_embeddedWorker(embeddedWorker) |
| + { |
| + } |
| + |
| + // Not owned, embedded worker owns this. |
|
adamk
2013/12/05 22:50:12
Maybe should be a reference too?
I guess you're f
kinuko
2013/12/09 12:24:20
Done.
|
| + WebEmbeddedWorkerImpl* m_embeddedWorker; |
| +}; |
| + |
| WebEmbeddedWorker* WebEmbeddedWorker::create( |
| WebServiceWorkerContextClient* client, |
| WebWorkerPermissionClientProxy* permissionClient) |
| @@ -189,12 +223,34 @@ void WebEmbeddedWorkerImpl::onScriptLoaderFinished() |
| return; |
| } |
| - // FIXME: Create WorkerReportingProxy, set up WorkerThreadStartupData, |
| - // create ServiceWorkerThread and start it with m_scripLoader->script(). |
| + WorkerThreadStartMode startMode = |
| + (m_workerStartData.startMode == WebEmbeddedWorkerStartModePauseOnStart) |
| + ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; |
| + |
| + OwnPtr<WorkerClients> workerClients = WorkerClients::create(); |
| + providePermissionClientToWorker(workerClients.get(), m_permissionClient.release()); |
| + |
| + OwnPtr<WorkerThreadStartupData> startupData = |
| + WorkerThreadStartupData::create( |
| + m_mainScriptLoader->url(), |
| + m_workerStartData.userAgent, |
| + m_mainScriptLoader->script(), |
| + startMode, |
| + // FIXME: fill appropriate CSP info and policy type. |
| + String(), |
| + ContentSecurityPolicy::Enforce, |
| + workerClients.release()); |
| m_mainScriptLoader.clear(); |
| - notImplemented(); |
| + m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(this, m_loadingContext.get(), m_workerContextClient.release()); |
| + m_loaderProxy = LoaderProxy::create(this); |
| + |
| + m_workerThread = ServiceWorkerThread::create( |
| + *m_loaderProxy.get(), |
|
adamk
2013/12/05 22:50:12
No need for .get() if you're using operator*.
kinuko
2013/12/09 12:24:20
Done.
|
| + *m_workerGlobalScopeProxy.get(), |
|
adamk
2013/12/05 22:50:12
Same here.
kinuko
2013/12/09 12:24:20
Done.
|
| + startupData.release()); |
|
adamk
2013/12/05 22:50:12
More linebreaks...
kinuko
2013/12/09 12:24:20
Too chrome'y? I packed these in one line.
|
| + m_workerThread->start(); |
| } |
| } // namespace blink |