1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QNETWORKDISKCACHE_H |
5 | #define QNETWORKDISKCACHE_H |
6 | |
7 | #include <QtNetwork/qtnetworkglobal.h> |
8 | #include <QtNetwork/qabstractnetworkcache.h> |
9 | |
10 | QT_REQUIRE_CONFIG(networkdiskcache); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QNetworkDiskCachePrivate; |
15 | class Q_NETWORK_EXPORT QNetworkDiskCache : public QAbstractNetworkCache |
16 | { |
17 | Q_OBJECT |
18 | |
19 | public: |
20 | explicit QNetworkDiskCache(QObject *parent = nullptr); |
21 | ~QNetworkDiskCache(); |
22 | |
23 | QString cacheDirectory() const; |
24 | void setCacheDirectory(const QString &cacheDir); |
25 | |
26 | qint64 maximumCacheSize() const; |
27 | void setMaximumCacheSize(qint64 size); |
28 | |
29 | qint64 cacheSize() const override; |
30 | QNetworkCacheMetaData metaData(const QUrl &url) override; |
31 | void updateMetaData(const QNetworkCacheMetaData &metaData) override; |
32 | QIODevice *data(const QUrl &url) override; |
33 | bool remove(const QUrl &url) override; |
34 | QIODevice *prepare(const QNetworkCacheMetaData &metaData) override; |
35 | void insert(QIODevice *device) override; |
36 | |
37 | QNetworkCacheMetaData fileMetaData(const QString &fileName) const; |
38 | |
39 | public Q_SLOTS: |
40 | void clear() override; |
41 | |
42 | protected: |
43 | virtual qint64 expire(); |
44 | |
45 | private: |
46 | Q_DECLARE_PRIVATE(QNetworkDiskCache) |
47 | Q_DISABLE_COPY(QNetworkDiskCache) |
48 | }; |
49 | |
50 | QT_END_NAMESPACE |
51 | |
52 | #endif // QNETWORKDISKCACHE_H |
53 |