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 13 matching lines...) Expand all Loading... |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 #ifndef DatabaseThread_h | 28 #ifndef DatabaseThread_h |
29 #define DatabaseThread_h | 29 #define DatabaseThread_h |
30 | 30 |
31 #include "platform/WebThreadSupportingGC.h" | 31 #include "platform/WebThreadSupportingGC.h" |
32 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
33 #include "wtf/HashMap.h" | 33 #include "wtf/HashMap.h" |
| 34 #include "wtf/OwnPtr.h" |
| 35 #include "wtf/PassOwnPtr.h" |
34 #include "wtf/ThreadingPrimitives.h" | 36 #include "wtf/ThreadingPrimitives.h" |
35 #include <memory> | |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 class Database; | 40 class Database; |
40 class DatabaseTask; | 41 class DatabaseTask; |
41 class SQLTransactionClient; | 42 class SQLTransactionClient; |
42 class SQLTransactionCoordinator; | 43 class SQLTransactionCoordinator; |
43 class TaskSynchronizer; | 44 class TaskSynchronizer; |
44 | 45 |
45 class DatabaseThread : public GarbageCollectedFinalized<DatabaseThread> { | 46 class DatabaseThread : public GarbageCollectedFinalized<DatabaseThread> { |
46 public: | 47 public: |
47 static DatabaseThread* create() { return new DatabaseThread; } | 48 static DatabaseThread* create() { return new DatabaseThread; } |
48 ~DatabaseThread(); | 49 ~DatabaseThread(); |
49 DECLARE_TRACE(); | 50 DECLARE_TRACE(); |
50 | 51 |
51 // Callable only from the main thread. | 52 // Callable only from the main thread. |
52 void start(); | 53 void start(); |
53 void terminate(); | 54 void terminate(); |
54 | 55 |
55 // Callable from the main thread or the database thread. | 56 // Callable from the main thread or the database thread. |
56 void scheduleTask(std::unique_ptr<DatabaseTask>); | 57 void scheduleTask(PassOwnPtr<DatabaseTask>); |
57 bool isDatabaseThread() const; | 58 bool isDatabaseThread() const; |
58 | 59 |
59 // Callable only from the database thread. | 60 // Callable only from the database thread. |
60 void recordDatabaseOpen(Database*); | 61 void recordDatabaseOpen(Database*); |
61 void recordDatabaseClosed(Database*); | 62 void recordDatabaseClosed(Database*); |
62 bool isDatabaseOpen(Database*); | 63 bool isDatabaseOpen(Database*); |
63 | 64 |
64 SQLTransactionClient* transactionClient() { return m_transactionClient.get()
; } | 65 SQLTransactionClient* transactionClient() { return m_transactionClient.get()
; } |
65 SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCo
ordinator.get(); } | 66 SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCo
ordinator.get(); } |
66 | 67 |
67 private: | 68 private: |
68 DatabaseThread(); | 69 DatabaseThread(); |
69 | 70 |
70 void setupDatabaseThread(); | 71 void setupDatabaseThread(); |
71 void cleanupDatabaseThread(); | 72 void cleanupDatabaseThread(); |
72 void cleanupDatabaseThreadCompleted(); | 73 void cleanupDatabaseThreadCompleted(); |
73 | 74 |
74 std::unique_ptr<WebThreadSupportingGC> m_thread; | 75 OwnPtr<WebThreadSupportingGC> m_thread; |
75 | 76 |
76 // This set keeps track of the open databases that have been used on this th
read. | 77 // This set keeps track of the open databases that have been used on this th
read. |
77 // This must be updated in the database thread though it is constructed and | 78 // This must be updated in the database thread though it is constructed and |
78 // destructed in the context thread. | 79 // destructed in the context thread. |
79 HashSet<CrossThreadPersistent<Database>> m_openDatabaseSet; | 80 HashSet<CrossThreadPersistent<Database>> m_openDatabaseSet; |
80 | 81 |
81 std::unique_ptr<SQLTransactionClient> m_transactionClient; | 82 OwnPtr<SQLTransactionClient> m_transactionClient; |
82 CrossThreadPersistent<SQLTransactionCoordinator> m_transactionCoordinator; | 83 CrossThreadPersistent<SQLTransactionCoordinator> m_transactionCoordinator; |
83 TaskSynchronizer* m_cleanupSync; | 84 TaskSynchronizer* m_cleanupSync; |
84 | 85 |
85 Mutex m_terminationRequestedMutex; | 86 Mutex m_terminationRequestedMutex; |
86 bool m_terminationRequested; | 87 bool m_terminationRequested; |
87 }; | 88 }; |
88 | 89 |
89 } // namespace blink | 90 } // namespace blink |
90 | 91 |
91 #endif // DatabaseThread_h | 92 #endif // DatabaseThread_h |
OLD | NEW |