OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "WebWorkerPermissionClientProxy.h" | 40 #include "WebWorkerPermissionClientProxy.h" |
41 #include "WorkerPermissionClient.h" | 41 #include "WorkerPermissionClient.h" |
42 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
43 #include "core/loader/FrameLoadRequest.h" | 43 #include "core/loader/FrameLoadRequest.h" |
44 #include "core/loader/SubstituteData.h" | 44 #include "core/loader/SubstituteData.h" |
45 #include "core/workers/WorkerClients.h" | 45 #include "core/workers/WorkerClients.h" |
46 #include "core/workers/WorkerLoaderProxy.h" | 46 #include "core/workers/WorkerLoaderProxy.h" |
47 #include "core/workers/WorkerScriptLoader.h" | 47 #include "core/workers/WorkerScriptLoader.h" |
48 #include "core/workers/WorkerScriptLoaderClient.h" | 48 #include "core/workers/WorkerScriptLoaderClient.h" |
49 #include "core/workers/WorkerThreadStartupData.h" | 49 #include "core/workers/WorkerThreadStartupData.h" |
| 50 #include "heap/Handle.h" |
50 #include "modules/serviceworkers/ServiceWorkerThread.h" | 51 #include "modules/serviceworkers/ServiceWorkerThread.h" |
51 #include "platform/NotImplemented.h" | 52 #include "platform/NotImplemented.h" |
52 #include "platform/SharedBuffer.h" | 53 #include "platform/SharedBuffer.h" |
53 #include "wtf/Functional.h" | 54 #include "wtf/Functional.h" |
54 | 55 |
55 using namespace WebCore; | 56 using namespace WebCore; |
56 | 57 |
57 namespace blink { | 58 namespace blink { |
58 | 59 |
59 // A thin wrapper for one-off script loading. | 60 // A thin wrapper for one-off script loading. |
(...skipping 29 matching lines...) Expand all Loading... |
89 | 90 |
90 bool failed() const { return m_scriptLoader->failed(); } | 91 bool failed() const { return m_scriptLoader->failed(); } |
91 const KURL& url() const { return m_scriptLoader->responseURL(); } | 92 const KURL& url() const { return m_scriptLoader->responseURL(); } |
92 String script() const { return m_scriptLoader->script(); } | 93 String script() const { return m_scriptLoader->script(); } |
93 | 94 |
94 private: | 95 private: |
95 Loader() : m_scriptLoader(WorkerScriptLoader::create()) | 96 Loader() : m_scriptLoader(WorkerScriptLoader::create()) |
96 { | 97 { |
97 } | 98 } |
98 | 99 |
99 RefPtr<WorkerScriptLoader> m_scriptLoader; | 100 RefPtrWillBePersistent<WorkerScriptLoader> m_scriptLoader; |
100 Closure m_callback; | 101 Closure m_callback; |
101 }; | 102 }; |
102 | 103 |
103 class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { | 104 class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { |
104 public: | 105 public: |
105 static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl& embeddedWorker) | 106 static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl& embeddedWorker) |
106 { | 107 { |
107 return adoptPtr(new LoaderProxy(embeddedWorker)); | 108 return adoptPtr(new LoaderProxy(embeddedWorker)); |
108 } | 109 } |
109 | 110 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; | 230 ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; |
230 | 231 |
231 // This is to be owned by ServiceWorker's WorkerGlobalScope, and is | 232 // This is to be owned by ServiceWorker's WorkerGlobalScope, and is |
232 // guaranteed to be around while the WorkerGlobalScope is alive. | 233 // guaranteed to be around while the WorkerGlobalScope is alive. |
233 WebServiceWorkerContextClient* contextClient = m_workerContextClient.get(); | 234 WebServiceWorkerContextClient* contextClient = m_workerContextClient.get(); |
234 | 235 |
235 OwnPtr<WorkerClients> workerClients = WorkerClients::create(); | 236 OwnPtr<WorkerClients> workerClients = WorkerClients::create(); |
236 providePermissionClientToWorker(workerClients.get(), m_permissionClient.rele
ase()); | 237 providePermissionClientToWorker(workerClients.get(), m_permissionClient.rele
ase()); |
237 provideServiceWorkerGlobalScopeClientToWorker(workerClients.get(), ServiceWo
rkerGlobalScopeClientImpl::create(m_workerContextClient.release())); | 238 provideServiceWorkerGlobalScopeClientToWorker(workerClients.get(), ServiceWo
rkerGlobalScopeClientImpl::create(m_workerContextClient.release())); |
238 | 239 |
239 OwnPtr<WorkerThreadStartupData> startupData = | 240 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = |
240 WorkerThreadStartupData::create( | 241 WorkerThreadStartupData::create( |
241 m_mainScriptLoader->url(), | 242 m_mainScriptLoader->url(), |
242 m_workerStartData.userAgent, | 243 m_workerStartData.userAgent, |
243 m_mainScriptLoader->script(), | 244 m_mainScriptLoader->script(), |
244 startMode, | 245 startMode, |
245 // FIXME: fill appropriate CSP info and policy type. | 246 // FIXME: fill appropriate CSP info and policy type. |
246 String(), | 247 String(), |
247 ContentSecurityPolicy::Enforce, | 248 ContentSecurityPolicy::Enforce, |
248 workerClients.release()); | 249 workerClients.release()); |
249 | 250 |
250 m_mainScriptLoader.clear(); | 251 m_mainScriptLoader.clear(); |
251 | 252 |
252 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebFrameImpl(m_mainFrame)->frame()->document(), *contextClient); | 253 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebFrameImpl(m_mainFrame)->frame()->document(), *contextClient); |
253 m_loaderProxy = LoaderProxy::create(*this); | 254 m_loaderProxy = LoaderProxy::create(*this); |
254 | 255 |
255 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); | 256 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); |
256 m_workerThread->start(); | 257 m_workerThread->start(); |
257 } | 258 } |
258 | 259 |
259 } // namespace blink | 260 } // namespace blink |
OLD | NEW |