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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); | 136 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); |
| 137 return set; | 137 return set; |
| 138 } | 138 } |
| 139 | 139 |
| 140 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextC lient> client, PassOwnPtr<WebWorkerContentSettingsClientProxy> ContentSettingsCl ient) | 140 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextC lient> client, PassOwnPtr<WebWorkerContentSettingsClientProxy> ContentSettingsCl ient) |
| 141 : m_workerContextClient(client) | 141 : m_workerContextClient(client) |
| 142 , m_contentSettingsClient(ContentSettingsClient) | 142 , m_contentSettingsClient(ContentSettingsClient) |
| 143 , m_workerInspectorProxy(WorkerInspectorProxy::create()) | 143 , m_workerInspectorProxy(WorkerInspectorProxy::create()) |
| 144 , m_webView(0) | 144 , m_webView(0) |
| 145 , m_mainFrame(0) | 145 , m_mainFrame(0) |
| 146 , m_loadingShadowPage(false) | |
| 146 , m_askedToTerminate(false) | 147 , m_askedToTerminate(false) |
| 147 , m_pauseAfterDownloadState(DontPauseAfterDownload) | 148 , m_pauseAfterDownloadState(DontPauseAfterDownload) |
| 148 , m_waitingForDebuggerState(NotWaitingForDebugger) | 149 , m_waitingForDebuggerState(NotWaitingForDebugger) |
| 149 { | 150 { |
| 150 runningWorkerInstances().add(this); | 151 runningWorkerInstances().add(this); |
| 151 } | 152 } |
| 152 | 153 |
| 153 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() | 154 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() |
| 154 { | 155 { |
| 155 // Prevent onScriptLoaderFinished from deleting 'this'. | 156 // Prevent onScriptLoaderFinished from deleting 'this'. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDow nload) | 190 if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDow nload) |
| 190 m_pauseAfterDownloadState = DoPauseAfterDownload; | 191 m_pauseAfterDownloadState = DoPauseAfterDownload; |
| 191 prepareShadowPageForLoader(); | 192 prepareShadowPageForLoader(); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void WebEmbeddedWorkerImpl::terminateWorkerContext() | 195 void WebEmbeddedWorkerImpl::terminateWorkerContext() |
| 195 { | 196 { |
| 196 if (m_askedToTerminate) | 197 if (m_askedToTerminate) |
| 197 return; | 198 return; |
| 198 m_askedToTerminate = true; | 199 m_askedToTerminate = true; |
| 200 if (m_loadingShadowPage) { | |
| 201 // This may delete 'this'. | |
|
falken
2015/06/16 12:03:43
With the new assert we're really saying "This dele
horo
2015/06/16 23:20:59
Done.
| |
| 202 m_workerContextClient->workerContextFailedToStart(); | |
| 203 return; | |
| 204 } | |
| 199 if (m_mainScriptLoader) { | 205 if (m_mainScriptLoader) { |
| 200 m_mainScriptLoader->cancel(); | 206 m_mainScriptLoader->cancel(); |
| 201 m_mainScriptLoader.clear(); | 207 m_mainScriptLoader.clear(); |
| 202 // This may delete 'this'. | 208 // This may delete 'this'. |
| 203 m_workerContextClient->workerContextFailedToStart(); | 209 m_workerContextClient->workerContextFailedToStart(); |
| 204 return; | 210 return; |
| 205 } | 211 } |
| 206 if (m_pauseAfterDownloadState == IsPausedAfterDownload) { | 212 if (m_pauseAfterDownloadState == IsPausedAfterDownload) { |
| 207 // This may delete 'this'. | 213 // This may delete 'this'. |
| 208 m_workerContextClient->workerContextFailedToStart(); | 214 m_workerContextClient->workerContextFailedToStart(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 loadShadowPage(); | 325 loadShadowPage(); |
| 320 } | 326 } |
| 321 | 327 |
| 322 void WebEmbeddedWorkerImpl::loadShadowPage() | 328 void WebEmbeddedWorkerImpl::loadShadowPage() |
| 323 { | 329 { |
| 324 // Construct substitute data source for the 'shadow page'. We only need it | 330 // Construct substitute data source for the 'shadow page'. We only need it |
| 325 // to have same origin as the worker so the loading checks work correctly. | 331 // to have same origin as the worker so the loading checks work correctly. |
| 326 CString content(""); | 332 CString content(""); |
| 327 int length = static_cast<int>(content.length()); | 333 int length = static_cast<int>(content.length()); |
| 328 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); | 334 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); |
| 335 m_loadingShadowPage = true; | |
| 329 m_mainFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_wo rkerStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL()))) ; | 336 m_mainFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_wo rkerStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL()))) ; |
| 330 } | 337 } |
| 331 | 338 |
| 332 void WebEmbeddedWorkerImpl::willSendRequest( | 339 void WebEmbeddedWorkerImpl::willSendRequest( |
| 333 WebLocalFrame* frame, unsigned, WebURLRequest& request, | 340 WebLocalFrame* frame, unsigned, WebURLRequest& request, |
| 334 const WebURLResponse& redirectResponse) | 341 const WebURLResponse& redirectResponse) |
| 335 { | 342 { |
| 336 if (m_networkProvider) | 343 if (m_networkProvider) |
| 337 m_networkProvider->willSendRequest(frame->dataSource(), request); | 344 m_networkProvider->willSendRequest(frame->dataSource(), request); |
| 338 } | 345 } |
| 339 | 346 |
| 340 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) | 347 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) |
| 341 { | 348 { |
| 342 ASSERT(!m_mainScriptLoader); | 349 ASSERT(!m_mainScriptLoader); |
| 343 ASSERT(!m_networkProvider); | 350 ASSERT(!m_networkProvider); |
| 344 ASSERT(m_mainFrame); | 351 ASSERT(m_mainFrame); |
| 345 ASSERT(m_workerContextClient); | 352 ASSERT(m_workerContextClient); |
| 353 ASSERT(m_loadingShadowPage); | |
| 354 ASSERT(!m_askedToTerminate); | |
| 355 m_loadingShadowPage = false; | |
| 346 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo rkProvider(frame->dataSource())); | 356 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo rkProvider(frame->dataSource())); |
| 347 m_mainScriptLoader = Loader::create(); | 357 m_mainScriptLoader = Loader::create(); |
| 348 m_mainScriptLoader->load( | 358 m_mainScriptLoader->load( |
| 349 m_mainFrame->frame()->document(), | 359 m_mainFrame->frame()->document(), |
| 350 m_workerStartData.scriptURL, | 360 m_workerStartData.scriptURL, |
| 351 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); | 361 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); |
| 352 } | 362 } |
| 353 | 363 |
| 354 void WebEmbeddedWorkerImpl::sendProtocolMessage(int callId, const WebString& mes sage, const WebString& state) | 364 void WebEmbeddedWorkerImpl::sendProtocolMessage(int callId, const WebString& mes sage, const WebString& state) |
| 355 { | 365 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 m_mainScriptLoader.clear(); | 439 m_mainScriptLoader.clear(); |
| 430 | 440 |
| 431 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); | 441 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); |
| 432 m_loaderProxy = WorkerLoaderProxy::create(this); | 442 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 433 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); | 443 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); |
| 434 m_workerThread->start(startupData.release()); | 444 m_workerThread->start(startupData.release()); |
| 435 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); | 445 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); |
| 436 } | 446 } |
| 437 | 447 |
| 438 } // namespace blink | 448 } // namespace blink |
| OLD | NEW |