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