Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1788)

Unified Diff: Source/modules/webdatabase/DatabaseThread.cpp

Issue 178103007: Revert of DatabaseBackend objects should be destructed in the originator thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webdatabase/DatabaseThread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/modules/webdatabase/DatabaseThread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698