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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 { | 58 { |
59 visitor->trace(m_openDatabaseSet); | 59 visitor->trace(m_openDatabaseSet); |
60 visitor->trace(m_transactionCoordinator); | 60 visitor->trace(m_transactionCoordinator); |
61 } | 61 } |
62 | 62 |
63 void DatabaseThread::start() | 63 void DatabaseThread::start() |
64 { | 64 { |
65 if (m_thread) | 65 if (m_thread) |
66 return; | 66 return; |
67 m_thread = WebThreadSupportingGC::create("WebCore: Database"); | 67 m_thread = WebThreadSupportingGC::create("WebCore: Database"); |
68 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&DatabaseThread::setup
DatabaseThread, this))); | 68 m_thread->postTask(BLINK_FROM_HERE, new Task(threadSafeBind(&DatabaseThread:
:setupDatabaseThread, this))); |
69 } | 69 } |
70 | 70 |
71 void DatabaseThread::setupDatabaseThread() | 71 void DatabaseThread::setupDatabaseThread() |
72 { | 72 { |
73 m_thread->initialize(); | 73 m_thread->initialize(); |
74 } | 74 } |
75 | 75 |
76 void DatabaseThread::terminate() | 76 void DatabaseThread::terminate() |
77 { | 77 { |
78 TaskSynchronizer sync; | 78 TaskSynchronizer sync; |
79 { | 79 { |
80 MutexLocker lock(m_terminationRequestedMutex); | 80 MutexLocker lock(m_terminationRequestedMutex); |
81 ASSERT(!m_terminationRequested); | 81 ASSERT(!m_terminationRequested); |
82 m_terminationRequested = true; | 82 m_terminationRequested = true; |
83 m_cleanupSync = &sync; | 83 m_cleanupSync = &sync; |
84 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); | 84 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); |
85 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&DatabaseThread::c
leanupDatabaseThread, this))); | 85 m_thread->postTask(BLINK_FROM_HERE, new Task(threadSafeBind(&DatabaseThr
ead::cleanupDatabaseThread, this))); |
86 } | 86 } |
87 sync.waitForTaskCompletion(); | 87 sync.waitForTaskCompletion(); |
88 // The WebThread destructor blocks until all the tasks of the database | 88 // The WebThread destructor blocks until all the tasks of the database |
89 // thread are processed. However, it shouldn't block at all because | 89 // thread are processed. However, it shouldn't block at all because |
90 // the database thread has already finished processing the cleanup task. | 90 // the database thread has already finished processing the cleanup task. |
91 m_thread.clear(); | 91 m_thread.clear(); |
92 } | 92 } |
93 | 93 |
94 bool DatabaseThread::terminationRequested() const | 94 bool DatabaseThread::terminationRequested() const |
95 { | 95 { |
(...skipping 13 matching lines...) Expand all Loading... |
109 if (m_openDatabaseSet.size() > 0) { | 109 if (m_openDatabaseSet.size() > 0) { |
110 // As the call to close will modify the original set, we must take a cop
y to iterate over. | 110 // As the call to close will modify the original set, we must take a cop
y to iterate over. |
111 HeapHashSet<Member<Database>> openSetCopy; | 111 HeapHashSet<Member<Database>> openSetCopy; |
112 openSetCopy.swap(m_openDatabaseSet); | 112 openSetCopy.swap(m_openDatabaseSet); |
113 HeapHashSet<Member<Database>>::iterator end = openSetCopy.end(); | 113 HeapHashSet<Member<Database>>::iterator end = openSetCopy.end(); |
114 for (HeapHashSet<Member<Database>>::iterator it = openSetCopy.begin(); i
t != end; ++it) | 114 for (HeapHashSet<Member<Database>>::iterator it = openSetCopy.begin(); i
t != end; ++it) |
115 (*it)->close(); | 115 (*it)->close(); |
116 } | 116 } |
117 m_openDatabaseSet.clear(); | 117 m_openDatabaseSet.clear(); |
118 | 118 |
119 m_thread->postTask(FROM_HERE, new Task(WTF::bind(&DatabaseThread::cleanupDat
abaseThreadCompleted, this))); | 119 m_thread->postTask(BLINK_FROM_HERE, new Task(WTF::bind(&DatabaseThread::clea
nupDatabaseThreadCompleted, this))); |
120 } | 120 } |
121 | 121 |
122 void DatabaseThread::cleanupDatabaseThreadCompleted() | 122 void DatabaseThread::cleanupDatabaseThreadCompleted() |
123 { | 123 { |
124 m_thread->shutdown(); | 124 m_thread->shutdown(); |
125 if (m_cleanupSync) // Someone wanted to know when we were done cleaning up. | 125 if (m_cleanupSync) // Someone wanted to know when we were done cleaning up. |
126 m_cleanupSync->taskCompleted(); | 126 m_cleanupSync->taskCompleted(); |
127 } | 127 } |
128 | 128 |
129 void DatabaseThread::recordDatabaseOpen(Database* database) | 129 void DatabaseThread::recordDatabaseOpen(Database* database) |
(...skipping 20 matching lines...) Expand all Loading... |
150 ASSERT(database); | 150 ASSERT(database); |
151 MutexLocker lock(m_terminationRequestedMutex); | 151 MutexLocker lock(m_terminationRequestedMutex); |
152 return !m_terminationRequested && m_openDatabaseSet.contains(database); | 152 return !m_terminationRequested && m_openDatabaseSet.contains(database); |
153 } | 153 } |
154 | 154 |
155 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) | 155 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) |
156 { | 156 { |
157 ASSERT(m_thread); | 157 ASSERT(m_thread); |
158 ASSERT(!terminationRequested()); | 158 ASSERT(!terminationRequested()); |
159 // WebThread takes ownership of the task. | 159 // WebThread takes ownership of the task. |
160 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&DatabaseTask::run, ta
sk))); | 160 m_thread->postTask(BLINK_FROM_HERE, new Task(threadSafeBind(&DatabaseTask::r
un, task))); |
161 } | 161 } |
162 | 162 |
163 } // namespace blink | 163 } // namespace blink |
OLD | NEW |