OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 "core/inspector/WorkerDebuggerAgent.h" | 40 #include "core/inspector/WorkerDebuggerAgent.h" |
41 #include "core/inspector/WorkerInspectorController.h" | 41 #include "core/inspector/WorkerInspectorController.h" |
42 #include "core/loader/FrameLoadRequest.h" | 42 #include "core/loader/FrameLoadRequest.h" |
43 #include "core/loader/FrameLoader.h" | 43 #include "core/loader/FrameLoader.h" |
44 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
45 #include "core/workers/SharedWorkerGlobalScope.h" | 45 #include "core/workers/SharedWorkerGlobalScope.h" |
46 #include "core/workers/SharedWorkerThread.h" | 46 #include "core/workers/SharedWorkerThread.h" |
47 #include "core/workers/WorkerClients.h" | 47 #include "core/workers/WorkerClients.h" |
48 #include "core/workers/WorkerGlobalScope.h" | 48 #include "core/workers/WorkerGlobalScope.h" |
49 #include "core/workers/WorkerInspectorProxy.h" | 49 #include "core/workers/WorkerInspectorProxy.h" |
| 50 #include "core/workers/WorkerLoaderProxy.h" |
50 #include "core/workers/WorkerScriptLoader.h" | 51 #include "core/workers/WorkerScriptLoader.h" |
51 #include "core/workers/WorkerThreadStartupData.h" | 52 #include "core/workers/WorkerThreadStartupData.h" |
52 #include "platform/RuntimeEnabledFeatures.h" | 53 #include "platform/RuntimeEnabledFeatures.h" |
53 #include "platform/heap/Handle.h" | 54 #include "platform/heap/Handle.h" |
54 #include "platform/network/ContentSecurityPolicyParsers.h" | 55 #include "platform/network/ContentSecurityPolicyParsers.h" |
55 #include "platform/network/ResourceResponse.h" | 56 #include "platform/network/ResourceResponse.h" |
56 #include "platform/weborigin/KURL.h" | 57 #include "platform/weborigin/KURL.h" |
57 #include "platform/weborigin/SecurityOrigin.h" | 58 #include "platform/weborigin/SecurityOrigin.h" |
58 #include "public/platform/WebFileError.h" | 59 #include "public/platform/WebFileError.h" |
59 #include "public/platform/WebMessagePortChannel.h" | 60 #include "public/platform/WebMessagePortChannel.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 165 } |
165 | 166 |
166 WebSharedWorkerImpl::~WebSharedWorkerImpl() | 167 WebSharedWorkerImpl::~WebSharedWorkerImpl() |
167 { | 168 { |
168 ASSERT(m_webView); | 169 ASSERT(m_webView); |
169 // Detach the client before closing the view to avoid getting called back. | 170 // Detach the client before closing the view to avoid getting called back. |
170 toWebLocalFrameImpl(m_mainFrame)->setClient(0); | 171 toWebLocalFrameImpl(m_mainFrame)->setClient(0); |
171 | 172 |
172 m_webView->close(); | 173 m_webView->close(); |
173 m_mainFrame->close(); | 174 m_mainFrame->close(); |
| 175 if (m_loaderProxy) |
| 176 m_loaderProxy->detachProvider(this); |
174 } | 177 } |
175 | 178 |
176 void WebSharedWorkerImpl::stopWorkerThread() | 179 void WebSharedWorkerImpl::stopWorkerThread() |
177 { | 180 { |
178 if (m_askedToTerminate) | 181 if (m_askedToTerminate) |
179 return; | 182 return; |
180 m_askedToTerminate = true; | 183 m_askedToTerminate = true; |
181 if (m_mainScriptLoader) { | 184 if (m_mainScriptLoader) { |
182 m_mainScriptLoader->cancel(); | 185 m_mainScriptLoader->cancel(); |
183 m_mainScriptLoader.clear(); | 186 m_mainScriptLoader.clear(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 313 } |
311 | 314 |
312 void WebSharedWorkerImpl::workerThreadTerminatedOnMainThread() | 315 void WebSharedWorkerImpl::workerThreadTerminatedOnMainThread() |
313 { | 316 { |
314 if (client()) | 317 if (client()) |
315 client()->workerContextDestroyed(); | 318 client()->workerContextDestroyed(); |
316 // The lifetime of this proxy is controlled by the worker context. | 319 // The lifetime of this proxy is controlled by the worker context. |
317 delete this; | 320 delete this; |
318 } | 321 } |
319 | 322 |
320 // WorkerLoaderProxy ----------------------------------------------------------- | 323 // WorkerLoaderProxyProvider ---------------------------------------------------
-------- |
321 | 324 |
322 void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ExecutionContextTask> task
) | 325 void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ExecutionContextTask> task
) |
323 { | 326 { |
324 toWebLocalFrameImpl(m_mainFrame)->frame()->document()->postTask(task); | 327 toWebLocalFrameImpl(m_mainFrame)->frame()->document()->postTask(task); |
325 } | 328 } |
326 | 329 |
327 bool WebSharedWorkerImpl::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContex
tTask> task) | 330 bool WebSharedWorkerImpl::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContex
tTask> task) |
328 { | 331 { |
329 m_workerThread->postTask(task); | 332 m_workerThread->postTask(task); |
330 return true; | 333 return true; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 startMode = PauseWorkerGlobalScopeOnStart; | 388 startMode = PauseWorkerGlobalScopeOnStart; |
386 | 389 |
387 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) | 390 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) |
388 SecurityOrigin* starterOrigin = document->securityOrigin(); | 391 SecurityOrigin* starterOrigin = document->securityOrigin(); |
389 | 392 |
390 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 393 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
391 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); | 394 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); |
392 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 395 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
393 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea
teWorkerPermissionClientProxy(webSecurityOrigin))); | 396 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea
teWorkerPermissionClientProxy(webSecurityOrigin))); |
394 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc
ript(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHea
derType>(m_policyType), starterOrigin, workerClients.release()); | 397 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc
ript(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHea
derType>(m_policyType), starterOrigin, workerClients.release()); |
395 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData
.release())); | 398 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 399 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this, sta
rtupData.release())); |
396 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); | 400 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); |
397 m_mainScriptLoader.clear(); | 401 m_mainScriptLoader.clear(); |
398 | 402 |
399 workerThread()->start(); | 403 workerThread()->start(); |
400 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); | 404 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); |
401 if (client()) | 405 if (client()) |
402 client()->workerScriptLoaded(); | 406 client()->workerScriptLoaded(); |
403 } | 407 } |
404 | 408 |
405 void WebSharedWorkerImpl::terminateWorkerContext() | 409 void WebSharedWorkerImpl::terminateWorkerContext() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 if (devtoolsAgent) | 451 if (devtoolsAgent) |
448 devtoolsAgent->dispatchOnInspectorBackend(message); | 452 devtoolsAgent->dispatchOnInspectorBackend(message); |
449 } | 453 } |
450 | 454 |
451 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 455 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
452 { | 456 { |
453 return new WebSharedWorkerImpl(client); | 457 return new WebSharedWorkerImpl(client); |
454 } | 458 } |
455 | 459 |
456 } // namespace blink | 460 } // namespace blink |
OLD | NEW |