| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/workers/InProcessWorkerBase.h" | 6 #include "core/workers/InProcessWorkerBase.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/events/MessageEvent.h" | 9 #include "core/events/MessageEvent.h" |
| 10 #include "core/fetch/ResourceFetcher.h" | 10 #include "core/fetch/ResourceFetcher.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool InProcessWorkerBase::hasPendingActivity() const | 73 bool InProcessWorkerBase::hasPendingActivity() const |
| 74 { | 74 { |
| 75 // The worker context does not exist while loading, so we must ensure that t
he worker object is not collected, nor are its event listeners. | 75 // The worker context does not exist while loading, so we must ensure that t
he worker object is not collected, nor are its event listeners. |
| 76 return (m_contextProxy && m_contextProxy->hasPendingActivity()) || m_scriptL
oader; | 76 return (m_contextProxy && m_contextProxy->hasPendingActivity()) || m_scriptL
oader; |
| 77 } | 77 } |
| 78 | 78 |
| 79 PassRefPtr<ContentSecurityPolicy> InProcessWorkerBase::contentSecurityPolicy() | 79 PassRefPtr<ContentSecurityPolicy> InProcessWorkerBase::contentSecurityPolicy() |
| 80 { | 80 { |
| 81 return WorkerScriptLoaderClient::contentSecurityPolicy(); | 81 if (m_scriptLoader) |
| 82 return m_scriptLoader->contentSecurityPolicy(); |
| 83 return m_contentSecurityPolicy; |
| 82 } | 84 } |
| 83 | 85 |
| 84 void InProcessWorkerBase::didReceiveResponse(unsigned long identifier, const Res
ourceResponse& response) | 86 void InProcessWorkerBase::didReceiveResponse(unsigned long identifier, const Res
ourceResponse& response) |
| 85 { | 87 { |
| 86 processContentSecurityPolicy(response); | |
| 87 InspectorInstrumentation::didReceiveScriptResponse(executionContext(), ident
ifier); | 88 InspectorInstrumentation::didReceiveScriptResponse(executionContext(), ident
ifier); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void InProcessWorkerBase::notifyFinished() | 91 void InProcessWorkerBase::notifyFinished() |
| 91 { | 92 { |
| 92 if (m_scriptLoader->failed()) { | 93 if (m_scriptLoader->failed()) { |
| 93 dispatchEvent(Event::createCancelable(EventTypeNames::error)); | 94 dispatchEvent(Event::createCancelable(EventTypeNames::error)); |
| 94 } else { | 95 } else { |
| 95 ASSERT(m_contextProxy); | 96 ASSERT(m_contextProxy); |
| 96 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart; | 97 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart; |
| 97 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executio
nContext())) | 98 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executio
nContext())) |
| 98 startMode = PauseWorkerGlobalScopeOnStart; | 99 startMode = PauseWorkerGlobalScopeOnStart; |
| 99 m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionC
ontext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode)
; | 100 m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionC
ontext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode)
; |
| 100 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa
der->identifier(), m_scriptLoader->script()); | 101 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa
der->identifier(), m_scriptLoader->script()); |
| 101 } | 102 } |
| 103 m_contentSecurityPolicy = m_scriptLoader->releaseContentSecurityPolicy(); |
| 102 m_scriptLoader = nullptr; | 104 m_scriptLoader = nullptr; |
| 103 } | 105 } |
| 104 | 106 |
| 105 DEFINE_TRACE(InProcessWorkerBase) | 107 DEFINE_TRACE(InProcessWorkerBase) |
| 106 { | 108 { |
| 107 AbstractWorker::trace(visitor); | 109 AbstractWorker::trace(visitor); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |