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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); | 197 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); |
198 | 198 |
199 // Construct substitute data source for the 'shadow page'. We only need it | 199 // 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. | 200 // to have same origin as the worker so the loading checks work correctly. |
201 CString content(""); | 201 CString content(""); |
202 int length = static_cast<int>(content.length()); | 202 int length = static_cast<int>(content.length()); |
203 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); | 203 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()))); | 204 webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_worke
rStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL()))); |
205 } | 205 } |
206 | 206 |
| 207 void WebEmbeddedWorkerImpl::willSendRequest( |
| 208 WebFrame* frame, unsigned, WebURLRequest& request, |
| 209 const WebURLResponse& redirectResponse) |
| 210 { |
| 211 if (m_networkProvider) |
| 212 m_networkProvider->willSendRequest(frame->dataSource(), request, redirec
tResponse); |
| 213 } |
| 214 |
207 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebFrame* frame) | 215 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebFrame* frame) |
208 { | 216 { |
209 ASSERT(!m_mainScriptLoader); | 217 ASSERT(!m_mainScriptLoader); |
| 218 ASSERT(!m_networkProvider); |
210 ASSERT(m_mainFrame); | 219 ASSERT(m_mainFrame); |
| 220 ASSERT(m_workerContextClient); |
| 221 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo
rkProvider(frame->dataSource())); |
211 m_mainScriptLoader = Loader::create(); | 222 m_mainScriptLoader = Loader::create(); |
212 m_mainScriptLoader->load( | 223 m_mainScriptLoader->load( |
213 toWebFrameImpl(m_mainFrame)->frame()->document(), | 224 toWebFrameImpl(m_mainFrame)->frame()->document(), |
214 m_workerStartData.scriptURL, | 225 m_workerStartData.scriptURL, |
215 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); | 226 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); |
216 } | 227 } |
217 | 228 |
218 void WebEmbeddedWorkerImpl::onScriptLoaderFinished() | 229 void WebEmbeddedWorkerImpl::onScriptLoaderFinished() |
219 { | 230 { |
220 ASSERT(m_mainScriptLoader); | 231 ASSERT(m_mainScriptLoader); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 m_mainScriptLoader.clear(); | 263 m_mainScriptLoader.clear(); |
253 | 264 |
254 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebFrameImpl(m_mainFrame)->frame()->document(), *contextClient); | 265 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebFrameImpl(m_mainFrame)->frame()->document(), *contextClient); |
255 m_loaderProxy = LoaderProxy::create(*this); | 266 m_loaderProxy = LoaderProxy::create(*this); |
256 | 267 |
257 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); | 268 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); |
258 m_workerThread->start(); | 269 m_workerThread->start(); |
259 } | 270 } |
260 | 271 |
261 } // namespace blink | 272 } // namespace blink |
OLD | NEW |