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

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

Issue 194073002: Identify service worker version at main resource load time (BlinkSide) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/web/WebEmbeddedWorkerImpl.h ('k') | public/web/WebServiceWorkerContextClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "WebEmbeddedWorkerImpl.h" 32 #include "WebEmbeddedWorkerImpl.h"
33 33
34 #include "ServiceWorkerGlobalScopeClientImpl.h" 34 #include "ServiceWorkerGlobalScopeClientImpl.h"
35 #include "ServiceWorkerGlobalScopeProxy.h" 35 #include "ServiceWorkerGlobalScopeProxy.h"
36 #include "WebDataSourceImpl.h" 36 #include "WebDataSourceImpl.h"
37 #include "WebFrameImpl.h" 37 #include "WebFrameImpl.h"
38 #include "WebServiceWorkerContextClient.h" 38 #include "WebServiceWorkerContextClient.h"
39 #include "WebServiceWorkerNetworkProvider.h"
39 #include "WebView.h" 40 #include "WebView.h"
40 #include "WebWorkerPermissionClientProxy.h" 41 #include "WebWorkerPermissionClientProxy.h"
41 #include "WorkerPermissionClient.h" 42 #include "WorkerPermissionClient.h"
42 #include "core/dom/Document.h" 43 #include "core/dom/Document.h"
43 #include "core/loader/FrameLoadRequest.h" 44 #include "core/loader/FrameLoadRequest.h"
44 #include "core/loader/SubstituteData.h" 45 #include "core/loader/SubstituteData.h"
45 #include "core/workers/WorkerClients.h" 46 #include "core/workers/WorkerClients.h"
46 #include "core/workers/WorkerLoaderProxy.h" 47 #include "core/workers/WorkerLoaderProxy.h"
47 #include "core/workers/WorkerScriptLoader.h" 48 #include "core/workers/WorkerScriptLoader.h"
48 #include "core/workers/WorkerScriptLoaderClient.h" 49 #include "core/workers/WorkerScriptLoaderClient.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); 198 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame());
198 199
199 // Construct substitute data source for the 'shadow page'. We only need it 200 // Construct substitute data source for the 'shadow page'. We only need it
200 // to have same origin as the worker so the loading checks work correctly. 201 // to have same origin as the worker so the loading checks work correctly.
201 CString content(""); 202 CString content("");
202 int length = static_cast<int>(content.length()); 203 int length = static_cast<int>(content.length());
203 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); 204 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length));
204 webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_worke rStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL()))); 205 webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_worke rStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL())));
205 } 206 }
206 207
208 void WebEmbeddedWorkerImpl::willSendRequest(
209 WebFrame* frame, unsigned, WebURLRequest& request,
210 const WebURLResponse& redirectResponse)
211 {
212 if (m_networkProvider)
213 m_networkProvider->willSendRequest(frame->dataSource(), request, redirec tResponse);
kinuko 2014/03/17 05:21:06 nit: you need to drop redirectResponse param here
michaeln 2014/03/17 17:44:04 Done. (ooops)
214 }
215
207 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebFrame* frame) 216 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebFrame* frame)
208 { 217 {
209 ASSERT(!m_mainScriptLoader); 218 ASSERT(!m_mainScriptLoader);
219 ASSERT(!m_networkProvider);
210 ASSERT(m_mainFrame); 220 ASSERT(m_mainFrame);
221 ASSERT(m_workerContextClient);
222 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo rkProvider(frame->dataSource()));
211 m_mainScriptLoader = Loader::create(); 223 m_mainScriptLoader = Loader::create();
212 m_mainScriptLoader->load( 224 m_mainScriptLoader->load(
213 toWebFrameImpl(m_mainFrame)->frame()->document(), 225 toWebFrameImpl(m_mainFrame)->frame()->document(),
214 m_workerStartData.scriptURL, 226 m_workerStartData.scriptURL,
215 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); 227 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this));
216 } 228 }
217 229
218 void WebEmbeddedWorkerImpl::onScriptLoaderFinished() 230 void WebEmbeddedWorkerImpl::onScriptLoaderFinished()
219 { 231 {
220 ASSERT(m_mainScriptLoader); 232 ASSERT(m_mainScriptLoader);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 m_mainScriptLoader.clear(); 264 m_mainScriptLoader.clear();
253 265
254 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW ebFrameImpl(m_mainFrame)->frame()->document(), *contextClient); 266 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW ebFrameImpl(m_mainFrame)->frame()->document(), *contextClient);
255 m_loaderProxy = LoaderProxy::create(*this); 267 m_loaderProxy = LoaderProxy::create(*this);
256 268
257 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release()); 269 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release());
258 m_workerThread->start(); 270 m_workerThread->start();
259 } 271 }
260 272
261 } // namespace blink 273 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebEmbeddedWorkerImpl.h ('k') | public/web/WebServiceWorkerContextClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698