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

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

Issue 2733283004: Expose WebServiceWorkerNetworkProvider on DataSource (Closed)
Patch Set: . 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) 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "platform/heap/Persistent.h" 52 #include "platform/heap/Persistent.h"
53 #include "platform/network/ContentSecurityPolicyParsers.h" 53 #include "platform/network/ContentSecurityPolicyParsers.h"
54 #include "platform/network/ResourceResponse.h" 54 #include "platform/network/ResourceResponse.h"
55 #include "platform/weborigin/KURL.h" 55 #include "platform/weborigin/KURL.h"
56 #include "platform/weborigin/SecurityOrigin.h" 56 #include "platform/weborigin/SecurityOrigin.h"
57 #include "public/platform/Platform.h" 57 #include "public/platform/Platform.h"
58 #include "public/platform/WebMessagePortChannel.h" 58 #include "public/platform/WebMessagePortChannel.h"
59 #include "public/platform/WebString.h" 59 #include "public/platform/WebString.h"
60 #include "public/platform/WebURL.h" 60 #include "public/platform/WebURL.h"
61 #include "public/platform/WebURLRequest.h" 61 #include "public/platform/WebURLRequest.h"
62 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h"
62 #include "public/web/WebDevToolsAgent.h" 63 #include "public/web/WebDevToolsAgent.h"
63 #include "public/web/WebFrame.h" 64 #include "public/web/WebFrame.h"
64 #include "public/web/WebSettings.h" 65 #include "public/web/WebSettings.h"
65 #include "public/web/WebView.h" 66 #include "public/web/WebView.h"
66 #include "public/web/WebWorkerContentSettingsClientProxy.h" 67 #include "public/web/WebWorkerContentSettingsClientProxy.h"
67 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h"
68 #include "web/IndexedDBClientImpl.h" 68 #include "web/IndexedDBClientImpl.h"
69 #include "web/LocalFileSystemClient.h" 69 #include "web/LocalFileSystemClient.h"
70 #include "web/WebDataSourceImpl.h" 70 #include "web/WebDataSourceImpl.h"
71 #include "web/WebLocalFrameImpl.h" 71 #include "web/WebLocalFrameImpl.h"
72 #include "web/WorkerContentSettingsClient.h" 72 #include "web/WorkerContentSettingsClient.h"
73 #include "wtf/Functional.h" 73 #include "wtf/Functional.h"
74 #include "wtf/PtrUtil.h" 74 #include "wtf/PtrUtil.h"
75 75
76 namespace blink { 76 namespace blink {
77 77
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 CString content(""); 163 CString content("");
164 RefPtr<SharedBuffer> buffer( 164 RefPtr<SharedBuffer> buffer(
165 SharedBuffer::create(content.data(), content.length())); 165 SharedBuffer::create(content.data(), content.length()));
166 m_mainFrame->frame()->loader().load( 166 m_mainFrame->frame()->loader().load(
167 FrameLoadRequest(0, ResourceRequest(m_url), 167 FrameLoadRequest(0, ResourceRequest(m_url),
168 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); 168 SubstituteData(buffer, "text/html", "UTF-8", KURL())));
169 } 169 }
170 170
171 void WebSharedWorkerImpl::willSendRequest(WebLocalFrame* frame, 171 void WebSharedWorkerImpl::willSendRequest(WebLocalFrame* frame,
172 WebURLRequest& request) { 172 WebURLRequest& request) {
173 DCHECK(isMainThread()); 173 auto networkProvider = frame->dataSource()->getServiceWorkerNetworkProvider();
dcheng 2017/03/10 04:48:38 Nit: auto* (this is checked automatically in Chrom
kinuko 2017/03/10 05:52:29 Done.
174 if (m_networkProvider) 174 if (networkProvider)
175 m_networkProvider->willSendRequest(frame->dataSource(), request); 175 networkProvider->willSendRequest(request);
176 } 176 }
177 177
178 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { 178 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) {
179 DCHECK(isMainThread()); 179 DCHECK(isMainThread());
180 DCHECK(!m_loadingDocument); 180 DCHECK(!m_loadingDocument);
181 DCHECK(!m_mainScriptLoader); 181 DCHECK(!m_mainScriptLoader);
182 m_networkProvider = WTF::wrapUnique( 182 frame->dataSource()->setServiceWorkerNetworkProvider(
183 m_client->createServiceWorkerNetworkProvider(frame->dataSource())); 183 WTF::wrapUnique(m_client->createServiceWorkerNetworkProvider()));
184 m_mainScriptLoader = WorkerScriptLoader::create(); 184 m_mainScriptLoader = WorkerScriptLoader::create();
185 m_mainScriptLoader->setRequestContext( 185 m_mainScriptLoader->setRequestContext(
186 WebURLRequest::RequestContextSharedWorker); 186 WebURLRequest::RequestContextSharedWorker);
187 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); 187 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document();
188 188
189 CrossOriginRequestPolicy crossOriginRequestPolicy = 189 CrossOriginRequestPolicy crossOriginRequestPolicy =
190 (static_cast<KURL>(m_url)).protocolIsData() ? AllowCrossOriginRequests 190 (static_cast<KURL>(m_url)).protocolIsData() ? AllowCrossOriginRequests
191 : DenyCrossOriginRequests; 191 : DenyCrossOriginRequests;
192 192
193 m_mainScriptLoader->loadAsynchronously( 193 m_mainScriptLoader->loadAsynchronously(
194 *m_loadingDocument.get(), m_url, crossOriginRequestPolicy, 194 *m_loadingDocument.get(), m_url, crossOriginRequestPolicy,
195 m_creationAddressSpace, 195 m_creationAddressSpace,
196 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, 196 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse,
197 WTF::unretained(this)), 197 WTF::unretained(this)),
198 bind(&WebSharedWorkerImpl::onScriptLoaderFinished, 198 bind(&WebSharedWorkerImpl::onScriptLoaderFinished,
199 WTF::unretained(this))); 199 WTF::unretained(this)));
200 // Do nothing here since onScriptLoaderFinished() might have been already 200 // Do nothing here since onScriptLoaderFinished() might have been already
201 // invoked and |this| might have been deleted at this point. 201 // invoked and |this| might have been deleted at this point.
202 } 202 }
203 203
204 bool WebSharedWorkerImpl::isControlledByServiceWorker(
205 WebDataSource& dataSource) {
206 DCHECK(isMainThread());
207 return m_networkProvider &&
208 m_networkProvider->isControlledByServiceWorker(dataSource);
209 }
210
211 int64_t WebSharedWorkerImpl::serviceWorkerID(WebDataSource& dataSource) {
212 DCHECK(isMainThread());
213 if (!m_networkProvider)
214 return -1;
215 return m_networkProvider->serviceWorkerID(dataSource);
216 }
217
218 void WebSharedWorkerImpl::sendProtocolMessage(int sessionId, 204 void WebSharedWorkerImpl::sendProtocolMessage(int sessionId,
219 int callId, 205 int callId,
220 const WebString& message, 206 const WebString& message,
221 const WebString& state) { 207 const WebString& state) {
222 DCHECK(isMainThread()); 208 DCHECK(isMainThread());
223 m_client->sendDevToolsMessage(sessionId, callId, message, state); 209 m_client->sendDevToolsMessage(sessionId, callId, message, state);
224 } 210 }
225 211
226 void WebSharedWorkerImpl::resumeStartup() { 212 void WebSharedWorkerImpl::resumeStartup() {
227 DCHECK(isMainThread()); 213 DCHECK(isMainThread());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (devtoolsAgent) 425 if (devtoolsAgent)
440 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, 426 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method,
441 message); 427 message);
442 } 428 }
443 429
444 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { 430 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) {
445 return new WebSharedWorkerImpl(client); 431 return new WebSharedWorkerImpl(client);
446 } 432 }
447 433
448 } // namespace blink 434 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698