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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 m_finishCallback = finishCallback; | 97 m_finishCallback = finishCallback; |
98 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); | 98 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); |
99 m_scriptLoader->loadAsynchronously( | 99 m_scriptLoader->loadAsynchronously( |
100 *loadingContext, scriptURL, DenyCrossOriginRequests, this); | 100 *loadingContext, scriptURL, DenyCrossOriginRequests, this); |
101 } | 101 } |
102 | 102 |
103 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re
sponse) override | 103 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re
sponse) override |
104 { | 104 { |
105 m_identifier = identifier; | 105 m_identifier = identifier; |
106 m_appCacheID = response.appCacheID(); | 106 m_appCacheID = response.appCacheID(); |
| 107 processContentSecurityPolicy(response); |
107 (*m_receiveResponseCallback)(); | 108 (*m_receiveResponseCallback)(); |
108 } | 109 } |
109 | 110 |
110 virtual void notifyFinished() override | 111 virtual void notifyFinished() override |
111 { | 112 { |
112 (*m_finishCallback)(); | 113 (*m_finishCallback)(); |
113 } | 114 } |
114 | 115 |
115 void cancel() | 116 void cancel() |
116 { | 117 { |
117 m_scriptLoader->cancel(); | 118 m_scriptLoader->cancel(); |
118 } | 119 } |
119 | 120 |
120 bool failed() const { return m_scriptLoader->failed(); } | 121 bool failed() const { return m_scriptLoader->failed(); } |
121 const KURL& url() const { return m_scriptLoader->responseURL(); } | 122 const KURL& url() const { return m_scriptLoader->responseURL(); } |
122 String script() const { return m_scriptLoader->script(); } | 123 String script() const { return m_scriptLoader->script(); } |
123 unsigned long identifier() const { return m_identifier; } | 124 unsigned long identifier() const { return m_identifier; } |
124 long long appCacheID() const { return m_appCacheID; } | 125 long long appCacheID() const { return m_appCacheID; } |
125 | 126 |
126 private: | 127 private: |
127 Loader() : m_scriptLoader(WorkerScriptLoader::create()), m_identifier(0), m_
appCacheID(0) | 128 Loader() |
| 129 : m_scriptLoader(WorkerScriptLoader::create()) |
| 130 , m_identifier(0) |
| 131 , m_appCacheID(0) |
128 { | 132 { |
| 133 setContentSecurityPolicy(ContentSecurityPolicy::create()); |
129 } | 134 } |
130 | 135 |
131 RefPtr<WorkerScriptLoader> m_scriptLoader; | 136 RefPtr<WorkerScriptLoader> m_scriptLoader; |
132 unsigned long m_identifier; | 137 unsigned long m_identifier; |
133 long long m_appCacheID; | 138 long long m_appCacheID; |
134 OwnPtr<Closure> m_receiveResponseCallback; | 139 OwnPtr<Closure> m_receiveResponseCallback; |
135 OwnPtr<Closure> m_finishCallback; | 140 OwnPtr<Closure> m_finishCallback; |
136 }; | 141 }; |
137 | 142 |
138 // This function is called on the main thread to force to initialize some static | 143 // This function is called on the main thread to force to initialize some static |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 port->entangle(channel); | 371 port->entangle(channel); |
367 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 372 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
368 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop
e()); | 373 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop
e()); |
369 workerGlobalScope->dispatchEvent(createConnectEvent(port.release())); | 374 workerGlobalScope->dispatchEvent(createConnectEvent(port.release())); |
370 } | 375 } |
371 | 376 |
372 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString&
name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType poli
cyType) | 377 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString&
name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType poli
cyType) |
373 { | 378 { |
374 m_url = url; | 379 m_url = url; |
375 m_name = name; | 380 m_name = name; |
376 m_contentSecurityPolicy = contentSecurityPolicy; | |
377 m_policyType = policyType; | |
378 initializeLoader(); | 381 initializeLoader(); |
379 } | 382 } |
380 | 383 |
381 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() | 384 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() |
382 { | 385 { |
383 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(),
m_mainScriptLoader->identifier()); | 386 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(),
m_mainScriptLoader->identifier()); |
384 if (client()) | 387 if (client()) |
385 client()->selectAppCacheID(m_mainScriptLoader->appCacheID()); | 388 client()->selectAppCacheID(m_mainScriptLoader->appCacheID()); |
386 } | 389 } |
387 | 390 |
(...skipping 19 matching lines...) Expand all Loading... |
407 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) | 410 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) |
408 startMode = PauseWorkerGlobalScopeOnStart; | 411 startMode = PauseWorkerGlobalScopeOnStart; |
409 | 412 |
410 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) | 413 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) |
411 SecurityOrigin* starterOrigin = document->securityOrigin(); | 414 SecurityOrigin* starterOrigin = document->securityOrigin(); |
412 | 415 |
413 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 416 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
414 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); | 417 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); |
415 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 418 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
416 provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(client()-
>createWorkerContentSettingsClientProxy(webSecurityOrigin))); | 419 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()); | 420 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), null
ptr, startMode, m_mainScriptLoader->contentSecurityPolicy()->deprecatedHeader(),
static_cast<ContentSecurityPolicyHeaderType>(m_mainScriptLoader->contentSecurit
yPolicy()->deprecatedHeaderType()), starterOrigin, workerClients.release()); |
418 m_loaderProxy = WorkerLoaderProxy::create(this); | 421 m_loaderProxy = WorkerLoaderProxy::create(this); |
419 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this, sta
rtupData.release())); | 422 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this, sta
rtupData.release())); |
420 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); | 423 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); |
421 m_mainScriptLoader.clear(); | 424 m_mainScriptLoader.clear(); |
422 | 425 |
423 workerThread()->start(); | 426 workerThread()->start(); |
424 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); | 427 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); |
425 if (client()) | 428 if (client()) |
426 client()->workerScriptLoaded(); | 429 client()->workerScriptLoaded(); |
427 } | 430 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (devtoolsAgent) | 474 if (devtoolsAgent) |
472 devtoolsAgent->dispatchOnInspectorBackend(message); | 475 devtoolsAgent->dispatchOnInspectorBackend(message); |
473 } | 476 } |
474 | 477 |
475 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 478 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
476 { | 479 { |
477 return new WebSharedWorkerImpl(client); | 480 return new WebSharedWorkerImpl(client); |
478 } | 481 } |
479 | 482 |
480 } // namespace blink | 483 } // namespace blink |
OLD | NEW |