| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 nameMap->remove(name); | 150 nameMap->remove(name); |
| 151 delete databaseSet; | 151 delete databaseSet; |
| 152 if (nameMap->isEmpty()) { | 152 if (nameMap->isEmpty()) { |
| 153 m_openDatabaseMap->remove(originIdentifier); | 153 m_openDatabaseMap->remove(originIdentifier); |
| 154 delete nameMap; | 154 delete nameMap; |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 ExecutionContext* executionContext = database->databaseContext()->executionC
ontext(); | 158 ExecutionContext* executionContext = database->databaseContext()->executionC
ontext(); |
| 159 if (!executionContext->isContextThread()) | 159 if (!executionContext->isContextThread()) |
| 160 executionContext->postTask(FROM_HERE, NotifyDatabaseObserverOnCloseTask:
:create(database)); | 160 executionContext->postTask(BLINK_FROM_HERE, NotifyDatabaseObserverOnClos
eTask::create(database)); |
| 161 else | 161 else |
| 162 databaseClosed(database); | 162 databaseClosed(database); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void DatabaseTracker::prepareToOpenDatabase(Database* database) | 165 void DatabaseTracker::prepareToOpenDatabase(Database* database) |
| 166 { | 166 { |
| 167 ASSERT(database->databaseContext()->executionContext()->isContextThread()); | 167 ASSERT(database->databaseContext()->executionContext()->isContextThread()); |
| 168 if (Platform::current()->databaseObserver()) { | 168 if (Platform::current()->databaseObserver()) { |
| 169 Platform::current()->databaseObserver()->databaseOpened( | 169 Platform::current()->databaseObserver()->databaseOpened( |
| 170 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin(
)), | 170 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin(
)), |
| 171 database->stringIdentifier(), | 171 database->stringIdentifier(), |
| 172 database->displayName(), | 172 database->displayName(), |
| 173 database->estimatedSize()); | 173 database->estimatedSize()); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 void DatabaseTracker::failedToOpenDatabase(Database* database) | 177 void DatabaseTracker::failedToOpenDatabase(Database* database) |
| 178 { | 178 { |
| 179 ExecutionContext* executionContext = database->databaseContext()->executionC
ontext(); | 179 ExecutionContext* executionContext = database->databaseContext()->executionC
ontext(); |
| 180 if (!executionContext->isContextThread()) | 180 if (!executionContext->isContextThread()) |
| 181 executionContext->postTask(FROM_HERE, NotifyDatabaseObserverOnCloseTask:
:create(database)); | 181 executionContext->postTask(BLINK_FROM_HERE, NotifyDatabaseObserverOnClos
eTask::create(database)); |
| 182 else | 182 else |
| 183 databaseClosed(database); | 183 databaseClosed(database); |
| 184 } | 184 } |
| 185 | 185 |
| 186 unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* databa
se) | 186 unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* databa
se) |
| 187 { | 187 { |
| 188 unsigned long long spaceAvailable = 0; | 188 unsigned long long spaceAvailable = 0; |
| 189 unsigned long long databaseSize = 0; | 189 unsigned long long databaseSize = 0; |
| 190 QuotaTracker::instance().getDatabaseSizeAndSpaceAvailableToOrigin( | 190 QuotaTracker::instance().getDatabaseSizeAndSpaceAvailableToOrigin( |
| 191 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin()), | 191 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin()), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier); | 227 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier); |
| 228 if (!nameMap) | 228 if (!nameMap) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 DatabaseSet* databaseSet = nameMap->get(name); | 231 DatabaseSet* databaseSet = nameMap->get(name); |
| 232 if (!databaseSet) | 232 if (!databaseSet) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 // We have to call closeImmediately() on the context thread. | 235 // We have to call closeImmediately() on the context thread. |
| 236 for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end
(); ++it) | 236 for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end
(); ++it) |
| 237 (*it)->databaseContext()->executionContext()->postTask(FROM_HERE, CloseO
neDatabaseImmediatelyTask::create(originIdentifier, name, *it)); | 237 (*it)->databaseContext()->executionContext()->postTask(BLINK_FROM_HERE,
CloseOneDatabaseImmediatelyTask::create(originIdentifier, name, *it)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void DatabaseTracker::closeOneDatabaseImmediately(const String& originIdentifier
, const String& name, Database* database) | 240 void DatabaseTracker::closeOneDatabaseImmediately(const String& originIdentifier
, const String& name, Database* database) |
| 241 { | 241 { |
| 242 // First we have to confirm the 'database' is still in our collection. | 242 // First we have to confirm the 'database' is still in our collection. |
| 243 { | 243 { |
| 244 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); | 244 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); |
| 245 if (!m_openDatabaseMap) | 245 if (!m_openDatabaseMap) |
| 246 return; | 246 return; |
| 247 | 247 |
| 248 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier); | 248 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier); |
| 249 if (!nameMap) | 249 if (!nameMap) |
| 250 return; | 250 return; |
| 251 | 251 |
| 252 DatabaseSet* databaseSet = nameMap->get(name); | 252 DatabaseSet* databaseSet = nameMap->get(name); |
| 253 if (!databaseSet) | 253 if (!databaseSet) |
| 254 return; | 254 return; |
| 255 | 255 |
| 256 DatabaseSet::iterator found = databaseSet->find(database); | 256 DatabaseSet::iterator found = databaseSet->find(database); |
| 257 if (found == databaseSet->end()) | 257 if (found == databaseSet->end()) |
| 258 return; | 258 return; |
| 259 } | 259 } |
| 260 | 260 |
| 261 // And we have to call closeImmediately() without our collection lock being
held. | 261 // And we have to call closeImmediately() without our collection lock being
held. |
| 262 database->closeImmediately(); | 262 database->closeImmediately(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 } // namespace blink | 265 } // namespace blink |
| OLD | NEW |