| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "modules/webdatabase/DatabaseTracker.h" | 31 #include "modules/webdatabase/DatabaseTracker.h" |
| 32 | 32 |
| 33 #include "core/dom/Document.h" |
| 33 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
| 34 #include "core/dom/ExecutionContextTask.h" | 35 #include "core/dom/ExecutionContextTask.h" |
| 35 #include "modules/webdatabase/Database.h" | 36 #include "modules/webdatabase/Database.h" |
| 36 #include "modules/webdatabase/DatabaseClient.h" | 37 #include "modules/webdatabase/DatabaseClient.h" |
| 37 #include "modules/webdatabase/DatabaseContext.h" | 38 #include "modules/webdatabase/DatabaseContext.h" |
| 38 #include "modules/webdatabase/QuotaTracker.h" | 39 #include "modules/webdatabase/QuotaTracker.h" |
| 39 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h" | 40 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h" |
| 40 #include "platform/weborigin/SecurityOrigin.h" | 41 #include "platform/weborigin/SecurityOrigin.h" |
| 41 #include "platform/weborigin/SecurityOriginHash.h" | 42 #include "platform/weborigin/SecurityOriginHash.h" |
| 42 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 203 |
| 203 DatabaseSet* databaseSet = nameMap->get(name); | 204 DatabaseSet* databaseSet = nameMap->get(name); |
| 204 if (!databaseSet) | 205 if (!databaseSet) |
| 205 return; | 206 return; |
| 206 | 207 |
| 207 // We have to call closeImmediately() on the context thread. | 208 // We have to call closeImmediately() on the context thread. |
| 208 for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end
(); ++it) | 209 for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end
(); ++it) |
| 209 (*it)->getDatabaseContext()->getExecutionContext()->postTask(BLINK_FROM_
HERE, CloseOneDatabaseImmediatelyTask::create(originString, name, *it)); | 210 (*it)->getDatabaseContext()->getExecutionContext()->postTask(BLINK_FROM_
HERE, CloseOneDatabaseImmediatelyTask::create(originString, name, *it)); |
| 210 } | 211 } |
| 211 | 212 |
| 213 void DatabaseTracker::forEachOpenDatabaseInPage(Page* page, PassOwnPtr<DatabaseC
allback> callback) |
| 214 { |
| 215 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); |
| 216 if (!m_openDatabaseMap) |
| 217 return; |
| 218 for (auto& originMap : *m_openDatabaseMap) { |
| 219 for (auto& nameDatabaseSet : *originMap.value) { |
| 220 for (Database* database : *nameDatabaseSet.value) { |
| 221 ExecutionContext* context = database->getExecutionContext(); |
| 222 ASSERT(context->isDocument()); |
| 223 if (toDocument(context)->frame()->page() == page) |
| 224 (*callback)(database); |
| 225 } |
| 226 } |
| 227 } |
| 228 } |
| 229 |
| 212 void DatabaseTracker::closeOneDatabaseImmediately(const String& originString, co
nst String& name, Database* database) | 230 void DatabaseTracker::closeOneDatabaseImmediately(const String& originString, co
nst String& name, Database* database) |
| 213 { | 231 { |
| 214 // First we have to confirm the 'database' is still in our collection. | 232 // First we have to confirm the 'database' is still in our collection. |
| 215 { | 233 { |
| 216 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); | 234 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); |
| 217 if (!m_openDatabaseMap) | 235 if (!m_openDatabaseMap) |
| 218 return; | 236 return; |
| 219 | 237 |
| 220 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originString); | 238 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originString); |
| 221 if (!nameMap) | 239 if (!nameMap) |
| 222 return; | 240 return; |
| 223 | 241 |
| 224 DatabaseSet* databaseSet = nameMap->get(name); | 242 DatabaseSet* databaseSet = nameMap->get(name); |
| 225 if (!databaseSet) | 243 if (!databaseSet) |
| 226 return; | 244 return; |
| 227 | 245 |
| 228 DatabaseSet::iterator found = databaseSet->find(database); | 246 DatabaseSet::iterator found = databaseSet->find(database); |
| 229 if (found == databaseSet->end()) | 247 if (found == databaseSet->end()) |
| 230 return; | 248 return; |
| 231 } | 249 } |
| 232 | 250 |
| 233 // And we have to call closeImmediately() without our collection lock being
held. | 251 // And we have to call closeImmediately() without our collection lock being
held. |
| 234 database->closeImmediately(); | 252 database->closeImmediately(); |
| 235 } | 253 } |
| 236 | 254 |
| 237 } // namespace blink | 255 } // namespace blink |
| OLD | NEW |