| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #include "public/web/WebSettings.h" | 65 #include "public/web/WebSettings.h" |
| 66 #include "public/web/WebView.h" | 66 #include "public/web/WebView.h" |
| 67 #include "public/web/WebWorkerContentSettingsClientProxy.h" | 67 #include "public/web/WebWorkerContentSettingsClientProxy.h" |
| 68 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" | 68 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" |
| 69 #include "web/IndexedDBClientImpl.h" | 69 #include "web/IndexedDBClientImpl.h" |
| 70 #include "web/LocalFileSystemClient.h" | 70 #include "web/LocalFileSystemClient.h" |
| 71 #include "web/WebDataSourceImpl.h" | 71 #include "web/WebDataSourceImpl.h" |
| 72 #include "web/WebLocalFrameImpl.h" | 72 #include "web/WebLocalFrameImpl.h" |
| 73 #include "web/WorkerContentSettingsClient.h" | 73 #include "web/WorkerContentSettingsClient.h" |
| 74 #include "wtf/Functional.h" | 74 #include "wtf/Functional.h" |
| 75 #include "wtf/PtrUtil.h" |
| 76 #include <memory> |
| 75 | 77 |
| 76 namespace blink { | 78 namespace blink { |
| 77 | 79 |
| 78 // TODO(toyoshim): Share implementation with WebEmbeddedWorkerImpl as much as | 80 // TODO(toyoshim): Share implementation with WebEmbeddedWorkerImpl as much as |
| 79 // possible. | 81 // possible. |
| 80 | 82 |
| 81 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) | 83 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) |
| 82 : m_webView(nullptr) | 84 : m_webView(nullptr) |
| 83 , m_mainFrame(nullptr) | 85 , m_mainFrame(nullptr) |
| 84 , m_askedToTerminate(false) | 86 , m_askedToTerminate(false) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const WebURLResponse& redirectResponse) | 165 const WebURLResponse& redirectResponse) |
| 164 { | 166 { |
| 165 if (m_networkProvider) | 167 if (m_networkProvider) |
| 166 m_networkProvider->willSendRequest(frame->dataSource(), request); | 168 m_networkProvider->willSendRequest(frame->dataSource(), request); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) | 171 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) |
| 170 { | 172 { |
| 171 DCHECK(!m_loadingDocument); | 173 DCHECK(!m_loadingDocument); |
| 172 DCHECK(!m_mainScriptLoader); | 174 DCHECK(!m_mainScriptLoader); |
| 173 m_networkProvider = adoptPtr(m_client->createServiceWorkerNetworkProvider(fr
ame->dataSource())); | 175 m_networkProvider = wrapUnique(m_client->createServiceWorkerNetworkProvider(
frame->dataSource())); |
| 174 m_mainScriptLoader = WorkerScriptLoader::create(); | 176 m_mainScriptLoader = WorkerScriptLoader::create(); |
| 175 m_mainScriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); | 177 m_mainScriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); |
| 176 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); | 178 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); |
| 177 m_mainScriptLoader->loadAsynchronously( | 179 m_mainScriptLoader->loadAsynchronously( |
| 178 *m_loadingDocument.get(), | 180 *m_loadingDocument.get(), |
| 179 m_url, | 181 m_url, |
| 180 DenyCrossOriginRequests, | 182 DenyCrossOriginRequests, |
| 181 m_creationAddressSpace, | 183 m_creationAddressSpace, |
| 182 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, this), | 184 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, this), |
| 183 bind(&WebSharedWorkerImpl::onScriptLoaderFinished, this)); | 185 bind(&WebSharedWorkerImpl::onScriptLoaderFinished, this)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 205 void WebSharedWorkerImpl::resumeStartup() | 207 void WebSharedWorkerImpl::resumeStartup() |
| 206 { | 208 { |
| 207 bool isPausedOnStart = m_isPausedOnStart; | 209 bool isPausedOnStart = m_isPausedOnStart; |
| 208 m_isPausedOnStart = false; | 210 m_isPausedOnStart = false; |
| 209 if (isPausedOnStart) | 211 if (isPausedOnStart) |
| 210 loadShadowPage(); | 212 loadShadowPage(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 // WorkerReportingProxy -------------------------------------------------------- | 215 // WorkerReportingProxy -------------------------------------------------------- |
| 214 | 216 |
| 215 void WebSharedWorkerImpl::reportException(const String& errorMessage, PassOwnPtr
<SourceLocation>) | 217 void WebSharedWorkerImpl::reportException(const String& errorMessage, std::uniqu
e_ptr<SourceLocation>) |
| 216 { | 218 { |
| 217 // Not suppported in SharedWorker. | 219 // Not suppported in SharedWorker. |
| 218 } | 220 } |
| 219 | 221 |
| 220 void WebSharedWorkerImpl::reportConsoleMessage(ConsoleMessage*) | 222 void WebSharedWorkerImpl::reportConsoleMessage(ConsoleMessage*) |
| 221 { | 223 { |
| 222 // Not supported in SharedWorker. | 224 // Not supported in SharedWorker. |
| 223 } | 225 } |
| 224 | 226 |
| 225 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) | 227 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return; | 321 return; |
| 320 } | 322 } |
| 321 | 323 |
| 322 Document* document = m_mainFrame->frame()->document(); | 324 Document* document = m_mainFrame->frame()->document(); |
| 323 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) | 325 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) |
| 324 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); | 326 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); |
| 325 | 327 |
| 326 WorkerClients* workerClients = WorkerClients::create(); | 328 WorkerClients* workerClients = WorkerClients::create(); |
| 327 provideLocalFileSystemToWorker(workerClients, LocalFileSystemClient::create(
)); | 329 provideLocalFileSystemToWorker(workerClients, LocalFileSystemClient::create(
)); |
| 328 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); | 330 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); |
| 329 provideContentSettingsClientToWorker(workerClients, adoptPtr(m_client->creat
eWorkerContentSettingsClientProxy(webSecurityOrigin))); | 331 provideContentSettingsClientToWorker(workerClients, wrapUnique(m_client->cre
ateWorkerContentSettingsClientProxy(webSecurityOrigin))); |
| 330 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create())
; | 332 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create())
; |
| 331 ContentSecurityPolicy* contentSecurityPolicy = m_mainScriptLoader->releaseCo
ntentSecurityPolicy(); | 333 ContentSecurityPolicy* contentSecurityPolicy = m_mainScriptLoader->releaseCo
ntentSecurityPolicy(); |
| 332 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do
cument); | 334 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do
cument); |
| 333 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e( | 335 std::unique_ptr<WorkerThreadStartupData> startupData = WorkerThreadStartupDa
ta::create( |
| 334 m_url, | 336 m_url, |
| 335 m_loadingDocument->userAgent(), | 337 m_loadingDocument->userAgent(), |
| 336 m_mainScriptLoader->script(), | 338 m_mainScriptLoader->script(), |
| 337 nullptr, | 339 nullptr, |
| 338 startMode, | 340 startMode, |
| 339 contentSecurityPolicy ? contentSecurityPolicy->headers().get() : nullptr
, | 341 contentSecurityPolicy ? contentSecurityPolicy->headers().get() : nullptr
, |
| 340 starterOrigin, | 342 starterOrigin, |
| 341 workerClients, | 343 workerClients, |
| 342 m_mainScriptLoader->responseAddressSpace(), | 344 m_mainScriptLoader->responseAddressSpace(), |
| 343 m_mainScriptLoader->originTrialTokens()); | 345 m_mainScriptLoader->originTrialTokens()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (devtoolsAgent) | 393 if (devtoolsAgent) |
| 392 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, mes
sage); | 394 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, mes
sage); |
| 393 } | 395 } |
| 394 | 396 |
| 395 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 397 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
| 396 { | 398 { |
| 397 return new WebSharedWorkerImpl(client); | 399 return new WebSharedWorkerImpl(client); |
| 398 } | 400 } |
| 399 | 401 |
| 400 } // namespace blink | 402 } // namespace blink |
| OLD | NEW |