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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/WorkerLoaderProxy.h" |
51 #include "core/workers/WorkerScriptLoader.h" | 51 #include "core/workers/WorkerScriptLoader.h" |
52 #include "core/workers/WorkerThreadStartupData.h" | 52 #include "core/workers/WorkerScriptStartupData.h" |
53 #include "platform/RuntimeEnabledFeatures.h" | 53 #include "platform/RuntimeEnabledFeatures.h" |
54 #include "platform/ThreadSafeFunctional.h" | 54 #include "platform/ThreadSafeFunctional.h" |
55 #include "platform/heap/Handle.h" | 55 #include "platform/heap/Handle.h" |
56 #include "platform/network/ContentSecurityPolicyParsers.h" | 56 #include "platform/network/ContentSecurityPolicyParsers.h" |
57 #include "platform/network/ResourceResponse.h" | 57 #include "platform/network/ResourceResponse.h" |
58 #include "platform/weborigin/KURL.h" | 58 #include "platform/weborigin/KURL.h" |
59 #include "platform/weborigin/SecurityOrigin.h" | 59 #include "platform/weborigin/SecurityOrigin.h" |
60 #include "public/platform/WebFileError.h" | 60 #include "public/platform/WebFileError.h" |
61 #include "public/platform/WebMessagePortChannel.h" | 61 #include "public/platform/WebMessagePortChannel.h" |
62 #include "public/platform/WebString.h" | 62 #include "public/platform/WebString.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return; | 184 return; |
185 m_askedToTerminate = true; | 185 m_askedToTerminate = true; |
186 if (m_mainScriptLoader) { | 186 if (m_mainScriptLoader) { |
187 m_mainScriptLoader->cancel(); | 187 m_mainScriptLoader->cancel(); |
188 m_mainScriptLoader.clear(); | 188 m_mainScriptLoader.clear(); |
189 if (client()) | 189 if (client()) |
190 client()->workerScriptLoadFailed(); | 190 client()->workerScriptLoadFailed(); |
191 delete this; | 191 delete this; |
192 return; | 192 return; |
193 } | 193 } |
194 if (m_workerThread) | 194 if (m_workerScript) |
195 m_workerThread->stop(); | 195 m_workerScript->stop(); |
196 m_workerInspectorProxy->workerThreadTerminated(); | 196 m_workerInspectorProxy->workerScriptTerminated(); |
197 } | 197 } |
198 | 198 |
199 void WebSharedWorkerImpl::initializeLoader() | 199 void WebSharedWorkerImpl::initializeLoader() |
200 { | 200 { |
201 // Create 'shadow page'. This page is never displayed, it is used to proxy t
he | 201 // Create 'shadow page'. This page is never displayed, it is used to proxy t
he |
202 // loading requests from the worker context to the rest of WebKit and Chromi
um | 202 // loading requests from the worker context to the rest of WebKit and Chromi
um |
203 // infrastructure. | 203 // infrastructure. |
204 ASSERT(!m_webView); | 204 ASSERT(!m_webView); |
205 m_webView = WebView::create(0); | 205 m_webView = WebView::create(0); |
206 // FIXME: http://crbug.com/363843. This needs to find a better way to | 206 // FIXME: http://crbug.com/363843. This needs to find a better way to |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if (client()) | 320 if (client()) |
321 client()->workerContextClosed(); | 321 client()->workerContextClosed(); |
322 | 322 |
323 stopWorkerThread(); | 323 stopWorkerThread(); |
324 } | 324 } |
325 | 325 |
326 void WebSharedWorkerImpl::workerGlobalScopeStarted(WorkerGlobalScope*) | 326 void WebSharedWorkerImpl::workerGlobalScopeStarted(WorkerGlobalScope*) |
327 { | 327 { |
328 } | 328 } |
329 | 329 |
330 void WebSharedWorkerImpl::workerThreadTerminated() | 330 void WebSharedWorkerImpl::workerScriptTerminated() |
331 { | 331 { |
332 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&WebSh
aredWorkerImpl::workerThreadTerminatedOnMainThread, AllowCrossThreadAccess(this)
)); | 332 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&WebSh
aredWorkerImpl::workerScriptTerminatedOnMainThread, AllowCrossThreadAccess(this)
)); |
333 } | 333 } |
334 | 334 |
335 void WebSharedWorkerImpl::workerThreadTerminatedOnMainThread() | 335 void WebSharedWorkerImpl::workerScriptTerminatedOnMainThread() |
336 { | 336 { |
337 if (client()) | 337 if (client()) |
338 client()->workerContextDestroyed(); | 338 client()->workerContextDestroyed(); |
339 // The lifetime of this proxy is controlled by the worker context. | 339 // The lifetime of this proxy is controlled by the worker context. |
340 delete this; | 340 delete this; |
341 } | 341 } |
342 | 342 |
343 // WorkerLoaderProxyProvider ---------------------------------------------------
-------- | 343 // WorkerLoaderProxyProvider ---------------------------------------------------
-------- |
344 | 344 |
345 void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ExecutionContextTask> task
) | 345 void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ExecutionContextTask> task
) |
346 { | 346 { |
347 m_mainFrame->frame()->document()->postTask(FROM_HERE, task); | 347 m_mainFrame->frame()->document()->postTask(FROM_HERE, task); |
348 } | 348 } |
349 | 349 |
350 bool WebSharedWorkerImpl::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContex
tTask> task) | 350 bool WebSharedWorkerImpl::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContex
tTask> task) |
351 { | 351 { |
352 m_workerThread->postTask(FROM_HERE, task); | 352 m_workerScript->postTask(FROM_HERE, task); |
353 return true; | 353 return true; |
354 } | 354 } |
355 | 355 |
356 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) | 356 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) |
357 { | 357 { |
358 workerThread()->postTask( | 358 workerScript()->postTask( |
359 FROM_HERE, createCrossThreadTask(&connectTask, adoptPtr(webChannel))); | 359 FROM_HERE, createCrossThreadTask(&connectTask, adoptPtr(webChannel))); |
360 } | 360 } |
361 | 361 |
362 void WebSharedWorkerImpl::connectTask(PassOwnPtr<WebMessagePortChannel> channel,
ExecutionContext* context) | 362 void WebSharedWorkerImpl::connectTask(PassOwnPtr<WebMessagePortChannel> channel,
ExecutionContext* context) |
363 { | 363 { |
364 // Wrap the passed-in channel in a MessagePort, and send it off via a connec
t event. | 364 // Wrap the passed-in channel in a MessagePort, and send it off via a connec
t event. |
365 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(*context); | 365 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(*context); |
366 port->entangle(channel); | 366 port->entangle(channel); |
367 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 367 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
368 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop
e()); | 368 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop
e()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) | 407 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) |
408 startMode = PauseWorkerGlobalScopeOnStart; | 408 startMode = PauseWorkerGlobalScopeOnStart; |
409 | 409 |
410 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) | 410 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) |
411 SecurityOrigin* starterOrigin = document->securityOrigin(); | 411 SecurityOrigin* starterOrigin = document->securityOrigin(); |
412 | 412 |
413 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 413 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
414 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); | 414 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); |
415 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 415 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
416 provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(client()-
>createWorkerContentSettingsClientProxy(webSecurityOrigin))); | 416 provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(client()-
>createWorkerContentSettingsClientProxy(webSecurityOrigin))); |
417 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), null
ptr, startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHeader
Type>(m_policyType), starterOrigin, workerClients.release()); | 417 OwnPtr<WorkerScriptStartupData> startupData = WorkerScriptStartupData::creat
e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), null
ptr, startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHeader
Type>(m_policyType), starterOrigin, workerClients.release()); |
418 m_loaderProxy = WorkerLoaderProxy::create(this); | 418 m_loaderProxy = WorkerLoaderProxy::create(this); |
419 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this, sta
rtupData.release())); | 419 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this, sta
rtupData.release())); |
420 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); | 420 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); |
421 m_mainScriptLoader.clear(); | 421 m_mainScriptLoader.clear(); |
422 | 422 |
423 workerThread()->start(); | 423 workerScript()->start(); |
424 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); | 424 m_workerInspectorProxy->workerScriptCreated(m_loadingDocument.get(), workerS
cript(), m_url); |
425 if (client()) | 425 if (client()) |
426 client()->workerScriptLoaded(); | 426 client()->workerScriptLoaded(); |
427 } | 427 } |
428 | 428 |
429 void WebSharedWorkerImpl::terminateWorkerContext() | 429 void WebSharedWorkerImpl::terminateWorkerContext() |
430 { | 430 { |
431 stopWorkerThread(); | 431 stopWorkerThread(); |
432 } | 432 } |
433 | 433 |
434 void WebSharedWorkerImpl::clientDestroyed() | 434 void WebSharedWorkerImpl::clientDestroyed() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (devtoolsAgent) | 471 if (devtoolsAgent) |
472 devtoolsAgent->dispatchOnInspectorBackend(message); | 472 devtoolsAgent->dispatchOnInspectorBackend(message); |
473 } | 473 } |
474 | 474 |
475 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 475 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
476 { | 476 { |
477 return new WebSharedWorkerImpl(client); | 477 return new WebSharedWorkerImpl(client); |
478 } | 478 } |
479 | 479 |
480 } // namespace blink | 480 } // namespace blink |
OLD | NEW |