| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ASSERT(database); | 131 ASSERT(database); |
| 132 ASSERT(!m_openDatabaseSet.contains(database)); | 132 ASSERT(!m_openDatabaseSet.contains(database)); |
| 133 MutexLocker lock(m_terminationRequestedMutex); | 133 MutexLocker lock(m_terminationRequestedMutex); |
| 134 if (!m_terminationRequested) | 134 if (!m_terminationRequested) |
| 135 m_openDatabaseSet.add(database); | 135 m_openDatabaseSet.add(database); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void DatabaseThread::recordDatabaseClosed(Database* database) { | 138 void DatabaseThread::recordDatabaseClosed(Database* database) { |
| 139 ASSERT(isDatabaseThread()); | 139 ASSERT(isDatabaseThread()); |
| 140 ASSERT(database); | 140 ASSERT(database); |
| 141 #if ENABLE(ASSERT) | 141 #if DCHECK_IS_ON() |
| 142 { | 142 { |
| 143 MutexLocker lock(m_terminationRequestedMutex); | 143 MutexLocker lock(m_terminationRequestedMutex); |
| 144 ASSERT(m_terminationRequested || m_openDatabaseSet.contains(database)); | 144 ASSERT(m_terminationRequested || m_openDatabaseSet.contains(database)); |
| 145 } | 145 } |
| 146 #endif | 146 #endif |
| 147 m_openDatabaseSet.remove(database); | 147 m_openDatabaseSet.remove(database); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool DatabaseThread::isDatabaseOpen(Database* database) { | 150 bool DatabaseThread::isDatabaseOpen(Database* database) { |
| 151 ASSERT(isDatabaseThread()); | 151 ASSERT(isDatabaseThread()); |
| 152 ASSERT(database); | 152 ASSERT(database); |
| 153 MutexLocker lock(m_terminationRequestedMutex); | 153 MutexLocker lock(m_terminationRequestedMutex); |
| 154 return !m_terminationRequested && m_openDatabaseSet.contains(database); | 154 return !m_terminationRequested && m_openDatabaseSet.contains(database); |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool DatabaseThread::isDatabaseThread() const { | 157 bool DatabaseThread::isDatabaseThread() const { |
| 158 // This function is called only from the main thread or the database | 158 // This function is called only from the main thread or the database |
| 159 // thread. If we are not in the main thread, we are in the database thread. | 159 // thread. If we are not in the main thread, we are in the database thread. |
| 160 return !isMainThread(); | 160 return !isMainThread(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void DatabaseThread::scheduleTask(std::unique_ptr<DatabaseTask> task) { | 163 void DatabaseThread::scheduleTask(std::unique_ptr<DatabaseTask> task) { |
| 164 ASSERT(m_thread); | 164 ASSERT(m_thread); |
| 165 #if ENABLE(ASSERT) | 165 #if DCHECK_IS_ON() |
| 166 { | 166 { |
| 167 MutexLocker lock(m_terminationRequestedMutex); | 167 MutexLocker lock(m_terminationRequestedMutex); |
| 168 ASSERT(!m_terminationRequested); | 168 ASSERT(!m_terminationRequested); |
| 169 } | 169 } |
| 170 #endif | 170 #endif |
| 171 // WebThread takes ownership of the task. | 171 // WebThread takes ownership of the task. |
| 172 m_thread->postTask(BLINK_FROM_HERE, | 172 m_thread->postTask(BLINK_FROM_HERE, |
| 173 crossThreadBind(&DatabaseTask::run, std::move(task))); | 173 crossThreadBind(&DatabaseTask::run, std::move(task))); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |