Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp

Issue 2733283004: Expose WebServiceWorkerNetworkProvider on DataSource (Closed)
Patch Set: consistency Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 =
337 m_networkProvider->willSendRequest(frame->dataSource(), request); 337 frame->dataSource()->getServiceWorkerNetworkProvider();
338 if (networkProvider)
339 networkProvider->willSendRequest(request);
338 } 340 }
339 341
340 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { 342 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) {
341 DCHECK(!m_mainScriptLoader); 343 DCHECK(!m_mainScriptLoader);
342 DCHECK(!m_networkProvider);
343 DCHECK(m_mainFrame); 344 DCHECK(m_mainFrame);
344 DCHECK(m_workerContextClient); 345 DCHECK(m_workerContextClient);
345 DCHECK(m_loadingShadowPage); 346 DCHECK(m_loadingShadowPage);
346 DCHECK(!m_askedToTerminate); 347 DCHECK(!m_askedToTerminate);
347 m_loadingShadowPage = false; 348 m_loadingShadowPage = false;
348 m_networkProvider = 349 frame->dataSource()->setServiceWorkerNetworkProvider(WTF::wrapUnique(
349 WTF::wrapUnique(m_workerContextClient->createServiceWorkerNetworkProvider( 350 m_workerContextClient->createServiceWorkerNetworkProvider()));
350 frame->dataSource()));
351 m_mainScriptLoader = WorkerScriptLoader::create(); 351 m_mainScriptLoader = WorkerScriptLoader::create();
352 m_mainScriptLoader->setRequestContext( 352 m_mainScriptLoader->setRequestContext(
353 WebURLRequest::RequestContextServiceWorker); 353 WebURLRequest::RequestContextServiceWorker);
354 m_mainScriptLoader->loadAsynchronously( 354 m_mainScriptLoader->loadAsynchronously(
355 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, 355 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL,
356 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, 356 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr,
357 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, 357 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished,
358 WTF::unretained(this))); 358 WTF::unretained(this)));
359 // Do nothing here since onScriptLoaderFinished() might have been already 359 // Do nothing here since onScriptLoaderFinished() might have been already
360 // invoked and |this| might have been deleted at this point. 360 // invoked and |this| might have been deleted at this point.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 *this, *document, *m_workerContextClient); 479 *this, *document, *m_workerContextClient);
480 m_loaderProxy = WorkerLoaderProxy::create(this); 480 m_loaderProxy = WorkerLoaderProxy::create(this);
481 m_workerThread = 481 m_workerThread =
482 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); 482 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy);
483 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); 483 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get());
484 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), 484 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
485 scriptURL); 485 scriptURL);
486 } 486 }
487 487
488 } // namespace blink 488 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h ('k') | third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698