Changeset 52367 in webkit
- Timestamp:
- Dec 18, 2009 5:27:14 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52354 r52367 1 2009-12-16 Dumitru Daniliuc <dumi@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Move some code related to database closing from the destructor to 6 the close() method. This would allow us to do things such as post 7 tasks to other threads when a database closes, which cannot be 8 done now, because we cannot increment the ref count to a database 9 object when we're in its destructor. 10 11 https://bugs.webkit.org/show_bug.cgi?id=32626 12 13 * storage/Database.cpp: 14 (WebCore::Database::~Database): 15 (WebCore::Database::close): 16 1 17 2009-12-18 Jon Honeycutt <jhoneycutt@apple.com> 2 18 -
trunk/WebCore/storage/Database.cpp
r50666 r52367 199 199 Database::~Database() 200 200 { 201 if (m_document->databaseThread())202 m_document->databaseThread()->unscheduleDatabaseTasks(this);203 204 DatabaseTracker::tracker().removeOpenDatabase(this);205 m_document->removeOpenDatabase(this);206 207 201 // Deref m_document on the main thread. 208 202 callOnMainThread(derefDocument, m_document.release().releaseRef()); … … 334 328 } 335 329 330 static void documentRemoveOpenDatabase(void* context) 331 { 332 ASSERT(isMainThread()); 333 Database* database = static_cast<Database*>(context); 334 database->document()->removeOpenDatabase(database); 335 database->deref(); 336 } 337 336 338 void Database::close() 337 339 { 338 if (m_opened) { 339 ASSERT(m_document->databaseThread()); 340 ASSERT(currentThread() == document()->databaseThread()->getThreadID()); 341 m_sqliteDatabase.close(); 342 m_document->databaseThread()->recordDatabaseClosed(this); 343 m_opened = false; 344 345 { 346 MutexLocker locker(guidMutex()); 347 348 HashSet<Database*>* hashSet = guidToDatabaseMap().get(m_guid); 349 ASSERT(hashSet); 350 ASSERT(hashSet->contains(this)); 351 hashSet->remove(this); 352 if (hashSet->isEmpty()) { 353 guidToDatabaseMap().remove(m_guid); 354 delete hashSet; 355 guidToVersionMap().remove(m_guid); 356 } 340 if (!m_opened) 341 return; 342 343 ASSERT(m_document->databaseThread()); 344 ASSERT(currentThread() == document()->databaseThread()->getThreadID()); 345 m_sqliteDatabase.close(); 346 m_document->databaseThread()->recordDatabaseClosed(this); 347 m_opened = false; 348 349 { 350 MutexLocker locker(guidMutex()); 351 352 HashSet<Database*>* hashSet = guidToDatabaseMap().get(m_guid); 353 ASSERT(hashSet); 354 ASSERT(hashSet->contains(this)); 355 hashSet->remove(this); 356 if (hashSet->isEmpty()) { 357 guidToDatabaseMap().remove(m_guid); 358 delete hashSet; 359 guidToVersionMap().remove(m_guid); 357 360 } 358 361 } 362 363 m_document->databaseThread()->unscheduleDatabaseTasks(this); 364 365 DatabaseTracker::tracker().removeOpenDatabase(this); 366 ref(); // deref() called in documentRemoveOpenDatabase() 367 callOnMainThread(documentRemoveOpenDatabase, this); 359 368 } 360 369
Note: See TracChangeset
for help on using the changeset viewer.