summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/webdatabase/DatabaseThread.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/Modules/webdatabase/DatabaseThread.h')
-rw-r--r--Source/WebCore/Modules/webdatabase/DatabaseThread.h56
1 files changed, 18 insertions, 38 deletions
diff --git a/Source/WebCore/Modules/webdatabase/DatabaseThread.h b/Source/WebCore/Modules/webdatabase/DatabaseThread.h
index c05979e5a..ec041e318 100644
--- a/Source/WebCore/Modules/webdatabase/DatabaseThread.h
+++ b/Source/WebCore/Modules/webdatabase/DatabaseThread.h
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -25,82 +25,62 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DatabaseThread_h
-#define DatabaseThread_h
-#if ENABLE(SQL_DATABASE)
+#pragma once
-#include <wtf/Deque.h>
-#include <wtf/HashMap.h>
+#include <memory>
#include <wtf/HashSet.h>
#include <wtf/MessageQueue.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Threading.h>
namespace WebCore {
-class DatabaseBackend;
+class Database;
class DatabaseTask;
class DatabaseTaskSynchronizer;
class Document;
-class SQLTransactionClient;
class SQLTransactionCoordinator;
class DatabaseThread : public ThreadSafeRefCounted<DatabaseThread> {
public:
- static PassRefPtr<DatabaseThread> create() { return adoptRef(new DatabaseThread); }
+ static Ref<DatabaseThread> create() { return adoptRef(*new DatabaseThread); }
~DatabaseThread();
bool start();
void requestTermination(DatabaseTaskSynchronizer* cleanupSync);
- bool terminationRequested(DatabaseTaskSynchronizer* taskSynchronizer = 0) const;
+ bool terminationRequested(DatabaseTaskSynchronizer* = nullptr) const;
- void scheduleTask(std::unique_ptr<DatabaseTask>);
- void scheduleImmediateTask(std::unique_ptr<DatabaseTask>); // This just adds the task to the front of the queue - the caller needs to be extremely careful not to create deadlocks when waiting for completion.
- void unscheduleDatabaseTasks(DatabaseBackend*);
+ void scheduleTask(std::unique_ptr<DatabaseTask>&&);
+ void scheduleImmediateTask(std::unique_ptr<DatabaseTask>&&); // This just adds the task to the front of the queue - the caller needs to be extremely careful not to create deadlocks when waiting for completion.
+ void unscheduleDatabaseTasks(Database&);
+ bool hasPendingDatabaseActivity() const;
- void recordDatabaseOpen(DatabaseBackend*);
- void recordDatabaseClosed(DatabaseBackend*);
+ void recordDatabaseOpen(Database&);
+ void recordDatabaseClosed(Database&);
ThreadIdentifier getThreadID() { return m_threadID; }
- SQLTransactionClient* transactionClient() { return m_transactionClient.get(); }
SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCoordinator.get(); }
-#if PLATFORM(IOS)
- void setPaused(bool);
- void handlePausedQueue();
-#endif
-
private:
DatabaseThread();
static void databaseThreadStart(void*);
void databaseThread();
- Mutex m_threadCreationMutex;
- ThreadIdentifier m_threadID;
+ Lock m_threadCreationMutex;
+ ThreadIdentifier m_threadID { 0 };
RefPtr<DatabaseThread> m_selfRef;
MessageQueue<DatabaseTask> m_queue;
-#if PLATFORM(IOS)
- MessageQueue<DatabaseTask> m_pausedQueue;
- Mutex m_pausedMutex;
- volatile bool m_paused;
-#endif
// This set keeps track of the open databases that have been used on this thread.
- typedef HashSet<RefPtr<DatabaseBackend>> DatabaseSet;
+ using DatabaseSet = HashSet<RefPtr<Database>>;
+ mutable Lock m_openDatabaseSetMutex;
DatabaseSet m_openDatabaseSet;
- OwnPtr<SQLTransactionClient> m_transactionClient;
- OwnPtr<SQLTransactionCoordinator> m_transactionCoordinator;
- DatabaseTaskSynchronizer* m_cleanupSync;
+ std::unique_ptr<SQLTransactionCoordinator> m_transactionCoordinator;
+ DatabaseTaskSynchronizer* m_cleanupSync { nullptr };
};
} // namespace WebCore
-
-#endif // ENABLE(SQL_DATABASE)
-#endif // DatabaseThread_h