QSampleCache: Add a method to check whether a sample is cached.
At the moment there is no way to tell whether a sample returned by QSampleCache comes from cache. This functionality is required for a unit test. Change-Id: Ice23bb39b8e4f0a58b9297b46bb19b9a8c34b53c Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
d6cba78516
commit
4d1579d37b
@@ -147,6 +147,12 @@ bool QSampleCache::isLoading() const
|
||||
return m_loadingThread.isRunning();
|
||||
}
|
||||
|
||||
bool QSampleCache::isCached(const QUrl &url) const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
return m_samples.contains(url);
|
||||
}
|
||||
|
||||
QSample* QSampleCache::requestSample(const QUrl& url)
|
||||
{
|
||||
//lock and add first to make sure live loadingThread will not be killed during this function call
|
||||
|
||||
@@ -140,6 +140,7 @@ public:
|
||||
void setCapacity(qint64 capacity);
|
||||
|
||||
bool isLoading() const;
|
||||
bool isCached(const QUrl& url) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void isLoadingChanged();
|
||||
@@ -148,7 +149,7 @@ private:
|
||||
QMap<QUrl, QSample*> m_samples;
|
||||
QSet<QSample*> m_staleSamples;
|
||||
QNetworkAccessManager *m_networkAccessManager;
|
||||
QMutex m_mutex;
|
||||
mutable QMutex m_mutex;
|
||||
qint64 m_capacity;
|
||||
qint64 m_usage;
|
||||
QThread m_loadingThread;
|
||||
|
||||
Reference in New Issue
Block a user