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 26 matching lines...) Expand all Loading... |
210 loadShadowPage(); | 212 loadShadowPage(); |
211 } | 213 } |
212 | 214 |
213 WebDevToolsAgentClient::WebKitClientMessageLoop* WebSharedWorkerImpl::createClie
ntMessageLoop() | 215 WebDevToolsAgentClient::WebKitClientMessageLoop* WebSharedWorkerImpl::createClie
ntMessageLoop() |
214 { | 216 { |
215 return m_client->createDevToolsMessageLoop(); | 217 return m_client->createDevToolsMessageLoop(); |
216 } | 218 } |
217 | 219 |
218 // WorkerReportingProxy -------------------------------------------------------- | 220 // WorkerReportingProxy -------------------------------------------------------- |
219 | 221 |
220 void WebSharedWorkerImpl::reportException(const String& errorMessage, PassOwnPtr
<SourceLocation>) | 222 void WebSharedWorkerImpl::reportException(const String& errorMessage, std::uniqu
e_ptr<SourceLocation>) |
221 { | 223 { |
222 // Not suppported in SharedWorker. | 224 // Not suppported in SharedWorker. |
223 } | 225 } |
224 | 226 |
225 void WebSharedWorkerImpl::reportConsoleMessage(ConsoleMessage*) | 227 void WebSharedWorkerImpl::reportConsoleMessage(ConsoleMessage*) |
226 { | 228 { |
227 // Not supported in SharedWorker. | 229 // Not supported in SharedWorker. |
228 } | 230 } |
229 | 231 |
230 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) | 232 void WebSharedWorkerImpl::postMessageToPageInspector(const String& message) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return; | 326 return; |
325 } | 327 } |
326 | 328 |
327 Document* document = m_mainFrame->frame()->document(); | 329 Document* document = m_mainFrame->frame()->document(); |
328 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) | 330 // FIXME: this document's origin is pristine and without any extra privilege
s. (crbug.com/254993) |
329 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); | 331 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); |
330 | 332 |
331 WorkerClients* workerClients = WorkerClients::create(); | 333 WorkerClients* workerClients = WorkerClients::create(); |
332 provideLocalFileSystemToWorker(workerClients, LocalFileSystemClient::create(
)); | 334 provideLocalFileSystemToWorker(workerClients, LocalFileSystemClient::create(
)); |
333 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); | 335 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); |
334 provideContentSettingsClientToWorker(workerClients, adoptPtr(m_client->creat
eWorkerContentSettingsClientProxy(webSecurityOrigin))); | 336 provideContentSettingsClientToWorker(workerClients, wrapUnique(m_client->cre
ateWorkerContentSettingsClientProxy(webSecurityOrigin))); |
335 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create())
; | 337 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create())
; |
336 ContentSecurityPolicy* contentSecurityPolicy = m_mainScriptLoader->releaseCo
ntentSecurityPolicy(); | 338 ContentSecurityPolicy* contentSecurityPolicy = m_mainScriptLoader->releaseCo
ntentSecurityPolicy(); |
337 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do
cument); | 339 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do
cument); |
338 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e( | 340 std::unique_ptr<WorkerThreadStartupData> startupData = WorkerThreadStartupDa
ta::create( |
339 m_url, | 341 m_url, |
340 m_loadingDocument->userAgent(), | 342 m_loadingDocument->userAgent(), |
341 m_mainScriptLoader->script(), | 343 m_mainScriptLoader->script(), |
342 nullptr, | 344 nullptr, |
343 startMode, | 345 startMode, |
344 contentSecurityPolicy ? contentSecurityPolicy->headers().get() : nullptr
, | 346 contentSecurityPolicy ? contentSecurityPolicy->headers().get() : nullptr
, |
345 starterOrigin, | 347 starterOrigin, |
346 workerClients, | 348 workerClients, |
347 m_mainScriptLoader->responseAddressSpace(), | 349 m_mainScriptLoader->responseAddressSpace(), |
348 m_mainScriptLoader->originTrialTokens()); | 350 m_mainScriptLoader->originTrialTokens()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 if (devtoolsAgent) | 398 if (devtoolsAgent) |
397 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, mes
sage); | 399 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, mes
sage); |
398 } | 400 } |
399 | 401 |
400 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 402 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
401 { | 403 { |
402 return new WebSharedWorkerImpl(client); | 404 return new WebSharedWorkerImpl(client); |
403 } | 405 } |
404 | 406 |
405 } // namespace blink | 407 } // namespace blink |
OLD | NEW |