OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2013 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 void DatabaseThread::requestTermination(TaskSynchronizer *cleanupSync) | 84 void DatabaseThread::requestTermination(TaskSynchronizer *cleanupSync) |
85 { | 85 { |
86 MutexLocker lock(m_terminationRequestedMutex); | 86 MutexLocker lock(m_terminationRequestedMutex); |
87 ASSERT(!m_terminationRequested); | 87 ASSERT(!m_terminationRequested); |
88 m_terminationRequested = true; | 88 m_terminationRequested = true; |
89 m_cleanupSync = cleanupSync; | 89 m_cleanupSync = cleanupSync; |
90 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); | 90 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); |
91 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread
, this))); | 91 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread
, this))); |
92 } | 92 } |
93 | 93 |
94 bool DatabaseThread::terminationRequested() const | 94 bool DatabaseThread::terminationRequested(TaskSynchronizer* taskSynchronizer) co
nst |
95 { | 95 { |
| 96 #if ENABLE(ASSERT) |
| 97 if (taskSynchronizer) |
| 98 taskSynchronizer->setHasCheckedForTermination(); |
| 99 #endif |
| 100 |
96 MutexLocker lock(m_terminationRequestedMutex); | 101 MutexLocker lock(m_terminationRequestedMutex); |
97 return m_terminationRequested; | 102 return m_terminationRequested; |
98 } | 103 } |
99 | 104 |
100 void DatabaseThread::cleanupDatabaseThread() | 105 void DatabaseThread::cleanupDatabaseThread() |
101 { | 106 { |
102 WTF_LOG(StorageAPI, "Cleaning up DatabaseThread %p", this); | 107 WTF_LOG(StorageAPI, "Cleaning up DatabaseThread %p", this); |
103 | 108 |
104 // Clean up the list of all pending transactions on this database thread | 109 // Clean up the list of all pending transactions on this database thread |
105 m_transactionCoordinator->shutdown(); | 110 m_transactionCoordinator->shutdown(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 { | 150 { |
146 ASSERT(isDatabaseThread()); | 151 ASSERT(isDatabaseThread()); |
147 ASSERT(database); | 152 ASSERT(database); |
148 MutexLocker lock(m_terminationRequestedMutex); | 153 MutexLocker lock(m_terminationRequestedMutex); |
149 return !m_terminationRequested && m_openDatabaseSet.contains(database); | 154 return !m_terminationRequested && m_openDatabaseSet.contains(database); |
150 } | 155 } |
151 | 156 |
152 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) | 157 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) |
153 { | 158 { |
154 ASSERT(m_thread); | 159 ASSERT(m_thread); |
155 ASSERT(!terminationRequested()); | 160 ASSERT(!task->hasSynchronizer() || task->hasCheckedForTermination()); |
156 // WebThread takes ownership of the task. | 161 // WebThread takes ownership of the task. |
157 m_thread->postTask(task.leakPtr()); | 162 m_thread->postTask(task.leakPtr()); |
158 } | 163 } |
159 | 164 |
160 } // namespace blink | 165 } // namespace blink |
OLD | NEW |