| 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 17 matching lines...) Expand all Loading... |
| 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/ExecutionContext.h" | 33 #include "core/dom/ExecutionContext.h" |
| 34 #include "core/dom/ExecutionContextTask.h" | 34 #include "core/dom/ExecutionContextTask.h" |
| 35 #include "modules/webdatabase/Database.h" | 35 #include "modules/webdatabase/Database.h" |
| 36 #include "modules/webdatabase/DatabaseClient.h" | 36 #include "modules/webdatabase/DatabaseClient.h" |
| 37 #include "modules/webdatabase/DatabaseContext.h" | 37 #include "modules/webdatabase/DatabaseContext.h" |
| 38 #include "modules/webdatabase/InspectorDatabaseAgent.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" |
| 43 #include "public/platform/WebDatabaseObserver.h" | 44 #include "public/platform/WebDatabaseObserver.h" |
| 44 #include "public/platform/WebSecurityOrigin.h" | 45 #include "public/platform/WebSecurityOrigin.h" |
| 45 #include "public/platform/WebTraceLocation.h" | 46 #include "public/platform/WebTraceLocation.h" |
| 46 #include "wtf/Assertions.h" | 47 #include "wtf/Assertions.h" |
| 47 #include "wtf/StdLibExtras.h" | 48 #include "wtf/StdLibExtras.h" |
| (...skipping 154 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::registerAllDatabasesInInspector(InspectorDatabaseAgent* ag
ent) |
| 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 agent->didOpenDatabase(database, database->getSecurityOrigin()->
host(), database->displayName(), database->version()); |
| 222 } |
| 223 } |
| 224 } |
| 225 } |
| 226 |
| 212 void DatabaseTracker::closeOneDatabaseImmediately(const String& originString, co
nst String& name, Database* database) | 227 void DatabaseTracker::closeOneDatabaseImmediately(const String& originString, co
nst String& name, Database* database) |
| 213 { | 228 { |
| 214 // First we have to confirm the 'database' is still in our collection. | 229 // First we have to confirm the 'database' is still in our collection. |
| 215 { | 230 { |
| 216 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); | 231 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); |
| 217 if (!m_openDatabaseMap) | 232 if (!m_openDatabaseMap) |
| 218 return; | 233 return; |
| 219 | 234 |
| 220 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originString); | 235 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originString); |
| 221 if (!nameMap) | 236 if (!nameMap) |
| 222 return; | 237 return; |
| 223 | 238 |
| 224 DatabaseSet* databaseSet = nameMap->get(name); | 239 DatabaseSet* databaseSet = nameMap->get(name); |
| 225 if (!databaseSet) | 240 if (!databaseSet) |
| 226 return; | 241 return; |
| 227 | 242 |
| 228 DatabaseSet::iterator found = databaseSet->find(database); | 243 DatabaseSet::iterator found = databaseSet->find(database); |
| 229 if (found == databaseSet->end()) | 244 if (found == databaseSet->end()) |
| 230 return; | 245 return; |
| 231 } | 246 } |
| 232 | 247 |
| 233 // And we have to call closeImmediately() without our collection lock being
held. | 248 // And we have to call closeImmediately() without our collection lock being
held. |
| 234 database->closeImmediately(); | 249 database->closeImmediately(); |
| 235 } | 250 } |
| 236 | 251 |
| 237 } // namespace blink | 252 } // namespace blink |
| OLD | NEW |