bool Client::HasTransactionsForStorage(nsIOfflineStorage* aStorage) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); TransactionThreadPool* pool = TransactionThreadPool::Get(); NS_ASSERTION(pool, "Should have checked if transaction service is active!"); IDBDatabase* database = IDBDatabase::FromStorage(aStorage); NS_ASSERTION(database, "This shouldn't be null!"); return pool->HasTransactionsForDatabase(database); }
bool IndexedDatabaseManager::HasOpenTransactions(nsPIDOMWindow* aWindow) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aWindow, "Null pointer!"); nsAutoTArray<IDBDatabase*, 50> liveDatabases; mLiveDatabases.EnumerateRead(EnumerateToTArray, &liveDatabases); TransactionThreadPool* pool = TransactionThreadPool::Get(); if (!pool) { return false; } for (PRUint32 index = 0; index < liveDatabases.Length(); index++) { IDBDatabase*& database = liveDatabases[index]; if (database->Owner() == aWindow && pool->HasTransactionsForDatabase(database)) { return true; } } return false; }