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

Side by Side Diff: Source/WebCore/workers/WorkerThread.cpp

Issue 13774005: Remove the ENABLE_SQL_DATABASE compile-time flag. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: python Created 7 years, 8 months 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/WebCore/page/ChromeClient.h ('k') | Source/WebKit/chromium/features.gypi » ('j') | 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 28
29 #if ENABLE(WORKERS) 29 #if ENABLE(WORKERS)
30 30
31 #include "WorkerThread.h" 31 #include "WorkerThread.h"
32 32
33 #include "DatabaseManager.h"
34 #include "DatabaseTask.h"
33 #include "DedicatedWorkerContext.h" 35 #include "DedicatedWorkerContext.h"
34 #include "InspectorInstrumentation.h" 36 #include "InspectorInstrumentation.h"
35 #include "KURL.h" 37 #include "KURL.h"
36 #include "ScriptSourceCode.h" 38 #include "ScriptSourceCode.h"
37 #include "ScriptValue.h" 39 #include "ScriptValue.h"
38 #include "ThreadGlobalData.h" 40 #include "ThreadGlobalData.h"
39 41
40 #include <utility> 42 #include <utility>
41 #include <wtf/Noncopyable.h> 43 #include <wtf/Noncopyable.h>
42 #include <wtf/text/WTFString.h> 44 #include <wtf/text/WTFString.h>
43 45
44 #if ENABLE(SQL_DATABASE)
45 #include "DatabaseManager.h"
46 #include "DatabaseTask.h"
47 #endif
48 46
49 #if PLATFORM(CHROMIUM) 47 #if PLATFORM(CHROMIUM)
50 #include <public/Platform.h> 48 #include <public/Platform.h>
51 #include <public/WebWorkerRunLoop.h> 49 #include <public/WebWorkerRunLoop.h>
52 #endif 50 #endif
53 51
54 namespace WebCore { 52 namespace WebCore {
55 53
56 static Mutex& threadSetMutex() 54 static Mutex& threadSetMutex()
57 { 55 {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 static PassOwnPtr<WorkerThreadShutdownStartTask> create() 218 static PassOwnPtr<WorkerThreadShutdownStartTask> create()
221 { 219 {
222 return adoptPtr(new WorkerThreadShutdownStartTask()); 220 return adoptPtr(new WorkerThreadShutdownStartTask());
223 } 221 }
224 222
225 virtual void performTask(ScriptExecutionContext *context) 223 virtual void performTask(ScriptExecutionContext *context)
226 { 224 {
227 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext()); 225 ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext());
228 WorkerContext* workerContext = static_cast<WorkerContext*>(context); 226 WorkerContext* workerContext = static_cast<WorkerContext*>(context);
229 227
230 #if ENABLE(SQL_DATABASE)
231 // FIXME: Should we stop the databases as part of stopActiveDOMObjects() below? 228 // FIXME: Should we stop the databases as part of stopActiveDOMObjects() below?
232 DatabaseTaskSynchronizer cleanupSync; 229 DatabaseTaskSynchronizer cleanupSync;
233 DatabaseManager::manager().stopDatabases(workerContext, &cleanupSync); 230 DatabaseManager::manager().stopDatabases(workerContext, &cleanupSync);
234 #endif
235 231
236 workerContext->stopActiveDOMObjects(); 232 workerContext->stopActiveDOMObjects();
237 233
238 workerContext->notifyObserversOfStop(); 234 workerContext->notifyObserversOfStop();
239 235
240 // Event listeners would keep DOMWrapperWorld objects alive for too long . Also, they have references to JS objects, 236 // Event listeners would keep DOMWrapperWorld objects alive for too long . Also, they have references to JS objects,
241 // which become dangling once Heap is destroyed. 237 // which become dangling once Heap is destroyed.
242 workerContext->removeAllEventListeners(); 238 workerContext->removeAllEventListeners();
243 239
244 #if ENABLE(SQL_DATABASE)
245 // We wait for the database thread to clean up all its stuff so that we 240 // We wait for the database thread to clean up all its stuff so that we
246 // can do more stringent leak checks as we exit. 241 // can do more stringent leak checks as we exit.
247 cleanupSync.waitForTaskCompletion(); 242 cleanupSync.waitForTaskCompletion();
248 #endif
249 243
250 // Stick a shutdown command at the end of the queue, so that we deal 244 // Stick a shutdown command at the end of the queue, so that we deal
251 // with all the cleanup tasks the databases post first. 245 // with all the cleanup tasks the databases post first.
252 workerContext->postTask(WorkerThreadShutdownFinishTask::create()); 246 workerContext->postTask(WorkerThreadShutdownFinishTask::create());
253 } 247 }
254 248
255 virtual bool isCleanupTask() const { return true; } 249 virtual bool isCleanupTask() const { return true; }
256 }; 250 };
257 251
258 void WorkerThread::stop() 252 void WorkerThread::stop()
259 { 253 {
260 // Mutex protection is necessary because stop() can be called before the con text is fully created. 254 // Mutex protection is necessary because stop() can be called before the con text is fully created.
261 MutexLocker lock(m_threadCreationMutex); 255 MutexLocker lock(m_threadCreationMutex);
262 256
263 // Ensure that tasks are being handled by thread event loop. If script execu tion weren't forbidden, a while(1) loop in JS could keep the thread alive foreve r. 257 // Ensure that tasks are being handled by thread event loop. If script execu tion weren't forbidden, a while(1) loop in JS could keep the thread alive foreve r.
264 if (m_workerContext) { 258 if (m_workerContext) {
265 m_workerContext->script()->scheduleExecutionTermination(); 259 m_workerContext->script()->scheduleExecutionTermination();
266 260
267 #if ENABLE(SQL_DATABASE)
268 DatabaseManager::manager().interruptAllDatabasesForContext(m_workerConte xt.get()); 261 DatabaseManager::manager().interruptAllDatabasesForContext(m_workerConte xt.get());
269 #endif
270 m_runLoop.postTaskAndTerminate(WorkerThreadShutdownStartTask::create()); 262 m_runLoop.postTaskAndTerminate(WorkerThreadShutdownStartTask::create());
271 return; 263 return;
272 } 264 }
273 m_runLoop.terminate(); 265 m_runLoop.terminate();
274 } 266 }
275 267
276 class ReleaseFastMallocFreeMemoryTask : public ScriptExecutionContext::Task { 268 class ReleaseFastMallocFreeMemoryTask : public ScriptExecutionContext::Task {
277 virtual void performTask(ScriptExecutionContext*) OVERRIDE { WTF::releaseFas tMallocFreeMemory(); } 269 virtual void performTask(ScriptExecutionContext*) OVERRIDE { WTF::releaseFas tMallocFreeMemory(); }
278 }; 270 };
279 271
280 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() 272 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads()
281 { 273 {
282 MutexLocker lock(threadSetMutex()); 274 MutexLocker lock(threadSetMutex());
283 HashSet<WorkerThread*>& threads = workerThreads(); 275 HashSet<WorkerThread*>& threads = workerThreads();
284 HashSet<WorkerThread*>::iterator end = threads.end(); 276 HashSet<WorkerThread*>::iterator end = threads.end();
285 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) 277 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it)
286 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; 278 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ;
287 } 279 }
288 280
289 } // namespace WebCore 281 } // namespace WebCore
290 282
291 #endif // ENABLE(WORKERS) 283 #endif // ENABLE(WORKERS)
OLDNEW
« no previous file with comments | « Source/WebCore/page/ChromeClient.h ('k') | Source/WebKit/chromium/features.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698