OLD | NEW |
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 175 } |
176 | 176 |
177 void WebSharedWorkerImpl::stopWorkerThread() | 177 void WebSharedWorkerImpl::stopWorkerThread() |
178 { | 178 { |
179 if (m_askedToTerminate) | 179 if (m_askedToTerminate) |
180 return; | 180 return; |
181 m_askedToTerminate = true; | 181 m_askedToTerminate = true; |
182 if (m_mainScriptLoader) { | 182 if (m_mainScriptLoader) { |
183 m_mainScriptLoader->cancel(); | 183 m_mainScriptLoader->cancel(); |
184 m_mainScriptLoader.clear(); | 184 m_mainScriptLoader.clear(); |
| 185 if (client()) |
| 186 client()->workerScriptLoadFailed(); |
| 187 delete this; |
| 188 return; |
185 } | 189 } |
186 if (m_workerThread) | 190 if (m_workerThread) |
187 m_workerThread->stop(); | 191 m_workerThread->stop(); |
188 } | 192 } |
189 | 193 |
190 void WebSharedWorkerImpl::initializeLoader(const WebURL& url) | 194 void WebSharedWorkerImpl::initializeLoader(const WebURL& url) |
191 { | 195 { |
192 // Create 'shadow page'. This page is never displayed, it is used to proxy t
he | 196 // Create 'shadow page'. This page is never displayed, it is used to proxy t
he |
193 // loading requests from the worker context to the rest of WebKit and Chromi
um | 197 // loading requests from the worker context to the rest of WebKit and Chromi
um |
194 // infrastructure. | 198 // infrastructure. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 344 |
341 static void connectToWorkerContextInspectorTask(ExecutionContext* context, bool) | 345 static void connectToWorkerContextInspectorTask(ExecutionContext* context, bool) |
342 { | 346 { |
343 toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend()
; | 347 toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend()
; |
344 } | 348 } |
345 | 349 |
346 void WebSharedWorkerImpl::onScriptLoaderFinished() | 350 void WebSharedWorkerImpl::onScriptLoaderFinished() |
347 { | 351 { |
348 ASSERT(m_loadingDocument); | 352 ASSERT(m_loadingDocument); |
349 ASSERT(m_mainScriptLoader); | 353 ASSERT(m_mainScriptLoader); |
350 if (m_mainScriptLoader->failed() || m_askedToTerminate) { | 354 if (m_askedToTerminate) |
| 355 return; |
| 356 if (m_mainScriptLoader->failed()) { |
351 m_mainScriptLoader->cancel(); | 357 m_mainScriptLoader->cancel(); |
352 if (client()) | 358 if (client()) |
353 client()->workerScriptLoadFailed(); | 359 client()->workerScriptLoadFailed(); |
354 | 360 |
355 // The SharedWorker was unable to load the initial script, so | 361 // The SharedWorker was unable to load the initial script, so |
356 // shut it down right here unless we're here handling a load | 362 // shut it down right here. |
357 // cancellation failure triggered by an explicit shared worker | 363 delete this; |
358 // termination call (via terminateWorkerContext().) | |
359 if (!m_askedToTerminate) | |
360 delete this; | |
361 return; | 364 return; |
362 } | 365 } |
363 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG
lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; | 366 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG
lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; |
364 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); | 367 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
365 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); | 368 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); |
366 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat
e()); | 369 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat
e()); |
367 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 370 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
368 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea
teWorkerPermissionClientProxy(webSecurityOrigin))); | 371 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea
teWorkerPermissionClientProxy(webSecurityOrigin))); |
369 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc
ript(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHea
derType>(m_policyType), workerClients.release()); | 372 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc
ript(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHea
derType>(m_policyType), workerClients.release()); |
370 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData
.release())); | 373 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData
.release())); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 workerThread()->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa
ckendTask, String(message))); | 452 workerThread()->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa
ckendTask, String(message))); |
450 workerThread()->interruptAndDispatchInspectorCommands(); | 453 workerThread()->interruptAndDispatchInspectorCommands(); |
451 } | 454 } |
452 | 455 |
453 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 456 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
454 { | 457 { |
455 return new WebSharedWorkerImpl(client); | 458 return new WebSharedWorkerImpl(client); |
456 } | 459 } |
457 | 460 |
458 } // namespace blink | 461 } // namespace blink |
OLD | NEW |