| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/ThreadSafeRefCounted.h" | 40 #include "wtf/ThreadSafeRefCounted.h" |
| 41 #include "wtf/ThreadingPrimitives.h" | 41 #include "wtf/ThreadingPrimitives.h" |
| 42 | 42 |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 class DatabaseBackend; | 45 class DatabaseBackend; |
| 46 class DatabaseTask; | 46 class DatabaseTask; |
| 47 class DatabaseTaskSynchronizer; | 47 class TaskSynchronizer; |
| 48 class Document; | 48 class Document; |
| 49 class MessageLoopInterruptor; | 49 class MessageLoopInterruptor; |
| 50 class PendingGCRunner; | 50 class PendingGCRunner; |
| 51 class SQLTransactionClient; | 51 class SQLTransactionClient; |
| 52 class SQLTransactionCoordinator; | 52 class SQLTransactionCoordinator; |
| 53 | 53 |
| 54 class DatabaseThread : public ThreadSafeRefCounted<DatabaseThread> { | 54 class DatabaseThread : public ThreadSafeRefCounted<DatabaseThread> { |
| 55 public: | 55 public: |
| 56 static PassRefPtr<DatabaseThread> create() { return adoptRef(new DatabaseThr
ead); } | 56 static PassRefPtr<DatabaseThread> create() { return adoptRef(new DatabaseThr
ead); } |
| 57 ~DatabaseThread(); | 57 ~DatabaseThread(); |
| 58 | 58 |
| 59 void start(); | 59 void start(); |
| 60 void requestTermination(DatabaseTaskSynchronizer* cleanupSync); | 60 void requestTermination(TaskSynchronizer* cleanupSync); |
| 61 bool terminationRequested(DatabaseTaskSynchronizer* taskSynchronizer = 0) co
nst; | 61 bool terminationRequested(TaskSynchronizer* = 0) const; |
| 62 | 62 |
| 63 void scheduleTask(PassOwnPtr<DatabaseTask>); | 63 void scheduleTask(PassOwnPtr<DatabaseTask>); |
| 64 | 64 |
| 65 void recordDatabaseOpen(DatabaseBackend*); | 65 void recordDatabaseOpen(DatabaseBackend*); |
| 66 void recordDatabaseClosed(DatabaseBackend*); | 66 void recordDatabaseClosed(DatabaseBackend*); |
| 67 bool isDatabaseOpen(DatabaseBackend*); | 67 bool isDatabaseOpen(DatabaseBackend*); |
| 68 | 68 |
| 69 bool isDatabaseThread() { return m_thread && m_thread->isCurrentThread(); } | 69 bool isDatabaseThread() { return m_thread && m_thread->isCurrentThread(); } |
| 70 | 70 |
| 71 SQLTransactionClient* transactionClient() { return m_transactionClient.get()
; } | 71 SQLTransactionClient* transactionClient() { return m_transactionClient.get()
; } |
| 72 SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCo
ordinator.get(); } | 72 SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCo
ordinator.get(); } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 DatabaseThread(); | 75 DatabaseThread(); |
| 76 | 76 |
| 77 void setupDatabaseThread(); | 77 void setupDatabaseThread(); |
| 78 void cleanupDatabaseThread(); | 78 void cleanupDatabaseThread(); |
| 79 void cleanupDatabaseThreadCompleted(); | 79 void cleanupDatabaseThreadCompleted(); |
| 80 | 80 |
| 81 OwnPtr<blink::WebThread> m_thread; | 81 OwnPtr<blink::WebThread> m_thread; |
| 82 | 82 |
| 83 // This set keeps track of the open databases that have been used on this th
read. | 83 // This set keeps track of the open databases that have been used on this th
read. |
| 84 // This must be updated in the database thread though it is constructed and | 84 // This must be updated in the database thread though it is constructed and |
| 85 // destructed in the context thread. | 85 // destructed in the context thread. |
| 86 WillBePersistentHeapHashSet<RefPtrWillBeMember<DatabaseBackend> > m_openData
baseSet; | 86 WillBePersistentHeapHashSet<RefPtrWillBeMember<DatabaseBackend> > m_openData
baseSet; |
| 87 | 87 |
| 88 OwnPtr<SQLTransactionClient> m_transactionClient; | 88 OwnPtr<SQLTransactionClient> m_transactionClient; |
| 89 OwnPtr<SQLTransactionCoordinator> m_transactionCoordinator; | 89 OwnPtr<SQLTransactionCoordinator> m_transactionCoordinator; |
| 90 DatabaseTaskSynchronizer* m_cleanupSync; | 90 TaskSynchronizer* m_cleanupSync; |
| 91 | 91 |
| 92 mutable Mutex m_terminationRequestedMutex; | 92 mutable Mutex m_terminationRequestedMutex; |
| 93 bool m_terminationRequested; | 93 bool m_terminationRequested; |
| 94 OwnPtr<PendingGCRunner> m_pendingGCRunner; | 94 OwnPtr<PendingGCRunner> m_pendingGCRunner; |
| 95 OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor; | 95 OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 } // namespace WebCore | 98 } // namespace WebCore |
| 99 | 99 |
| 100 #endif // DatabaseThread_h | 100 #endif // DatabaseThread_h |
| OLD | NEW |