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

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

Issue 214163004: Oilpan: Move database closing task in ~DatabaseBackendSync to a pre-finalization hook with HeapHash… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a FIXME comment Created 6 years, 9 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/DatabaseContext.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/DatabaseContext.cpp
diff --git a/Source/modules/webdatabase/DatabaseContext.cpp b/Source/modules/webdatabase/DatabaseContext.cpp
index 4a63b9c78518ea8291cb556da0bb08332dd7f9f8..ec01219a4f5f62df6696b9855ecc38f75543a8e8 100644
--- a/Source/modules/webdatabase/DatabaseContext.cpp
+++ b/Source/modules/webdatabase/DatabaseContext.cpp
@@ -170,17 +170,30 @@ void DatabaseContext::didOpenDatabase(DatabaseBackendBase& database)
if (!database.isSyncDatabase())
return;
ASSERT(isContextThread());
+#if ENABLE(OILPAN)
+ m_openSyncDatabases.add(&database, adoptPtr(new DatabaseCloser(database)));
+#else
m_openSyncDatabases.add(&database);
+#endif
}
void DatabaseContext::didCloseDatabase(DatabaseBackendBase& database)
{
+#if !ENABLE(OILPAN)
if (!database.isSyncDatabase())
return;
ASSERT(isContextThread());
m_openSyncDatabases.remove(&database);
+#endif
}
+#if ENABLE(OILPAN)
+DatabaseContext::DatabaseCloser::~DatabaseCloser()
+{
+ m_database.closeImmediately();
+}
+#endif
+
void DatabaseContext::stopSyncDatabases()
{
// SQLite is "multi-thread safe", but each database handle can only be used
@@ -191,11 +204,20 @@ void DatabaseContext::stopSyncDatabases()
// thread. This means that the SQLite database need to be closed here in the
// destructor.
ASSERT(isContextThread());
+#if ENABLE(OILPAN)
+ // FIXME: We need to clear OwnPtr<> in the HeapHashMap explicitly.
+ // HeapHashMap::clear() doesn't destruct values
+ // immediately. crbug.com/357113.
+ for (PersistentHeapHashMap<WeakMember<DatabaseBackendBase>, OwnPtr<DatabaseCloser> >::iterator i = m_openSyncDatabases.begin(); i != m_openSyncDatabases.end(); ++i)
+ (*i).value.clear();
+ m_openSyncDatabases.clear();
+#else
Vector<DatabaseBackendBase*> syncDatabases;
copyToVector(m_openSyncDatabases, syncDatabases);
m_openSyncDatabases.clear();
for (size_t i = 0; i < syncDatabases.size(); ++i)
syncDatabases[i]->closeImmediately();
+#endif
}
void DatabaseContext::stopDatabases()
« no previous file with comments | « Source/modules/webdatabase/DatabaseContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698