Make DatabaseTrackerChromium::removeOpenDatabase() send and IPC on
[WebKit-https.git] / WebCore / storage / chromium / DatabaseTrackerChromium.cpp
index 24ed642d6f619ee0f38bb5c721f79c95bd212687..7556e3da6044aa51c7cd8c036025c3ac348091ac 100644 (file)
@@ -40,6 +40,7 @@
 #include "SecurityOrigin.h"
 #include "SQLiteFileSystem.h"
 #include <wtf/HashSet.h>
+#include <wtf/StdLibExtras.h>
 
 namespace WebCore {
 
@@ -68,7 +69,7 @@ void DatabaseTracker::setDatabaseDetails(SecurityOrigin*, const String&, const S
 
 String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool)
 {
-    return origin->databaseIdentifier() + "/" + name;
+    return origin->databaseIdentifier() + "/" + name + "#";
 }
 
 void DatabaseTracker::addOpenDatabase(Database* database)
@@ -76,14 +77,25 @@ void DatabaseTracker::addOpenDatabase(Database* database)
     ASSERT(isMainThread());
     DatabaseObserver::databaseOpened(database);
 }
+static void removeOpenDatabaseOnMainThread(void* context)
+{
+    Database* database = static_cast<Database*>(context);
+    DatabaseTracker::tracker().removeOpenDatabase(database);
+    database->deref();
+}
 
 void DatabaseTracker::removeOpenDatabase(Database* database)
 {
-    ASSERT(isMainThread());
+    if (!isMainThread()) {
+        database->ref();
+        callOnMainThread(removeOpenDatabaseOnMainThread, database);
+        return;
+    }
+
     DatabaseObserver::databaseClosed(database);
 }
 
-unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* database) const
+unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* database)
 {
     ASSERT(currentThread() == database->document()->databaseThread()->getThreadID());
     unsigned long long spaceAvailable = 0;