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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 bool DatabaseThread::isDatabaseOpen(Database* database) | 148 bool DatabaseThread::isDatabaseOpen(Database* database) |
149 { | 149 { |
150 ASSERT(isDatabaseThread()); | 150 ASSERT(isDatabaseThread()); |
151 ASSERT(database); | 151 ASSERT(database); |
152 MutexLocker lock(m_terminationRequestedMutex); | 152 MutexLocker lock(m_terminationRequestedMutex); |
153 return !m_terminationRequested && m_openDatabaseSet.contains(database); | 153 return !m_terminationRequested && m_openDatabaseSet.contains(database); |
154 } | 154 } |
155 | 155 |
| 156 bool DatabaseThread::isDatabaseOpen(CrossThreadPersistent<Database> database) |
| 157 { |
| 158 DCHECK(isDatabaseThread()); |
| 159 DCHECK(database); |
| 160 MutexLocker lock(m_terminationRequestedMutex); |
| 161 return !m_terminationRequested && m_openDatabaseSet.contains(database); |
| 162 } |
| 163 |
156 bool DatabaseThread::isDatabaseThread() const | 164 bool DatabaseThread::isDatabaseThread() const |
157 { | 165 { |
158 // This function is called only from the main thread or the database | 166 // 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. | 167 // thread. If we are not in the main thread, we are in the database thread. |
160 return !isMainThread(); | 168 return !isMainThread(); |
161 } | 169 } |
162 | 170 |
163 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) | 171 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) |
164 { | 172 { |
165 ASSERT(m_thread); | 173 ASSERT(m_thread); |
166 #if ENABLE(ASSERT) | 174 #if ENABLE(ASSERT) |
167 { | 175 { |
168 MutexLocker lock(m_terminationRequestedMutex); | 176 MutexLocker lock(m_terminationRequestedMutex); |
169 ASSERT(!m_terminationRequested); | 177 ASSERT(!m_terminationRequested); |
170 } | 178 } |
171 #endif | 179 #endif |
172 // WebThread takes ownership of the task. | 180 // WebThread takes ownership of the task. |
173 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseTask::run, std::
move(task))); | 181 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseTask::run, std::
move(task))); |
174 } | 182 } |
175 | 183 |
176 } // namespace blink | 184 } // namespace blink |
OLD | NEW |