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

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

Issue 183883005: DatabaseBackend objects should be destructed in the originator thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Delete copy in cleanupDatabaseThread 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 4f7ceabd5e1ce719699417f8a268b6e5ba62fbc7..9c83d901cffedbf0c7f8d8049805c9a9d61b4afd 100644
--- a/Source/modules/webdatabase/DatabaseThread.cpp
+++ b/Source/modules/webdatabase/DatabaseThread.cpp
@@ -48,6 +48,8 @@ DatabaseThread::DatabaseThread()
DatabaseThread::~DatabaseThread()
{
+ ASSERT(m_thread);
+ ASSERT(!isDatabaseThread());
bool terminationRequested;
{
MutexLocker lock(m_terminationRequestedMutex);
@@ -96,11 +98,8 @@ void DatabaseThread::cleanupDatabaseThread()
// 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) {
- // 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)
+ DatabaseSet::iterator end = m_openDatabaseSet.end();
+ for (DatabaseSet::iterator it = m_openDatabaseSet.begin(); it != end; ++it)
(*it).get()->close();
}
@@ -122,17 +121,9 @@ void DatabaseThread::recordDatabaseClosed(DatabaseBackend* database)
MutexLocker lock(m_terminationRequestedMutex);
#endif
ASSERT(isDatabaseThread());
- ASSERT(database);
+ ASSERT_UNUSED(database, database);
ASSERT(m_terminationRequested || m_openDatabaseSet.contains(database));
- m_openDatabaseSet.remove(database);
-}
-
-bool DatabaseThread::isDatabaseOpen(DatabaseBackend* database)
-{
- ASSERT(isDatabaseThread());
- ASSERT(database);
- MutexLocker lock(m_terminationRequestedMutex);
- return !m_terminationRequested && m_openDatabaseSet.contains(database);
+ // We'll clear m_openDatabaseSet in the destructor.
}
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