Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QNETWORKDISKCACHE_P_H
6
#
define
QNETWORKDISKCACHE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtNetwork
/
private
/
qtnetworkglobal_p
.
h
>
20
#
include
"private/qabstractnetworkcache_p.h"
21
22
#
include
<
qbuffer
.
h
>
23
#
include
<
qhash
.
h
>
24
#
include
<
qsavefile
.
h
>
25
26
QT_REQUIRE_CONFIG
(
networkdiskcache
);
27
28
QT_BEGIN_NAMESPACE
29
30
class
QCacheItem
31
{
32
public
:
33
QCacheItem() =
default
;
34
~QCacheItem()
35
{
36
reset();
37
}
38
39
QNetworkCacheMetaData metaData;
40
QBuffer data;
41
QSaveFile *file =
nullptr
;
42
inline
qint64 size()
const
43
{
return
file ? file->size() : data.size(); }
44
45
inline
void
reset() {
46
metaData = QNetworkCacheMetaData();
47
data.close();
48
delete
file;
49
file =
nullptr
;
50
}
51
void
writeHeader(QFileDevice *device)
const
;
52
void
writeCompressedData(QFileDevice *device)
const
;
53
bool
read(QFileDevice *device,
bool
readData);
54
55
bool
canCompress()
const
;
56
};
57
58
class
QNetworkDiskCachePrivate
:
public
QAbstractNetworkCachePrivate
59
{
60
public
:
61
QNetworkDiskCachePrivate
()
62
:
QAbstractNetworkCachePrivate
()
63
,
maximumCacheSize
(1024 * 1024 * 50)
64
,
currentCacheSize
(-1)
65
{}
66
67
static
QString
uniqueFileName
(
const
QUrl &url);
68
QString
cacheFileName
(
const
QUrl &url)
const
;
69
bool
removeFile
(
const
QString &file);
70
void
storeItem
(QCacheItem *item);
71
void
prepareLayout
();
72
static
quint32
crc32
(
const
char
*data, uint len);
73
74
mutable
QCacheItem
lastItem
;
75
QString
cacheDirectory
;
76
QString
dataDirectory
;
77
qint64
maximumCacheSize
;
78
qint64
currentCacheSize
;
79
80
QHash
<
QIODevice
*,
QCacheItem
*>
inserting
;
81
Q_DECLARE_PUBLIC(QNetworkDiskCache)
82
};
83
84
QT_END_NAMESPACE
85
86
#
endif
// QNETWORKDISKCACHE_P_H
QByteArray::FromBase64Result
\inmodule QtCore
Definition
qbytearray.h:824
QNetworkDiskCachePrivate
Definition
qnetworkdiskcache_p.h:59
QNetworkDiskCachePrivate::QNetworkDiskCachePrivate
QNetworkDiskCachePrivate()
Definition
qnetworkdiskcache_p.h:61
QNetworkDiskCachePrivate::cacheDirectory
QString cacheDirectory
Definition
qnetworkdiskcache_p.h:75
QNetworkDiskCachePrivate::removeFile
bool removeFile(const QString &file)
Put all of the misc file removing into one function to be extra safe.
Definition
qnetworkdiskcache.cpp:337
QNetworkDiskCachePrivate::cacheFileName
QString cacheFileName(const QUrl &url) const
Generates fully qualified path of cached resource from a URL.
Definition
qnetworkdiskcache.cpp:607
QNetworkDiskCachePrivate::uniqueFileName
static QString uniqueFileName(const QUrl &url)
Given a URL, generates a unique enough filename (and subdirectory).
Definition
qnetworkdiskcache.cpp:588
QNetworkDiskCachePrivate::prepareLayout
void prepareLayout()
Create subdirectories and other housekeeping on the filesystem.
Definition
qnetworkdiskcache.cpp:245
QNetworkDiskCachePrivate::dataDirectory
QString dataDirectory
Definition
qnetworkdiskcache_p.h:76
QNetworkDiskCachePrivate::currentCacheSize
qint64 currentCacheSize
Definition
qnetworkdiskcache_p.h:78
QNetworkDiskCachePrivate::lastItem
QCacheItem lastItem
Definition
qnetworkdiskcache_p.h:74
QNetworkDiskCachePrivate::inserting
QHash< QIODevice *, QCacheItem * > inserting
Definition
qnetworkdiskcache_p.h:80
QNetworkDiskCachePrivate::crc32
static quint32 crc32(const char *data, uint len)
QNetworkDiskCachePrivate::maximumCacheSize
qint64 maximumCacheSize
Definition
qnetworkdiskcache_p.h:77
QNetworkDiskCachePrivate::storeItem
void storeItem(QCacheItem *item)
Definition
qnetworkdiskcache.cpp:269
QNetworkDiskCache
The QNetworkDiskCache class provides a very basic disk cache.
Definition
qnetworkdiskcache.h:17
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(animation)
CACHE_VERSION
#define CACHE_VERSION
Definition
qnetworkdiskcache.cpp:25
DATA_DIR
#define DATA_DIR
Definition
qnetworkdiskcache.cpp:26
CACHE_POSTFIX
#define CACHE_POSTFIX
Definition
qnetworkdiskcache.cpp:24
CurrentCacheVersion
@ CurrentCacheVersion
Definition
qnetworkdiskcache.cpp:652
CacheMagic
@ CacheMagic
Definition
qnetworkdiskcache.cpp:651
MAX_COMPRESSION_SIZE
#define MAX_COMPRESSION_SIZE
Definition
qnetworkdiskcache.cpp:28
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(networkdiskcache)
qtbase
src
network
access
qnetworkdiskcache_p.h
Generated on
for Qt by
1.18.0