| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 m_finishCallback = finishCallback; | 99 m_finishCallback = finishCallback; |
| 100 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); | 100 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); |
| 101 m_scriptLoader->loadAsynchronously( | 101 m_scriptLoader->loadAsynchronously( |
| 102 *loadingContext, scriptURL, DenyCrossOriginRequests, this); | 102 *loadingContext, scriptURL, DenyCrossOriginRequests, this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re
sponse) override | 105 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re
sponse) override |
| 106 { | 106 { |
| 107 m_identifier = identifier; | 107 m_identifier = identifier; |
| 108 m_appCacheID = response.appCacheID(); | 108 m_appCacheID = response.appCacheID(); |
| 109 processContentSecurityPolicy(response); | |
| 110 (*m_receiveResponseCallback)(); | 109 (*m_receiveResponseCallback)(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 virtual void notifyFinished() override | 112 virtual void notifyFinished() override |
| 114 { | 113 { |
| 115 (*m_finishCallback)(); | 114 (*m_finishCallback)(); |
| 116 } | 115 } |
| 117 | 116 |
| 118 void cancel() | 117 void cancel() |
| 119 { | 118 { |
| 120 m_scriptLoader->cancel(); | 119 m_scriptLoader->cancel(); |
| 121 } | 120 } |
| 122 | 121 |
| 123 bool failed() const { return m_scriptLoader->failed(); } | 122 bool failed() const { return m_scriptLoader->failed(); } |
| 124 const KURL& url() const { return m_scriptLoader->responseURL(); } | 123 const KURL& url() const { return m_scriptLoader->responseURL(); } |
| 125 String script() const { return m_scriptLoader->script(); } | 124 String script() const { return m_scriptLoader->script(); } |
| 126 unsigned long identifier() const { return m_identifier; } | 125 unsigned long identifier() const { return m_identifier; } |
| 127 long long appCacheID() const { return m_appCacheID; } | 126 long long appCacheID() const { return m_appCacheID; } |
| 127 PassRefPtr<ContentSecurityPolicy> contentSecurityPolicy() { return m_scriptL
oader->contentSecurityPolicy(); } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 Loader() | 130 Loader() |
| 131 : m_scriptLoader(WorkerScriptLoader::create()) | 131 : m_scriptLoader(WorkerScriptLoader::create()) |
| 132 , m_identifier(0) | 132 , m_identifier(0) |
| 133 , m_appCacheID(0) | 133 , m_appCacheID(0) |
| 134 { | 134 { |
| 135 setContentSecurityPolicy(ContentSecurityPolicy::create()); | 135 m_scriptLoader->setContentSecurityPolicy(ContentSecurityPolicy::create()
); |
| 136 } | 136 } |
| 137 | 137 |
| 138 RefPtr<WorkerScriptLoader> m_scriptLoader; | 138 RefPtr<WorkerScriptLoader> m_scriptLoader; |
| 139 unsigned long m_identifier; | 139 unsigned long m_identifier; |
| 140 long long m_appCacheID; | 140 long long m_appCacheID; |
| 141 OwnPtr<Closure> m_receiveResponseCallback; | 141 OwnPtr<Closure> m_receiveResponseCallback; |
| 142 OwnPtr<Closure> m_finishCallback; | 142 OwnPtr<Closure> m_finishCallback; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 // This function is called on the main thread to force to initialize some static | 145 // This function is called on the main thread to force to initialize some static |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) | 404 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) |
| 405 startMode = PauseWorkerGlobalScopeOnStart; | 405 startMode = PauseWorkerGlobalScopeOnStart; |
| 406 | 406 |
| 407 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) | 407 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) |
| 408 SecurityOrigin* starterOrigin = document->securityOrigin(); | 408 SecurityOrigin* starterOrigin = document->securityOrigin(); |
| 409 | 409 |
| 410 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 410 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
| 411 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); | 411 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); |
| 412 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 412 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
| 413 provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(m_client-
>createWorkerContentSettingsClientProxy(webSecurityOrigin))); | 413 provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(m_client-
>createWorkerContentSettingsClientProxy(webSecurityOrigin))); |
| 414 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), null
ptr, startMode, m_mainScriptLoader->contentSecurityPolicy()->headers(), starterO
rigin, workerClients.release()); | 414 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e( |
| 415 m_url, |
| 416 m_loadingDocument->userAgent(m_url), |
| 417 m_mainScriptLoader->script(), |
| 418 nullptr, |
| 419 startMode, |
| 420 m_mainScriptLoader->contentSecurityPolicy()->headers(), |
| 421 starterOrigin, |
| 422 workerClients.release()); |
| 415 m_loaderProxy = WorkerLoaderProxy::create(this); | 423 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 416 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this)); | 424 setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this)); |
| 417 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); | 425 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); |
| 418 m_mainScriptLoader.clear(); | 426 m_mainScriptLoader.clear(); |
| 419 | 427 |
| 420 workerThread()->start(startupData.release()); | 428 workerThread()->start(startupData.release()); |
| 421 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); | 429 m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerT
hread(), m_url); |
| 422 m_client->workerScriptLoaded(); | 430 m_client->workerScriptLoaded(); |
| 423 } | 431 } |
| 424 | 432 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 if (devtoolsAgent) | 470 if (devtoolsAgent) |
| 463 devtoolsAgent->dispatchOnInspectorBackend(message); | 471 devtoolsAgent->dispatchOnInspectorBackend(message); |
| 464 } | 472 } |
| 465 | 473 |
| 466 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 474 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
| 467 { | 475 { |
| 468 return new WebSharedWorkerImpl(client); | 476 return new WebSharedWorkerImpl(client); |
| 469 } | 477 } |
| 470 | 478 |
| 471 } // namespace blink | 479 } // namespace blink |
| OLD | NEW |