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

Unified Diff: WebCore/storage/DatabaseTracker.h

Issue 596028: Make the DatabaseTracker thread-safe. (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/
Patch Set: '' Created 10 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 | « WebCore/storage/DatabaseThread.cpp ('k') | WebCore/storage/DatabaseTracker.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebCore/storage/DatabaseTracker.h
===================================================================
--- WebCore/storage/DatabaseTracker.h (revision 55036)
+++ WebCore/storage/DatabaseTracker.h (working copy)
@@ -60,9 +60,11 @@
class DatabaseTracker : public Noncopyable {
public:
static DatabaseTracker& tracker();
- // FIXME: Due to workers having multiple threads in a single process sharing
- // a DatabaseTracker, this singleton will have to be synchronized or moved
- // to TLS.
+ // This singleton will potentially be used from multiple worker threads and the page's context thread simultaneously. To keep this safe, it's
+ // currently using 4 locks. In order to avoid deadlock when taking multiple locks, you must take them in the correct order:
+ // originQuotaManager() before m_databaseGuard or m_openDatabaseMapGuard
+ // m_databaseGuard before m_openDatabaseMapGuard
+ // notificationMutex() is currently independent of the other locks.
bool canEstablishDatabase(ScriptExecutionContext*, const String& name, const String& displayName, unsigned long estimatedSize);
void setDatabaseDetails(SecurityOrigin*, const String& name, const String& displayName, unsigned long estimatedSize);
@@ -87,7 +89,7 @@
#if !PLATFORM(CHROMIUM)
public:
void setDatabaseDirectoryPath(const String&);
- const String& databaseDirectoryPath() const;
+ String databaseDirectoryPath() const;
void origins(Vector<RefPtr<SecurityOrigin> >& result);
bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result);
@@ -114,6 +116,13 @@
bool hasEntryForOrigin(SecurityOrigin*);
private:
+ OriginQuotaManager& originQuotaManagerNoLock();
+ bool hasEntryForOriginNoLock(SecurityOrigin* origin);
+ String fullPathForDatabaseNoLock(SecurityOrigin*, const String& name, bool createIfDoesNotExist);
+ bool databaseNamesForOriginNoLock(SecurityOrigin* origin, Vector<String>& resultVector);
+ unsigned long long usageForOriginNoLock(SecurityOrigin* origin);
+ unsigned long long quotaForOriginNoLock(SecurityOrigin* origin);
+
String trackerDatabasePath() const;
void openTrackerDatabase(bool createIfDoesNotExist);
@@ -126,10 +135,11 @@
bool deleteDatabaseFile(SecurityOrigin*, const String& name);
+ // This lock protects m_database, m_quotaMap, and m_proposedDatabases.
+ Mutex m_databaseGuard;
SQLiteDatabase m_database;
typedef HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash> QuotaMap;
- Mutex m_quotaMapGuard;
mutable OwnPtr<QuotaMap> m_quotaMap;
OwnPtr<OriginQuotaManager> m_quotaManager;
@@ -138,12 +148,9 @@
DatabaseTrackerClient* m_client;
- std::pair<SecurityOrigin*, DatabaseDetails>* m_proposedDatabase;
+ typedef std::pair<SecurityOrigin*, DatabaseDetails> ProposedDatabase;
+ HashSet<ProposedDatabase*> m_proposedDatabases;
-#ifndef NDEBUG
- ThreadIdentifier m_thread;
-#endif
-
static void scheduleForNotification();
static void notifyDatabasesChanged(void*);
#endif // !PLATFORM(CHROMIUM)
« no previous file with comments | « WebCore/storage/DatabaseThread.cpp ('k') | WebCore/storage/DatabaseTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698