Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: Source/core/workers/InProcessWorkerBase.cpp

Issue 1190133002: Remove WorkerScriptLoaderClient and inheritances (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review #6 and #7 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/InProcessWorkerBase.h ('k') | Source/core/workers/WorkerGlobalScope.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 bool InProcessWorkerBase::initialize(ExecutionContext* context, const String& ur l, ExceptionState& exceptionState) 46 bool InProcessWorkerBase::initialize(ExecutionContext* context, const String& ur l, ExceptionState& exceptionState)
47 { 47 {
48 suspendIfNeeded(); 48 suspendIfNeeded();
49 49
50 KURL scriptURL = resolveURL(url, exceptionState); 50 KURL scriptURL = resolveURL(url, exceptionState);
51 if (scriptURL.isEmpty()) 51 if (scriptURL.isEmpty())
52 return false; 52 return false;
53 53
54 m_scriptLoader = WorkerScriptLoader::create(); 54 m_scriptLoader = adoptPtr(new WorkerScriptLoader());
55 m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOriginReque sts, this); 55 m_scriptLoader->loadAsynchronously(
56 *context,
57 scriptURL,
58 DenyCrossOriginRequests,
59 bind(&InProcessWorkerBase::onResponse, this),
60 bind(&InProcessWorkerBase::onFinished, this));
56 61
57 m_contextProxy = createWorkerGlobalScopeProxy(context); 62 m_contextProxy = createWorkerGlobalScopeProxy(context);
58 63
59 return true; 64 return true;
60 } 65 }
61 66
62 void InProcessWorkerBase::terminate() 67 void InProcessWorkerBase::terminate()
63 { 68 {
64 if (m_contextProxy) 69 if (m_contextProxy)
65 m_contextProxy->terminateWorkerGlobalScope(); 70 m_contextProxy->terminateWorkerGlobalScope();
(...skipping 10 matching lines...) Expand all
76 return (m_contextProxy && m_contextProxy->hasPendingActivity()) || m_scriptL oader; 81 return (m_contextProxy && m_contextProxy->hasPendingActivity()) || m_scriptL oader;
77 } 82 }
78 83
79 PassRefPtr<ContentSecurityPolicy> InProcessWorkerBase::contentSecurityPolicy() 84 PassRefPtr<ContentSecurityPolicy> InProcessWorkerBase::contentSecurityPolicy()
80 { 85 {
81 if (m_scriptLoader) 86 if (m_scriptLoader)
82 return m_scriptLoader->contentSecurityPolicy(); 87 return m_scriptLoader->contentSecurityPolicy();
83 return m_contentSecurityPolicy; 88 return m_contentSecurityPolicy;
84 } 89 }
85 90
86 void InProcessWorkerBase::didReceiveResponse(unsigned long identifier, const Res ourceResponse& response) 91 void InProcessWorkerBase::onResponse()
87 { 92 {
88 InspectorInstrumentation::didReceiveScriptResponse(executionContext(), ident ifier); 93 InspectorInstrumentation::didReceiveScriptResponse(executionContext(), m_scr iptLoader->identifier());
89 } 94 }
90 95
91 void InProcessWorkerBase::notifyFinished() 96 void InProcessWorkerBase::onFinished()
92 { 97 {
93 if (m_scriptLoader->failed()) { 98 if (m_scriptLoader->failed()) {
94 dispatchEvent(Event::createCancelable(EventTypeNames::error)); 99 dispatchEvent(Event::createCancelable(EventTypeNames::error));
95 } else { 100 } else {
96 ASSERT(m_contextProxy); 101 ASSERT(m_contextProxy);
97 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart; 102 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart;
98 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executio nContext())) 103 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executio nContext()))
99 startMode = PauseWorkerGlobalScopeOnStart; 104 startMode = PauseWorkerGlobalScopeOnStart;
100 m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionC ontext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode) ; 105 m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionC ontext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode) ;
101 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa der->identifier(), m_scriptLoader->script()); 106 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa der->identifier(), m_scriptLoader->script());
102 } 107 }
103 m_contentSecurityPolicy = m_scriptLoader->releaseContentSecurityPolicy(); 108 m_contentSecurityPolicy = m_scriptLoader->releaseContentSecurityPolicy();
104 m_scriptLoader = nullptr; 109 m_scriptLoader = nullptr;
105 } 110 }
106 111
107 DEFINE_TRACE(InProcessWorkerBase) 112 DEFINE_TRACE(InProcessWorkerBase)
108 { 113 {
109 AbstractWorker::trace(visitor); 114 AbstractWorker::trace(visitor);
110 } 115 }
111 116
112 } // namespace blink 117 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/InProcessWorkerBase.h ('k') | Source/core/workers/WorkerGlobalScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698