Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: Source/modules/webdatabase/DatabaseTask.cpp

Issue 219963019: Revert r170536 - "Rename DatabaseTaskSynchronizer to TaskSynchronizer ..." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/webdatabase/DatabaseTask.h ('k') | Source/modules/webdatabase/DatabaseThread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived 14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission. 15 * from this software without specific prior written permission.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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
29 #include "config.h" 28 #include "config.h"
30 #include "modules/webdatabase/DatabaseTask.h" 29 #include "modules/webdatabase/DatabaseTask.h"
31 30
32 #include "platform/Logging.h" 31 #include "platform/Logging.h"
33 #include "modules/webdatabase/Database.h" 32 #include "modules/webdatabase/Database.h"
34 #include "modules/webdatabase/DatabaseContext.h" 33 #include "modules/webdatabase/DatabaseContext.h"
35 #include "modules/webdatabase/DatabaseThread.h" 34 #include "modules/webdatabase/DatabaseThread.h"
36 35
37 namespace WebCore { 36 namespace WebCore {
38 37
39 DatabaseTask::DatabaseTask(DatabaseBackend* database, TaskSynchronizer* synchron izer) 38 DatabaseTaskSynchronizer::DatabaseTaskSynchronizer()
39 : m_taskCompleted(false)
40 #ifndef NDEBUG
41 , m_hasCheckedForTermination(false)
42 #endif
43 {
44 }
45
46 void DatabaseTaskSynchronizer::waitForTaskCompletion()
47 {
48 // Prevent the deadlock between park request by other threads and blocking
49 // by m_synchronousCondition.
50 ThreadState::SafePointScope scope(ThreadState::HeapPointersOnStack);
51 m_synchronousMutex.lock();
52 while (!m_taskCompleted)
53 m_synchronousCondition.wait(m_synchronousMutex);
54 m_synchronousMutex.unlock();
55 }
56
57 void DatabaseTaskSynchronizer::taskCompleted()
58 {
59 m_synchronousMutex.lock();
60 m_taskCompleted = true;
61 m_synchronousCondition.signal();
62 m_synchronousMutex.unlock();
63 }
64
65 DatabaseTask::DatabaseTask(DatabaseBackend* database, DatabaseTaskSynchronizer* synchronizer)
40 : m_database(database) 66 : m_database(database)
41 , m_synchronizer(synchronizer) 67 , m_synchronizer(synchronizer)
42 #if !LOG_DISABLED 68 #if !LOG_DISABLED
43 , m_complete(false) 69 , m_complete(false)
44 #endif 70 #endif
45 { 71 {
46 } 72 }
47 73
48 DatabaseTask::~DatabaseTask() 74 DatabaseTask::~DatabaseTask()
49 { 75 {
(...skipping 26 matching lines...) Expand all
76 m_synchronizer->taskCompleted(); 102 m_synchronizer->taskCompleted();
77 103
78 #if !LOG_DISABLED 104 #if !LOG_DISABLED
79 m_complete = true; 105 m_complete = true;
80 #endif 106 #endif
81 } 107 }
82 108
83 // *** DatabaseOpenTask *** 109 // *** DatabaseOpenTask ***
84 // Opens the database file and verifies the version matches the expected version . 110 // Opens the database file and verifies the version matches the expected version .
85 111
86 DatabaseBackend::DatabaseOpenTask::DatabaseOpenTask(DatabaseBackend* database, b ool setVersionInNewDatabase, TaskSynchronizer* synchronizer, DatabaseError& erro r, String& errorMessage, bool& success) 112 DatabaseBackend::DatabaseOpenTask::DatabaseOpenTask(DatabaseBackend* database, b ool setVersionInNewDatabase, DatabaseTaskSynchronizer* synchronizer, DatabaseErr or& error, String& errorMessage, bool& success)
87 : DatabaseTask(database, synchronizer) 113 : DatabaseTask(database, synchronizer)
88 , m_setVersionInNewDatabase(setVersionInNewDatabase) 114 , m_setVersionInNewDatabase(setVersionInNewDatabase)
89 , m_error(error) 115 , m_error(error)
90 , m_errorMessage(errorMessage) 116 , m_errorMessage(errorMessage)
91 , m_success(success) 117 , m_success(success)
92 { 118 {
93 ASSERT(synchronizer); // A task with output parameters is supposed to be syn chronous. 119 ASSERT(synchronizer); // A task with output parameters is supposed to be syn chronous.
94 } 120 }
95 121
96 void DatabaseBackend::DatabaseOpenTask::doPerformTask() 122 void DatabaseBackend::DatabaseOpenTask::doPerformTask()
97 { 123 {
98 String errorMessage; 124 String errorMessage;
99 m_success = database()->performOpenAndVerify(m_setVersionInNewDatabase, m_er ror, errorMessage); 125 m_success = database()->performOpenAndVerify(m_setVersionInNewDatabase, m_er ror, errorMessage);
100 if (!m_success) 126 if (!m_success)
101 m_errorMessage = errorMessage.isolatedCopy(); 127 m_errorMessage = errorMessage.isolatedCopy();
102 } 128 }
103 129
104 #if !LOG_DISABLED 130 #if !LOG_DISABLED
105 const char* DatabaseBackend::DatabaseOpenTask::debugTaskName() const 131 const char* DatabaseBackend::DatabaseOpenTask::debugTaskName() const
106 { 132 {
107 return "DatabaseOpenTask"; 133 return "DatabaseOpenTask";
108 } 134 }
109 #endif 135 #endif
110 136
111 // *** DatabaseCloseTask *** 137 // *** DatabaseCloseTask ***
112 // Closes the database. 138 // Closes the database.
113 139
114 DatabaseBackend::DatabaseCloseTask::DatabaseCloseTask(DatabaseBackend* database, TaskSynchronizer* synchronizer) 140 DatabaseBackend::DatabaseCloseTask::DatabaseCloseTask(DatabaseBackend* database, DatabaseTaskSynchronizer* synchronizer)
115 : DatabaseTask(database, synchronizer) 141 : DatabaseTask(database, synchronizer)
116 { 142 {
117 } 143 }
118 144
119 void DatabaseBackend::DatabaseCloseTask::doPerformTask() 145 void DatabaseBackend::DatabaseCloseTask::doPerformTask()
120 { 146 {
121 Database::from(database())->close(); 147 Database::from(database())->close();
122 } 148 }
123 149
124 #if !LOG_DISABLED 150 #if !LOG_DISABLED
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #if !LOG_DISABLED 188 #if !LOG_DISABLED
163 const char* DatabaseBackend::DatabaseTransactionTask::debugTaskName() const 189 const char* DatabaseBackend::DatabaseTransactionTask::debugTaskName() const
164 { 190 {
165 return "DatabaseTransactionTask"; 191 return "DatabaseTransactionTask";
166 } 192 }
167 #endif 193 #endif
168 194
169 // *** DatabaseTableNamesTask *** 195 // *** DatabaseTableNamesTask ***
170 // Retrieves a list of all tables in the database - for WebInspector support. 196 // Retrieves a list of all tables in the database - for WebInspector support.
171 197
172 DatabaseBackend::DatabaseTableNamesTask::DatabaseTableNamesTask(DatabaseBackend* database, TaskSynchronizer* synchronizer, Vector<String>& names) 198 DatabaseBackend::DatabaseTableNamesTask::DatabaseTableNamesTask(DatabaseBackend* database, DatabaseTaskSynchronizer* synchronizer, Vector<String>& names)
173 : DatabaseTask(database, synchronizer) 199 : DatabaseTask(database, synchronizer)
174 , m_tableNames(names) 200 , m_tableNames(names)
175 { 201 {
176 ASSERT(synchronizer); // A task with output parameters is supposed to be syn chronous. 202 ASSERT(synchronizer); // A task with output parameters is supposed to be syn chronous.
177 } 203 }
178 204
179 void DatabaseBackend::DatabaseTableNamesTask::doPerformTask() 205 void DatabaseBackend::DatabaseTableNamesTask::doPerformTask()
180 { 206 {
181 m_tableNames = Database::from(database())->performGetTableNames(); 207 m_tableNames = Database::from(database())->performGetTableNames();
182 } 208 }
183 209
184 #if !LOG_DISABLED 210 #if !LOG_DISABLED
185 const char* DatabaseBackend::DatabaseTableNamesTask::debugTaskName() const 211 const char* DatabaseBackend::DatabaseTableNamesTask::debugTaskName() const
186 { 212 {
187 return "DatabaseTableNamesTask"; 213 return "DatabaseTableNamesTask";
188 } 214 }
189 #endif 215 #endif
190 216
191 } // namespace WebCore 217 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/DatabaseTask.h ('k') | Source/modules/webdatabase/DatabaseThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698