| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "core/workers/WorkerThread.h" | 29 #include "core/workers/WorkerThread.h" |
| 30 | 30 |
| 31 #include "bindings/v8/ScriptSourceCode.h" | 31 #include "bindings/v8/ScriptSourceCode.h" |
| 32 #include "core/inspector/InspectorInstrumentation.h" | 32 #include "core/inspector/InspectorInstrumentation.h" |
| 33 #include "core/workers/DedicatedWorkerGlobalScope.h" | 33 #include "core/workers/DedicatedWorkerGlobalScope.h" |
| 34 #include "core/workers/WorkerClients.h" | 34 #include "core/workers/WorkerClients.h" |
| 35 #include "core/workers/WorkerReportingProxy.h" | 35 #include "core/workers/WorkerReportingProxy.h" |
| 36 #include "core/workers/WorkerThreadStartupData.h" | 36 #include "core/workers/WorkerThreadStartupData.h" |
| 37 #include "heap/ThreadState.h" | 37 #include "heap/ThreadState.h" |
| 38 #include "modules/webdatabase/DatabaseManager.h" | |
| 39 #include "platform/PlatformThreadData.h" | 38 #include "platform/PlatformThreadData.h" |
| 40 #include "platform/weborigin/KURL.h" | 39 #include "platform/weborigin/KURL.h" |
| 41 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebWaitableEvent.h" | 41 #include "public/platform/WebWaitableEvent.h" |
| 43 #include "public/platform/WebWorkerRunLoop.h" | 42 #include "public/platform/WebWorkerRunLoop.h" |
| 44 #include "wtf/Noncopyable.h" | 43 #include "wtf/Noncopyable.h" |
| 45 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
| 46 | 45 |
| 47 #include <utility> | 46 #include <utility> |
| 48 | 47 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Mutex protection is necessary because stop() can be called before the con
text is fully created. | 211 // Mutex protection is necessary because stop() can be called before the con
text is fully created. |
| 213 MutexLocker lock(m_threadCreationMutex); | 212 MutexLocker lock(m_threadCreationMutex); |
| 214 | 213 |
| 215 // Signal the thread to notify that the thread's stopping. | 214 // Signal the thread to notify that the thread's stopping. |
| 216 if (m_shutdownEvent) | 215 if (m_shutdownEvent) |
| 217 m_shutdownEvent->signal(); | 216 m_shutdownEvent->signal(); |
| 218 | 217 |
| 219 // 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. | 218 // 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. |
| 220 if (m_workerGlobalScope) { | 219 if (m_workerGlobalScope) { |
| 221 m_workerGlobalScope->script()->scheduleExecutionTermination(); | 220 m_workerGlobalScope->script()->scheduleExecutionTermination(); |
| 222 | 221 m_workerGlobalScope->willStopActiveDOMObjects(); |
| 223 DatabaseManager::manager().interruptAllDatabasesForContext(m_workerGloba
lScope.get()); | |
| 224 m_runLoop.postTaskAndTerminate(WorkerThreadShutdownStartTask::create()); | 222 m_runLoop.postTaskAndTerminate(WorkerThreadShutdownStartTask::create()); |
| 225 return; | 223 return; |
| 226 } | 224 } |
| 227 m_runLoop.terminate(); | 225 m_runLoop.terminate(); |
| 228 } | 226 } |
| 229 | 227 |
| 230 bool WorkerThread::isCurrentThread() const | 228 bool WorkerThread::isCurrentThread() const |
| 231 { | 229 { |
| 232 return m_threadID == currentThread(); | 230 return m_threadID == currentThread(); |
| 233 } | 231 } |
| 234 | 232 |
| 235 class ReleaseFastMallocFreeMemoryTask : public ExecutionContextTask { | 233 class ReleaseFastMallocFreeMemoryTask : public ExecutionContextTask { |
| 236 virtual void performTask(ExecutionContext*) OVERRIDE { WTF::releaseFastMallo
cFreeMemory(); } | 234 virtual void performTask(ExecutionContext*) OVERRIDE { WTF::releaseFastMallo
cFreeMemory(); } |
| 237 }; | 235 }; |
| 238 | 236 |
| 239 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() | 237 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() |
| 240 { | 238 { |
| 241 MutexLocker lock(threadSetMutex()); | 239 MutexLocker lock(threadSetMutex()); |
| 242 HashSet<WorkerThread*>& threads = workerThreads(); | 240 HashSet<WorkerThread*>& threads = workerThreads(); |
| 243 HashSet<WorkerThread*>::iterator end = threads.end(); | 241 HashSet<WorkerThread*>::iterator end = threads.end(); |
| 244 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) | 242 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) |
| 245 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask))
; | 243 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask))
; |
| 246 } | 244 } |
| 247 | 245 |
| 248 } // namespace WebCore | 246 } // namespace WebCore |
| OLD | NEW |