| Index: Source/modules/webdatabase/DatabaseThread.cpp
|
| diff --git a/Source/modules/webdatabase/DatabaseThread.cpp b/Source/modules/webdatabase/DatabaseThread.cpp
|
| index 9c83d901cffedbf0c7f8d8049805c9a9d61b4afd..4f7ceabd5e1ce719699417f8a268b6e5ba62fbc7 100644
|
| --- a/Source/modules/webdatabase/DatabaseThread.cpp
|
| +++ b/Source/modules/webdatabase/DatabaseThread.cpp
|
| @@ -48,8 +48,6 @@
|
|
|
| DatabaseThread::~DatabaseThread()
|
| {
|
| - ASSERT(m_thread);
|
| - ASSERT(!isDatabaseThread());
|
| bool terminationRequested;
|
| {
|
| MutexLocker lock(m_terminationRequestedMutex);
|
| @@ -98,8 +96,11 @@
|
| // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an
|
| // inconsistent or locked state.
|
| if (m_openDatabaseSet.size() > 0) {
|
| - DatabaseSet::iterator end = m_openDatabaseSet.end();
|
| - for (DatabaseSet::iterator it = m_openDatabaseSet.begin(); it != end; ++it)
|
| + // As the call to close will modify the original set, we must take a copy to iterate over.
|
| + DatabaseSet openSetCopy;
|
| + openSetCopy.swap(m_openDatabaseSet);
|
| + DatabaseSet::iterator end = openSetCopy.end();
|
| + for (DatabaseSet::iterator it = openSetCopy.begin(); it != end; ++it)
|
| (*it).get()->close();
|
| }
|
|
|
| @@ -121,9 +122,17 @@
|
| MutexLocker lock(m_terminationRequestedMutex);
|
| #endif
|
| ASSERT(isDatabaseThread());
|
| - ASSERT_UNUSED(database, database);
|
| + ASSERT(database);
|
| ASSERT(m_terminationRequested || m_openDatabaseSet.contains(database));
|
| - // We'll clear m_openDatabaseSet in the destructor.
|
| + m_openDatabaseSet.remove(database);
|
| +}
|
| +
|
| +bool DatabaseThread::isDatabaseOpen(DatabaseBackend* database)
|
| +{
|
| + ASSERT(isDatabaseThread());
|
| + ASSERT(database);
|
| + MutexLocker lock(m_terminationRequestedMutex);
|
| + return !m_terminationRequested && m_openDatabaseSet.contains(database);
|
| }
|
|
|
| void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task)
|
|
|