Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: Source/web/WebEmbeddedWorkerImpl.cpp

Issue 704063002: Terminate and wait the worker thread in ~WebEmbeddedWorkerImpl() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerThread.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
55 #include "public/web/WebDevToolsAgent.h" 54 #include "public/web/WebDevToolsAgent.h"
56 #include "public/web/WebServiceWorkerContextClient.h" 55 #include "public/web/WebServiceWorkerContextClient.h"
57 #include "public/web/WebServiceWorkerNetworkProvider.h" 56 #include "public/web/WebServiceWorkerNetworkProvider.h"
58 #include "public/web/WebSettings.h" 57 #include "public/web/WebSettings.h"
59 #include "public/web/WebView.h" 58 #include "public/web/WebView.h"
60 #include "public/web/WebWorkerPermissionClientProxy.h" 59 #include "public/web/WebWorkerPermissionClientProxy.h"
61 #include "web/ServiceWorkerGlobalScopeClientImpl.h" 60 #include "web/ServiceWorkerGlobalScopeClientImpl.h"
62 #include "web/ServiceWorkerGlobalScopeProxy.h" 61 #include "web/ServiceWorkerGlobalScopeProxy.h"
63 #include "web/WebDataSourceImpl.h" 62 #include "web/WebDataSourceImpl.h"
64 #include "web/WebLocalFrameImpl.h" 63 #include "web/WebLocalFrameImpl.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 , m_mainFrame(0) 164 , m_mainFrame(0)
166 , m_askedToTerminate(false) 165 , m_askedToTerminate(false)
167 , m_pauseAfterDownloadState(DontPauseAfterDownload) 166 , m_pauseAfterDownloadState(DontPauseAfterDownload)
168 , m_waitingForDebuggerState(NotWaitingForDebugger) 167 , m_waitingForDebuggerState(NotWaitingForDebugger)
169 { 168 {
170 runningWorkerInstances().add(this); 169 runningWorkerInstances().add(this);
171 } 170 }
172 171
173 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() 172 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl()
174 { 173 {
175 if (m_workerThread) { 174 if (m_workerThread)
176 ASSERT(m_workerThread->terminated()); 175 m_workerThread->terminateAndWait();
177 m_workerThread->terminationEvent()->wait();
178 }
179 176
180 ASSERT(runningWorkerInstances().contains(this)); 177 ASSERT(runningWorkerInstances().contains(this));
181 runningWorkerInstances().remove(this); 178 runningWorkerInstances().remove(this);
182 ASSERT(m_webView); 179 ASSERT(m_webView);
183 180
184 // Detach the client before closing the view to avoid getting called back. 181 // Detach the client before closing the view to avoid getting called back.
185 toWebLocalFrameImpl(m_mainFrame)->setClient(0); 182 toWebLocalFrameImpl(m_mainFrame)->setClient(0);
186 183
187 m_webView->close(); 184 m_webView->close();
188 m_mainFrame->close(); 185 m_mainFrame->close();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 m_mainScriptLoader.clear(); 423 m_mainScriptLoader.clear();
427 424
428 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); 425 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient);
429 m_loaderProxy = LoaderProxy::create(*this); 426 m_loaderProxy = LoaderProxy::create(*this);
430 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release()); 427 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release());
431 m_workerThread->start(); 428 m_workerThread->start();
432 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); 429 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL);
433 } 430 }
434 431
435 } // namespace blink 432 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerThread.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698