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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "core/workers/WorkerLoaderProxy.h" | 44 #include "core/workers/WorkerLoaderProxy.h" |
45 #include "core/workers/WorkerScriptLoader.h" | 45 #include "core/workers/WorkerScriptLoader.h" |
46 #include "core/workers/WorkerScriptLoaderClient.h" | 46 #include "core/workers/WorkerScriptLoaderClient.h" |
47 #include "core/workers/WorkerThreadStartupData.h" | 47 #include "core/workers/WorkerThreadStartupData.h" |
48 #include "modules/serviceworkers/ServiceWorkerThread.h" | 48 #include "modules/serviceworkers/ServiceWorkerThread.h" |
49 #include "platform/SharedBuffer.h" | 49 #include "platform/SharedBuffer.h" |
50 #include "platform/heap/Handle.h" | 50 #include "platform/heap/Handle.h" |
51 #include "platform/network/ContentSecurityPolicyParsers.h" | 51 #include "platform/network/ContentSecurityPolicyParsers.h" |
52 #include "public/platform/Platform.h" | 52 #include "public/platform/Platform.h" |
53 #include "public/platform/WebURLRequest.h" | 53 #include "public/platform/WebURLRequest.h" |
54 #include "public/platform/WebWaitableEvent.h" | |
54 #include "public/web/WebDevToolsAgent.h" | 55 #include "public/web/WebDevToolsAgent.h" |
55 #include "public/web/WebServiceWorkerContextClient.h" | 56 #include "public/web/WebServiceWorkerContextClient.h" |
56 #include "public/web/WebServiceWorkerNetworkProvider.h" | 57 #include "public/web/WebServiceWorkerNetworkProvider.h" |
57 #include "public/web/WebSettings.h" | 58 #include "public/web/WebSettings.h" |
58 #include "public/web/WebView.h" | 59 #include "public/web/WebView.h" |
59 #include "public/web/WebWorkerPermissionClientProxy.h" | 60 #include "public/web/WebWorkerPermissionClientProxy.h" |
60 #include "web/ServiceWorkerGlobalScopeClientImpl.h" | 61 #include "web/ServiceWorkerGlobalScopeClientImpl.h" |
61 #include "web/ServiceWorkerGlobalScopeProxy.h" | 62 #include "web/ServiceWorkerGlobalScopeProxy.h" |
62 #include "web/WebDataSourceImpl.h" | 63 #include "web/WebDataSourceImpl.h" |
63 #include "web/WebLocalFrameImpl.h" | 64 #include "web/WebLocalFrameImpl.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 , m_mainFrame(0) | 165 , m_mainFrame(0) |
165 , m_askedToTerminate(false) | 166 , m_askedToTerminate(false) |
166 , m_pauseAfterDownloadState(DontPauseAfterDownload) | 167 , m_pauseAfterDownloadState(DontPauseAfterDownload) |
167 , m_waitingForDebuggerState(NotWaitingForDebugger) | 168 , m_waitingForDebuggerState(NotWaitingForDebugger) |
168 { | 169 { |
169 runningWorkerInstances().add(this); | 170 runningWorkerInstances().add(this); |
170 } | 171 } |
171 | 172 |
172 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() | 173 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() |
173 { | 174 { |
175 if (m_workerThread) { | |
176 m_workerThread->stop(); | |
177 m_workerThread->terminationEvent()->wait(); | |
haraken
2014/10/30 02:40:24
Can we create a helper method like WorkerThread::t
Kunihiko Sakamoto
2014/10/30 04:50:15
Done.
| |
178 } | |
haraken
2014/10/30 02:40:24
Don't you need to call m_workerInspectorProxy->wor
Kunihiko Sakamoto
2014/10/30 04:50:15
No - WebEmbeddedWorkerImpl::terminateWorkerContext
| |
179 | |
174 ASSERT(runningWorkerInstances().contains(this)); | 180 ASSERT(runningWorkerInstances().contains(this)); |
175 runningWorkerInstances().remove(this); | 181 runningWorkerInstances().remove(this); |
176 ASSERT(m_webView); | 182 ASSERT(m_webView); |
177 | 183 |
178 // Detach the client before closing the view to avoid getting called back. | 184 // Detach the client before closing the view to avoid getting called back. |
179 toWebLocalFrameImpl(m_mainFrame)->setClient(0); | 185 toWebLocalFrameImpl(m_mainFrame)->setClient(0); |
180 | 186 |
181 m_webView->close(); | 187 m_webView->close(); |
182 m_mainFrame->close(); | 188 m_mainFrame->close(); |
183 } | 189 } |
(...skipping 29 matching lines...) Expand all Loading... | |
213 // This may delete 'this'. | 219 // This may delete 'this'. |
214 m_workerContextClient->workerContextFailedToStart(); | 220 m_workerContextClient->workerContextFailedToStart(); |
215 return; | 221 return; |
216 } | 222 } |
217 if (m_pauseAfterDownloadState == IsPausedAfterDownload) { | 223 if (m_pauseAfterDownloadState == IsPausedAfterDownload) { |
218 // This may delete 'this'. | 224 // This may delete 'this'. |
219 m_workerContextClient->workerContextFailedToStart(); | 225 m_workerContextClient->workerContextFailedToStart(); |
220 return; | 226 return; |
221 } | 227 } |
222 if (m_workerThread) | 228 if (m_workerThread) |
223 m_workerThread->stop(); | 229 m_workerThread->stop(); |
haraken
2014/10/30 02:40:24
Not related to your CL, I wonder why you don't nee
Kunihiko Sakamoto
2014/10/30 04:50:15
Worker thread can do its pending and cleanup tasks
| |
224 m_workerInspectorProxy->workerThreadTerminated(); | 230 m_workerInspectorProxy->workerThreadTerminated(); |
225 } | 231 } |
226 | 232 |
227 void WebEmbeddedWorkerImpl::resumeAfterDownload() | 233 void WebEmbeddedWorkerImpl::resumeAfterDownload() |
228 { | 234 { |
229 ASSERT(!m_askedToTerminate); | 235 ASSERT(!m_askedToTerminate); |
230 bool wasPaused = (m_pauseAfterDownloadState == IsPausedAfterDownload); | 236 bool wasPaused = (m_pauseAfterDownloadState == IsPausedAfterDownload); |
231 m_pauseAfterDownloadState = DontPauseAfterDownload; | 237 m_pauseAfterDownloadState = DontPauseAfterDownload; |
232 | 238 |
233 // If we were asked to wait for debugger while updating service worker versi on then it is good time now. | 239 // If we were asked to wait for debugger while updating service worker versi on then it is good time now. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 m_mainScriptLoader.clear(); | 426 m_mainScriptLoader.clear(); |
421 | 427 |
422 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); | 428 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); |
423 m_loaderProxy = LoaderProxy::create(*this); | 429 m_loaderProxy = LoaderProxy::create(*this); |
424 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release()); | 430 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release()); |
425 m_workerThread->start(); | 431 m_workerThread->start(); |
426 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); | 432 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); |
427 } | 433 } |
428 | 434 |
429 } // namespace blink | 435 } // namespace blink |
OLD | NEW |