OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2013 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #if ENABLE(OILPAN) | 65 #if ENABLE(OILPAN) |
66 visitor->trace(m_openDatabaseSet); | 66 visitor->trace(m_openDatabaseSet); |
67 visitor->trace(m_transactionCoordinator); | 67 visitor->trace(m_transactionCoordinator); |
68 #endif | 68 #endif |
69 } | 69 } |
70 | 70 |
71 void DatabaseThread::start() | 71 void DatabaseThread::start() |
72 { | 72 { |
73 if (m_thread) | 73 if (m_thread) |
74 return; | 74 return; |
75 m_thread = adoptPtr(blink::Platform::current()->createThread("WebCore: Datab
ase")); | 75 m_thread = WebThreadSupportingGC::create("WebCore: Database"); |
76 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::setupDatabaseThread,
this))); | 76 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::setupDatabaseThread,
this))); |
77 } | 77 } |
78 | 78 |
79 void DatabaseThread::setupDatabaseThread() | 79 void DatabaseThread::setupDatabaseThread() |
80 { | 80 { |
81 m_pendingGCRunner = adoptPtr(new PendingGCRunner); | 81 m_thread->attachGC(); |
82 m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(m_thread.get(
))); | |
83 m_thread->addTaskObserver(m_pendingGCRunner.get()); | |
84 ThreadState::attach(); | |
85 ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get()); | |
86 } | 82 } |
87 | 83 |
88 void DatabaseThread::requestTermination(TaskSynchronizer *cleanupSync) | 84 void DatabaseThread::requestTermination(TaskSynchronizer *cleanupSync) |
89 { | 85 { |
90 MutexLocker lock(m_terminationRequestedMutex); | 86 MutexLocker lock(m_terminationRequestedMutex); |
91 ASSERT(!m_terminationRequested); | 87 ASSERT(!m_terminationRequested); |
92 m_terminationRequested = true; | 88 m_terminationRequested = true; |
93 m_cleanupSync = cleanupSync; | 89 m_cleanupSync = cleanupSync; |
94 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); | 90 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); |
95 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread
, this))); | 91 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread
, this))); |
(...skipping 26 matching lines...) Expand all Loading... |
122 WillBeHeapHashSet<RefPtrWillBeMember<DatabaseBackend> >::iterator end =
openSetCopy.end(); | 118 WillBeHeapHashSet<RefPtrWillBeMember<DatabaseBackend> >::iterator end =
openSetCopy.end(); |
123 for (WillBeHeapHashSet<RefPtrWillBeMember<DatabaseBackend> >::iterator i
t = openSetCopy.begin(); it != end; ++it) | 119 for (WillBeHeapHashSet<RefPtrWillBeMember<DatabaseBackend> >::iterator i
t = openSetCopy.begin(); it != end; ++it) |
124 (*it)->close(); | 120 (*it)->close(); |
125 } | 121 } |
126 | 122 |
127 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread
Completed, this))); | 123 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread
Completed, this))); |
128 } | 124 } |
129 | 125 |
130 void DatabaseThread::cleanupDatabaseThreadCompleted() | 126 void DatabaseThread::cleanupDatabaseThreadCompleted() |
131 { | 127 { |
132 ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get()); | 128 m_thread->detachGC(); |
133 ThreadState::detach(); | |
134 // We need to unregister PendingGCRunner before finising this task to avoid | |
135 // PendingGCRunner::didProcessTask accesses dead ThreadState. | |
136 m_thread->removeTaskObserver(m_pendingGCRunner.get()); | |
137 | |
138 if (m_cleanupSync) // Someone wanted to know when we were done cleaning up. | 129 if (m_cleanupSync) // Someone wanted to know when we were done cleaning up. |
139 m_cleanupSync->taskCompleted(); | 130 m_cleanupSync->taskCompleted(); |
140 } | 131 } |
141 | 132 |
142 void DatabaseThread::recordDatabaseOpen(DatabaseBackend* database) | 133 void DatabaseThread::recordDatabaseOpen(DatabaseBackend* database) |
143 { | 134 { |
144 ASSERT(isDatabaseThread()); | 135 ASSERT(isDatabaseThread()); |
145 ASSERT(database); | 136 ASSERT(database); |
146 ASSERT(!m_openDatabaseSet.contains(database)); | 137 ASSERT(!m_openDatabaseSet.contains(database)); |
147 m_openDatabaseSet.add(database); | 138 m_openDatabaseSet.add(database); |
(...skipping 17 matching lines...) Expand all Loading... |
165 | 156 |
166 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) | 157 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) |
167 { | 158 { |
168 ASSERT(m_thread); | 159 ASSERT(m_thread); |
169 ASSERT(!task->hasSynchronizer() || task->hasCheckedForTermination()); | 160 ASSERT(!task->hasSynchronizer() || task->hasCheckedForTermination()); |
170 // WebThread takes ownership of the task. | 161 // WebThread takes ownership of the task. |
171 m_thread->postTask(task.leakPtr()); | 162 m_thread->postTask(task.leakPtr()); |
172 } | 163 } |
173 | 164 |
174 } // namespace blink | 165 } // namespace blink |
OLD | NEW |