| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 prepareShadowPageForLoader(); | 180 prepareShadowPageForLoader(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void WebEmbeddedWorkerImpl::terminateWorkerContext() | 183 void WebEmbeddedWorkerImpl::terminateWorkerContext() |
| 184 { | 184 { |
| 185 if (m_askedToTerminate) | 185 if (m_askedToTerminate) |
| 186 return; | 186 return; |
| 187 m_askedToTerminate = true; | 187 m_askedToTerminate = true; |
| 188 if (m_mainScriptLoader) | 188 if (m_mainScriptLoader) |
| 189 m_mainScriptLoader->cancel(); | 189 m_mainScriptLoader->cancel(); |
| 190 if (m_pauseAfterDownloadState == IsPausedAfterDownload) { |
| 191 // This may delete 'this'. |
| 192 m_workerContextClient->workerContextFailedToStart(); |
| 193 return; |
| 194 } |
| 190 if (m_workerThread) | 195 if (m_workerThread) |
| 191 m_workerThread->stop(); | 196 m_workerThread->stop(); |
| 192 } | 197 } |
| 193 | 198 |
| 194 namespace { | 199 namespace { |
| 195 | 200 |
| 196 void resumeWorkerContextTask(ExecutionContext* context, bool) | 201 void resumeWorkerContextTask(ExecutionContext* context, bool) |
| 197 { | 202 { |
| 198 toWorkerGlobalScope(context)->workerInspectorController()->resume(); | 203 toWorkerGlobalScope(context)->workerInspectorController()->resume(); |
| 199 } | 204 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 217 | 222 |
| 218 void dispatchOnInspectorBackendTask(ExecutionContext* context, const String& mes
sage) | 223 void dispatchOnInspectorBackendTask(ExecutionContext* context, const String& mes
sage) |
| 219 { | 224 { |
| 220 toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFr
omFrontend(message); | 225 toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFr
omFrontend(message); |
| 221 } | 226 } |
| 222 | 227 |
| 223 } // namespace | 228 } // namespace |
| 224 | 229 |
| 225 void WebEmbeddedWorkerImpl::resumeAfterDownload() | 230 void WebEmbeddedWorkerImpl::resumeAfterDownload() |
| 226 { | 231 { |
| 232 ASSERT(!m_askedToTerminate); |
| 227 bool wasPaused = (m_pauseAfterDownloadState == IsPausedAfterDownload); | 233 bool wasPaused = (m_pauseAfterDownloadState == IsPausedAfterDownload); |
| 228 m_pauseAfterDownloadState = DontPauseAfterDownload; | 234 m_pauseAfterDownloadState = DontPauseAfterDownload; |
| 229 if (wasPaused) | 235 if (wasPaused) |
| 230 startWorkerThread(); | 236 startWorkerThread(); |
| 231 } | 237 } |
| 232 | 238 |
| 233 void WebEmbeddedWorkerImpl::resumeWorkerContext() | 239 void WebEmbeddedWorkerImpl::resumeWorkerContext() |
| 234 { | 240 { |
| 235 if (m_workerThread) | 241 if (m_workerThread) |
| 236 m_workerThread->runLoop().postDebuggerTask(createCallbackTask(resumeWork
erContextTask, true)); | 242 m_workerThread->runLoop().postDebuggerTask(createCallbackTask(resumeWork
erContextTask, true)); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 m_pauseAfterDownloadState = IsPausedAfterDownload; | 327 m_pauseAfterDownloadState = IsPausedAfterDownload; |
| 322 m_workerContextClient->didPauseAfterDownload(); | 328 m_workerContextClient->didPauseAfterDownload(); |
| 323 return; | 329 return; |
| 324 } | 330 } |
| 325 startWorkerThread(); | 331 startWorkerThread(); |
| 326 } | 332 } |
| 327 | 333 |
| 328 void WebEmbeddedWorkerImpl::startWorkerThread() | 334 void WebEmbeddedWorkerImpl::startWorkerThread() |
| 329 { | 335 { |
| 330 ASSERT(m_pauseAfterDownloadState == DontPauseAfterDownload); | 336 ASSERT(m_pauseAfterDownloadState == DontPauseAfterDownload); |
| 331 if (m_askedToTerminate) | 337 ASSERT(!m_askedToTerminate); |
| 332 return; | |
| 333 | 338 |
| 334 WorkerThreadStartMode startMode = | 339 WorkerThreadStartMode startMode = |
| 335 (m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::Wa
itForDebugger) | 340 (m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::Wa
itForDebugger) |
| 336 ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; | 341 ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; |
| 337 | 342 |
| 338 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 343 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
| 339 providePermissionClientToWorker(workerClients.get(), m_permissionClient.rele
ase()); | 344 providePermissionClientToWorker(workerClients.get(), m_permissionClient.rele
ase()); |
| 340 provideServiceWorkerGlobalScopeClientToWorker(workerClients.get(), ServiceWo
rkerGlobalScopeClientImpl::create(*m_workerContextClient)); | 345 provideServiceWorkerGlobalScopeClientToWorker(workerClients.get(), ServiceWo
rkerGlobalScopeClientImpl::create(*m_workerContextClient)); |
| 341 | 346 |
| 342 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = | 347 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 353 m_mainScriptLoader.clear(); | 358 m_mainScriptLoader.clear(); |
| 354 | 359 |
| 355 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebLocalFrameImpl(m_mainFrame)->frame()->document(), *m_workerContextClient); | 360 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebLocalFrameImpl(m_mainFrame)->frame()->document(), *m_workerContextClient); |
| 356 m_loaderProxy = LoaderProxy::create(*this); | 361 m_loaderProxy = LoaderProxy::create(*this); |
| 357 | 362 |
| 358 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); | 363 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); |
| 359 m_workerThread->start(); | 364 m_workerThread->start(); |
| 360 } | 365 } |
| 361 | 366 |
| 362 } // namespace blink | 367 } // namespace blink |
| OLD | NEW |