bool MusicSongsListPlayWidget::showArtPicture(const QString &name) const { QPixmap originPath(QString(ART_DOWNLOAD_AL + name + SKN_FILE)); if(!originPath.isNull()) { m_artPictureLabel->setPixmap(originPath.scaled(60, 60)); return true; } return false; }
bool MusicSongsListItemInfoWidget::showArtPicture(const QString &name) { QPixmap originPath(QString(ART_DOWNLOAD_AL + name + SKN_FILE)); if(!originPath.isNull()) { ui->artPicture->setPixmap(originPath.scaled(60, 60)); return true; } return false; }
void DatabaseTracker::deleteOriginLockFor(SecurityOrigin* origin) { ASSERT(!m_databaseGuard.tryLock()); // There is not always an instance of an OriginLock associated with an origin. // For example, if the OriginLock lock file was created by a previous run of // the browser which has now terminated, and the current browser process // has not executed any database transactions from this origin that would // have created the OriginLock instance in memory. In this case, we will have // a lock file but not an OriginLock instance in memory. // This function is only called if we are already deleting all the database // files in this origin. We'll give the OriginLock one chance to do an // orderly clean up first when we remove its ref from the m_originLockMap. // This may or may not be possible depending on whether other threads are // also using the OriginLock at the same time. After that, we will delete the lock file. m_originLockMap.remove(origin->databaseIdentifier()); OriginLock::deleteLockFile(originPath(origin)); }
PassRefPtr<OriginLock> DatabaseTracker::originLockFor(SecurityOrigin* origin) { MutexLocker lockDatabase(m_databaseGuard); String databaseIdentifier = origin->databaseIdentifier(); // The originLockMap is accessed from multiple DatabaseThreads since // different script contexts can be writing to different databases from // the same origin. Hence, the databaseIdentifier key needs to be an // isolated copy. An isolated copy gives us a value whose refCounting is // thread-safe, since our copy is guarded by the m_databaseGuard mutex. databaseIdentifier = databaseIdentifier.isolatedCopy(); OriginLockMap::AddResult addResult = m_originLockMap.add(databaseIdentifier, RefPtr<OriginLock>()); if (!addResult.isNewEntry) return addResult.iterator->value; String path = originPath(origin); RefPtr<OriginLock> lock = adoptRef(new OriginLock(path)); ASSERT(lock); addResult.iterator->value = lock; return lock.release(); }
// It is the caller's responsibility to make sure that nobody is trying to create, delete, open, or close databases in this origin while the deletion is // taking place. bool DatabaseTracker::deleteOrigin(SecurityOrigin* origin) { Vector<String> databaseNames; { MutexLocker lockDatabase(m_databaseGuard); openTrackerDatabase(DontCreateIfDoesNotExist); if (!m_database.isOpen()) return false; if (!databaseNamesForOriginNoLock(origin, databaseNames)) { LOG_ERROR("Unable to retrieve list of database names for origin %s", origin->databaseIdentifier().ascii().data()); return false; } if (!canDeleteOrigin(origin)) { LOG_ERROR("Tried to delete an origin (%s) while either creating database in it or already deleting it", origin->databaseIdentifier().ascii().data()); ASSERT_NOT_REACHED(); return false; } recordDeletingOrigin(origin); } // We drop the lock here because holding locks during a call to deleteDatabaseFile will deadlock. for (unsigned i = 0; i < databaseNames.size(); ++i) { if (!deleteDatabaseFile(origin, databaseNames[i])) { // Even if the file can't be deleted, we want to try and delete the rest, don't return early here. LOG_ERROR("Unable to delete file for database %s in origin %s", databaseNames[i].ascii().data(), origin->databaseIdentifier().ascii().data()); } } { MutexLocker lockDatabase(m_databaseGuard); deleteOriginLockFor(origin); doneDeletingOrigin(origin); SQLiteStatement statement(m_database, "DELETE FROM Databases WHERE origin=?"); if (statement.prepare() != SQLResultOk) { LOG_ERROR("Unable to prepare deletion of databases from origin %s from tracker", origin->databaseIdentifier().ascii().data()); return false; } statement.bindText(1, origin->databaseIdentifier()); if (!statement.executeCommand()) { LOG_ERROR("Unable to execute deletion of databases from origin %s from tracker", origin->databaseIdentifier().ascii().data()); return false; } SQLiteStatement originStatement(m_database, "DELETE FROM Origins WHERE origin=?"); if (originStatement.prepare() != SQLResultOk) { LOG_ERROR("Unable to prepare deletion of origin %s from tracker", origin->databaseIdentifier().ascii().data()); return false; } originStatement.bindText(1, origin->databaseIdentifier()); if (!originStatement.executeCommand()) { LOG_ERROR("Unable to execute deletion of databases from origin %s from tracker", origin->databaseIdentifier().ascii().data()); return false; } SQLiteFileSystem::deleteEmptyDatabaseDirectory(originPath(origin)); RefPtr<SecurityOrigin> originPossiblyLastReference = origin; bool isEmpty = true; openTrackerDatabase(DontCreateIfDoesNotExist); if (m_database.isOpen()) { SQLiteStatement statement(m_database, "SELECT origin FROM Origins"); if (statement.prepare() != SQLResultOk) LOG_ERROR("Failed to prepare statement."); else if (statement.step() == SQLResultRow) isEmpty = false; } // If we removed the last origin, do some additional deletion. if (isEmpty) { if (m_database.isOpen()) m_database.close(); SQLiteFileSystem::deleteDatabaseFile(trackerDatabasePath()); SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_databaseDirectoryPath); } if (m_client) { m_client->dispatchDidModifyOrigin(origin); for (unsigned i = 0; i < databaseNames.size(); ++i) m_client->dispatchDidModifyDatabase(origin, databaseNames[i]); } } return true; }