Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnetworkdiskcache_p.h
Go to the documentation of this file.
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_P_H
5#define QNETWORKDISKCACHE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19#include "private/qabstractnetworkcache_p.h"
20
21#include <qbuffer.h>
22#include <qhash.h>
23#include <qsavefile.h>
24
25QT_REQUIRE_CONFIG(networkdiskcache);
26
28
30{
31public:
32 QCacheItem() = default;
34 {
35 reset();
36 }
37
40 QSaveFile *file = nullptr;
41 inline qint64 size() const
42 { return file ? file->size() : data.size(); }
43
44 inline void reset() {
46 data.close();
47 delete file;
48 file = nullptr;
49 }
50 void writeHeader(QFileDevice *device) const;
52 bool read(QFileDevice *device, bool readData);
53
54 bool canCompress() const;
55};
56
58{
59public:
65
66 static QString uniqueFileName(const QUrl &url);
67 QString cacheFileName(const QUrl &url) const;
68 bool removeFile(const QString &file);
70 void prepareLayout();
71 static quint32 crc32(const char *data, uint len);
72
78
79 QHash<QIODevice*, QCacheItem*> inserting;
80 Q_DECLARE_PUBLIC(QNetworkDiskCache)
81};
82
84
85#endif // QNETWORKDISKCACHE_P_H
IOBluetoothDevice * device
\inmodule QtCore \reentrant
Definition qbuffer.h:16
void writeCompressedData(QFileDevice *device) const
bool canCompress() const
We compress small text and JavaScript files.
QCacheItem()=default
bool read(QFileDevice *device, bool readData)
Returns false if the file is a cache file, but is an older version and should be removed otherwise tr...
QNetworkCacheMetaData metaData
QSaveFile * file
qint64 size() const
void writeHeader(QFileDevice *device) const
\inmodule QtCore
Definition qfiledevice.h:32
The QNetworkCacheMetaData class provides cache information.
bool removeFile(const QString &file)
Put all of the misc file removing into one function to be extra safe.
QString cacheFileName(const QUrl &url) const
Generates fully qualified path of cached resource from a URL.
static QString uniqueFileName(const QUrl &url)
Given a URL, generates a unique enough filename (and subdirectory)
void prepareLayout()
Create subdirectories and other housekeeping on the filesystem.
QHash< QIODevice *, QCacheItem * > inserting
static quint32 crc32(const char *data, uint len)
void storeItem(QCacheItem *item)
The QNetworkDiskCache class provides a very basic disk cache.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLsizei len
#define QT_REQUIRE_CONFIG(feature)
unsigned int quint32
Definition qtypes.h:50
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
QFile file
[0]
QUrl url("example.com")
[constructor-url-reference]
QByteArray readData()
QGraphicsItem * item