Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #include "platform/Histogram.h" | 52 #include "platform/Histogram.h" |
| 53 #include "platform/SharedBuffer.h" | 53 #include "platform/SharedBuffer.h" |
| 54 #include "platform/heap/Handle.h" | 54 #include "platform/heap/Handle.h" |
| 55 #include "platform/loader/fetch/SubstituteData.h" | 55 #include "platform/loader/fetch/SubstituteData.h" |
| 56 #include "platform/network/ContentSecurityPolicyParsers.h" | 56 #include "platform/network/ContentSecurityPolicyParsers.h" |
| 57 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" | 57 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" |
| 58 #include "platform/network/NetworkUtils.h" | 58 #include "platform/network/NetworkUtils.h" |
| 59 #include "platform/weborigin/SecurityOrigin.h" | 59 #include "platform/weborigin/SecurityOrigin.h" |
| 60 #include "public/platform/Platform.h" | 60 #include "public/platform/Platform.h" |
| 61 #include "public/platform/WebURLRequest.h" | 61 #include "public/platform/WebURLRequest.h" |
| 62 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h" | |
| 62 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" | 63 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" |
| 63 #include "public/web/WebConsoleMessage.h" | 64 #include "public/web/WebConsoleMessage.h" |
| 64 #include "public/web/WebDevToolsAgent.h" | 65 #include "public/web/WebDevToolsAgent.h" |
| 65 #include "public/web/WebSettings.h" | 66 #include "public/web/WebSettings.h" |
| 66 #include "public/web/WebView.h" | 67 #include "public/web/WebView.h" |
| 67 #include "public/web/WebWorkerContentSettingsClientProxy.h" | 68 #include "public/web/WebWorkerContentSettingsClientProxy.h" |
| 68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" | 69 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" |
| 69 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" | |
| 70 #include "web/IndexedDBClientImpl.h" | 70 #include "web/IndexedDBClientImpl.h" |
| 71 #include "web/ServiceWorkerGlobalScopeClientImpl.h" | 71 #include "web/ServiceWorkerGlobalScopeClientImpl.h" |
| 72 #include "web/ServiceWorkerGlobalScopeProxy.h" | 72 #include "web/ServiceWorkerGlobalScopeProxy.h" |
| 73 #include "web/WebDataSourceImpl.h" | 73 #include "web/WebDataSourceImpl.h" |
| 74 #include "web/WebLocalFrameImpl.h" | 74 #include "web/WebLocalFrameImpl.h" |
| 75 #include "web/WorkerContentSettingsClient.h" | 75 #include "web/WorkerContentSettingsClient.h" |
| 76 #include "wtf/Functional.h" | 76 #include "wtf/Functional.h" |
| 77 #include "wtf/PtrUtil.h" | 77 #include "wtf/PtrUtil.h" |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 RefPtr<SharedBuffer> buffer( | 326 RefPtr<SharedBuffer> buffer( |
| 327 SharedBuffer::create(content.data(), content.length())); | 327 SharedBuffer::create(content.data(), content.length())); |
| 328 m_loadingShadowPage = true; | 328 m_loadingShadowPage = true; |
| 329 m_mainFrame->frame()->loader().load( | 329 m_mainFrame->frame()->loader().load( |
| 330 FrameLoadRequest(0, ResourceRequest(m_workerStartData.scriptURL), | 330 FrameLoadRequest(0, ResourceRequest(m_workerStartData.scriptURL), |
| 331 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); | 331 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void WebEmbeddedWorkerImpl::willSendRequest(WebLocalFrame* frame, | 334 void WebEmbeddedWorkerImpl::willSendRequest(WebLocalFrame* frame, |
| 335 WebURLRequest& request) { | 335 WebURLRequest& request) { |
| 336 if (m_networkProvider) | 336 auto networkProvider = frame->dataSource()->getServiceWorkerNetworkProvider(); |
| 337 m_networkProvider->willSendRequest(frame->dataSource(), request); | 337 if (networkProvider) |
| 338 networkProvider->willSendRequest(request); | |
|
Nate Chapin
2017/03/09 19:52:07
Can we move this (and the equivalent one in WebSha
kinuko
2017/03/10 01:51:03
Yeah I want to remove this too, but that requires
| |
| 338 } | 339 } |
| 339 | 340 |
| 340 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { | 341 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { |
| 341 DCHECK(!m_mainScriptLoader); | 342 DCHECK(!m_mainScriptLoader); |
| 342 DCHECK(!m_networkProvider); | |
| 343 DCHECK(m_mainFrame); | 343 DCHECK(m_mainFrame); |
| 344 DCHECK(m_workerContextClient); | 344 DCHECK(m_workerContextClient); |
| 345 DCHECK(m_loadingShadowPage); | 345 DCHECK(m_loadingShadowPage); |
| 346 DCHECK(!m_askedToTerminate); | 346 DCHECK(!m_askedToTerminate); |
| 347 m_loadingShadowPage = false; | 347 m_loadingShadowPage = false; |
| 348 m_networkProvider = | 348 frame->dataSource()->setServiceWorkerNetworkProvider(WTF::wrapUnique( |
| 349 WTF::wrapUnique(m_workerContextClient->createServiceWorkerNetworkProvider( | 349 m_workerContextClient->createServiceWorkerNetworkProvider())); |
| 350 frame->dataSource())); | |
| 351 m_mainScriptLoader = WorkerScriptLoader::create(); | 350 m_mainScriptLoader = WorkerScriptLoader::create(); |
| 352 m_mainScriptLoader->setRequestContext( | 351 m_mainScriptLoader->setRequestContext( |
| 353 WebURLRequest::RequestContextServiceWorker); | 352 WebURLRequest::RequestContextServiceWorker); |
| 354 m_mainScriptLoader->loadAsynchronously( | 353 m_mainScriptLoader->loadAsynchronously( |
| 355 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, | 354 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, |
| 356 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, | 355 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, |
| 357 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, | 356 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, |
| 358 WTF::unretained(this))); | 357 WTF::unretained(this))); |
| 359 // Do nothing here since onScriptLoaderFinished() might have been already | 358 // Do nothing here since onScriptLoaderFinished() might have been already |
| 360 // invoked and |this| might have been deleted at this point. | 359 // invoked and |this| might have been deleted at this point. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 *this, *document, *m_workerContextClient); | 478 *this, *document, *m_workerContextClient); |
| 480 m_loaderProxy = WorkerLoaderProxy::create(this); | 479 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 481 m_workerThread = | 480 m_workerThread = |
| 482 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); | 481 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); |
| 483 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); | 482 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); |
| 484 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), | 483 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), |
| 485 scriptURL); | 484 scriptURL); |
| 486 } | 485 } |
| 487 | 486 |
| 488 } // namespace blink | 487 } // namespace blink |
| OLD | NEW |