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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 { | 45 { |
46 } | 46 } |
47 | 47 |
48 DatabaseTask::~DatabaseTask() { | 48 DatabaseTask::~DatabaseTask() { |
49 #if DCHECK_IS_ON() | 49 #if DCHECK_IS_ON() |
50 DCHECK(m_complete || !m_completeEvent); | 50 DCHECK(m_complete || !m_completeEvent); |
51 #endif | 51 #endif |
52 } | 52 } |
53 | 53 |
54 void DatabaseTask::run() { | 54 void DatabaseTask::run() { |
55 // Database tasks are meant to be used only once, so make sure this one hasn't b
een performed before. | 55 // Database tasks are meant to be used only once, so make sure this one hasn't |
| 56 // been performed before. |
56 #if DCHECK_IS_ON() | 57 #if DCHECK_IS_ON() |
57 ASSERT(!m_complete); | 58 ASSERT(!m_complete); |
58 #endif | 59 #endif |
59 | 60 |
60 if (!m_completeEvent && | 61 if (!m_completeEvent && |
61 !m_database->getDatabaseContext()->databaseThread()->isDatabaseOpen( | 62 !m_database->getDatabaseContext()->databaseThread()->isDatabaseOpen( |
62 m_database.get())) { | 63 m_database.get())) { |
63 taskCancelled(); | 64 taskCancelled(); |
64 #if DCHECK_IS_ON() | 65 #if DCHECK_IS_ON() |
65 m_complete = true; | 66 m_complete = true; |
66 #endif | 67 #endif |
67 return; | 68 return; |
68 } | 69 } |
69 #if DCHECK_IS_ON() | 70 #if DCHECK_IS_ON() |
70 STORAGE_DVLOG(1) << "Performing " << debugTaskName() << " " << this; | 71 STORAGE_DVLOG(1) << "Performing " << debugTaskName() << " " << this; |
71 #endif | 72 #endif |
72 m_database->resetAuthorizer(); | 73 m_database->resetAuthorizer(); |
73 doPerformTask(); | 74 doPerformTask(); |
74 | 75 |
75 if (m_completeEvent) | 76 if (m_completeEvent) |
76 m_completeEvent->signal(); | 77 m_completeEvent->signal(); |
77 | 78 |
78 #if DCHECK_IS_ON() | 79 #if DCHECK_IS_ON() |
79 m_complete = true; | 80 m_complete = true; |
80 #endif | 81 #endif |
81 } | 82 } |
82 | 83 |
83 // *** DatabaseOpenTask *** | 84 // *** DatabaseOpenTask *** |
84 // Opens the database file and verifies the version matches the expected version
. | 85 // Opens the database file and verifies the version matches the expected |
| 86 // version. |
85 | 87 |
86 Database::DatabaseOpenTask::DatabaseOpenTask(Database* database, | 88 Database::DatabaseOpenTask::DatabaseOpenTask(Database* database, |
87 bool setVersionInNewDatabase, | 89 bool setVersionInNewDatabase, |
88 WaitableEvent* completeEvent, | 90 WaitableEvent* completeEvent, |
89 DatabaseError& error, | 91 DatabaseError& error, |
90 String& errorMessage, | 92 String& errorMessage, |
91 bool& success) | 93 bool& success) |
92 : DatabaseTask(database, completeEvent), | 94 : DatabaseTask(database, completeEvent), |
93 m_setVersionInNewDatabase(setVersionInNewDatabase), | 95 m_setVersionInNewDatabase(setVersionInNewDatabase), |
94 m_error(error), | 96 m_error(error), |
95 m_errorMessage(errorMessage), | 97 m_errorMessage(errorMessage), |
96 m_success(success) { | 98 m_success(success) { |
97 DCHECK( | 99 DCHECK(completeEvent); // A task with output parameters is supposed to be |
98 completeEvent); // A task with output parameters is supposed to be synchr
onous. | 100 // synchronous. |
99 } | 101 } |
100 | 102 |
101 void Database::DatabaseOpenTask::doPerformTask() { | 103 void Database::DatabaseOpenTask::doPerformTask() { |
102 String errorMessage; | 104 String errorMessage; |
103 m_success = database()->performOpenAndVerify(m_setVersionInNewDatabase, | 105 m_success = database()->performOpenAndVerify(m_setVersionInNewDatabase, |
104 m_error, errorMessage); | 106 m_error, errorMessage); |
105 if (!m_success) | 107 if (!m_success) |
106 m_errorMessage = errorMessage.isolatedCopy(); | 108 m_errorMessage = errorMessage.isolatedCopy(); |
107 } | 109 } |
108 | 110 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 #endif | 163 #endif |
162 | 164 |
163 // *** DatabaseTableNamesTask *** | 165 // *** DatabaseTableNamesTask *** |
164 // Retrieves a list of all tables in the database - for WebInspector support. | 166 // Retrieves a list of all tables in the database - for WebInspector support. |
165 | 167 |
166 Database::DatabaseTableNamesTask::DatabaseTableNamesTask( | 168 Database::DatabaseTableNamesTask::DatabaseTableNamesTask( |
167 Database* database, | 169 Database* database, |
168 WaitableEvent* completeEvent, | 170 WaitableEvent* completeEvent, |
169 Vector<String>& names) | 171 Vector<String>& names) |
170 : DatabaseTask(database, completeEvent), m_tableNames(names) { | 172 : DatabaseTask(database, completeEvent), m_tableNames(names) { |
171 DCHECK( | 173 DCHECK(completeEvent); // A task with output parameters is supposed to be |
172 completeEvent); // A task with output parameters is supposed to be synchr
onous. | 174 // synchronous. |
173 } | 175 } |
174 | 176 |
175 void Database::DatabaseTableNamesTask::doPerformTask() { | 177 void Database::DatabaseTableNamesTask::doPerformTask() { |
176 m_tableNames = database()->performGetTableNames(); | 178 m_tableNames = database()->performGetTableNames(); |
177 } | 179 } |
178 | 180 |
179 #if DCHECK_IS_ON() | 181 #if DCHECK_IS_ON() |
180 const char* Database::DatabaseTableNamesTask::debugTaskName() const { | 182 const char* Database::DatabaseTableNamesTask::debugTaskName() const { |
181 return "DatabaseTableNamesTask"; | 183 return "DatabaseTableNamesTask"; |
182 } | 184 } |
183 #endif | 185 #endif |
184 | 186 |
185 } // namespace blink | 187 } // namespace blink |
OLD | NEW |