| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) OVERRID
E | 120 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) OVERRID
E |
| 121 { | 121 { |
| 122 toWebLocalFrameImpl(m_embeddedWorker.m_mainFrame)->frame()->document()->
postTask(task); | 122 toWebLocalFrameImpl(m_embeddedWorker.m_mainFrame)->frame()->document()->
postTask(task); |
| 123 } | 123 } |
| 124 | 124 |
| 125 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask> ta
sk) OVERRIDE | 125 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask> ta
sk) OVERRIDE |
| 126 { | 126 { |
| 127 if (m_embeddedWorker.m_askedToTerminate || !m_embeddedWorker.m_workerThr
ead) | 127 if (m_embeddedWorker.m_askedToTerminate || !m_embeddedWorker.m_workerThr
ead) |
| 128 return false; | 128 return false; |
| 129 return m_embeddedWorker.m_workerThread->runLoop().postTask(task); | 129 m_embeddedWorker.m_workerThread->postTask(task); |
| 130 return !m_embeddedWorker.m_workerThread->terminated(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 private: | 133 private: |
| 133 explicit LoaderProxy(WebEmbeddedWorkerImpl& embeddedWorker) | 134 explicit LoaderProxy(WebEmbeddedWorkerImpl& embeddedWorker) |
| 134 : m_embeddedWorker(embeddedWorker) | 135 : m_embeddedWorker(embeddedWorker) |
| 135 { | 136 { |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Not owned, embedded worker owns this. | 139 // Not owned, embedded worker owns this. |
| 139 WebEmbeddedWorkerImpl& m_embeddedWorker; | 140 WebEmbeddedWorkerImpl& m_embeddedWorker; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 ASSERT(!m_askedToTerminate); | 234 ASSERT(!m_askedToTerminate); |
| 234 bool wasPaused = (m_pauseAfterDownloadState == IsPausedAfterDownload); | 235 bool wasPaused = (m_pauseAfterDownloadState == IsPausedAfterDownload); |
| 235 m_pauseAfterDownloadState = DontPauseAfterDownload; | 236 m_pauseAfterDownloadState = DontPauseAfterDownload; |
| 236 if (wasPaused) | 237 if (wasPaused) |
| 237 startWorkerThread(); | 238 startWorkerThread(); |
| 238 } | 239 } |
| 239 | 240 |
| 240 void WebEmbeddedWorkerImpl::resumeWorkerContext() | 241 void WebEmbeddedWorkerImpl::resumeWorkerContext() |
| 241 { | 242 { |
| 242 if (m_workerThread) | 243 if (m_workerThread) |
| 243 m_workerThread->runLoop().postDebuggerTask(createCrossThreadTask(resumeW
orkerContextTask, true)); | 244 m_workerThread->postDebuggerTask(createCrossThreadTask(resumeWorkerConte
xtTask, true)); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void WebEmbeddedWorkerImpl::attachDevTools() | 247 void WebEmbeddedWorkerImpl::attachDevTools() |
| 247 { | 248 { |
| 248 if (m_workerThread) | 249 if (m_workerThread) |
| 249 m_workerThread->runLoop().postDebuggerTask(createCrossThreadTask(connect
ToWorkerContextInspectorTask, true)); | 250 m_workerThread->postDebuggerTask(createCrossThreadTask(connectToWorkerCo
ntextInspectorTask, true)); |
| 250 } | 251 } |
| 251 | 252 |
| 252 void WebEmbeddedWorkerImpl::reattachDevTools(const WebString& savedState) | 253 void WebEmbeddedWorkerImpl::reattachDevTools(const WebString& savedState) |
| 253 { | 254 { |
| 254 m_workerThread->runLoop().postDebuggerTask(createCrossThreadTask(reconnectTo
WorkerContextInspectorTask, String(savedState))); | 255 m_workerThread->postDebuggerTask(createCrossThreadTask(reconnectToWorkerCont
extInspectorTask, String(savedState))); |
| 255 } | 256 } |
| 256 | 257 |
| 257 void WebEmbeddedWorkerImpl::detachDevTools() | 258 void WebEmbeddedWorkerImpl::detachDevTools() |
| 258 { | 259 { |
| 259 m_workerThread->runLoop().postDebuggerTask(createCrossThreadTask(disconnectF
romWorkerContextInspectorTask, true)); | 260 m_workerThread->postDebuggerTask(createCrossThreadTask(disconnectFromWorkerC
ontextInspectorTask, true)); |
| 260 } | 261 } |
| 261 | 262 |
| 262 void WebEmbeddedWorkerImpl::dispatchDevToolsMessage(const WebString& message) | 263 void WebEmbeddedWorkerImpl::dispatchDevToolsMessage(const WebString& message) |
| 263 { | 264 { |
| 264 m_workerThread->runLoop().postDebuggerTask(createCrossThreadTask(dispatchOnI
nspectorBackendTask, String(message))); | 265 m_workerThread->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa
ckendTask, String(message))); |
| 265 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(m_workerThread.ge
t()); | 266 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(m_workerThread.ge
t()); |
| 266 } | 267 } |
| 267 | 268 |
| 268 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() | 269 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() |
| 269 { | 270 { |
| 270 // Create 'shadow page', which is never displayed and is used mainly to | 271 // Create 'shadow page', which is never displayed and is used mainly to |
| 271 // provide a context for loading on the main thread. | 272 // provide a context for loading on the main thread. |
| 272 // | 273 // |
| 273 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader. | 274 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader. |
| 274 // This code, and probably most of the code in this class should be shared | 275 // This code, and probably most of the code in this class should be shared |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 m_mainScriptLoader.clear(); | 360 m_mainScriptLoader.clear(); |
| 360 | 361 |
| 361 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebLocalFrameImpl(m_mainFrame)->frame()->document(), *m_workerContextClient); | 362 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW
ebLocalFrameImpl(m_mainFrame)->frame()->document(), *m_workerContextClient); |
| 362 m_loaderProxy = LoaderProxy::create(*this); | 363 m_loaderProxy = LoaderProxy::create(*this); |
| 363 | 364 |
| 364 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); | 365 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); |
| 365 m_workerThread->start(); | 366 m_workerThread->start(); |
| 366 } | 367 } |
| 367 | 368 |
| 368 } // namespace blink | 369 } // namespace blink |
| OLD | NEW |