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
qnetworkaccesscache_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 QNETWORKACCESSCACHE_P_H
5#define QNETWORKACCESSCACHE_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 for the convenience
12// of the Network Access API. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19#include "QtCore/qobject.h"
20#include "QtCore/qbasictimer.h"
21#include "QtCore/qbytearray.h"
22#include "QtCore/qhash.h"
23#include "QtCore/qmetatype.h"
24
26
27class QNetworkRequest;
28class QUrl;
29
30// this class is not about caching files but about
31// caching objects used by QNetworkAccessManager, e.g. existing TCP connections
32// or credentials.
34{
36public:
37 struct Node;
38 typedef QHash<QByteArray, Node *> NodeHash;
39
41 {
42 friend class QNetworkAccessCache;
44 bool expires;
45 bool shareable;
46 qint64 expiryTimeoutSeconds;
47 public:
49 virtual ~CacheableObject();
50 virtual void dispose() = 0;
51 inline QByteArray cacheKey() const { return key; }
52
53 protected:
54 void setExpires(bool enable);
55 void setShareable(bool enable);
56 };
57
59
60 void clear();
61
62 void addEntry(const QByteArray &key, CacheableObject *entry, qint64 connectionCacheExpiryTimeoutSeconds = -1);
63 bool hasEntry(const QByteArray &key) const;
64 CacheableObject *requestEntryNow(const QByteArray &key);
65 void releaseEntry(const QByteArray &key);
66 void removeEntry(const QByteArray &key);
67
70
71protected:
72 void timerEvent(QTimerEvent *) override;
73
74private:
75 // idea copied from qcache.h
77 Node *firstExpiringNode = nullptr;
78 Node *lastExpiringNode = nullptr;
79
81
82 void linkEntry(const QByteArray &key);
83 bool unlinkEntry(const QByteArray &key);
84 void updateTimer();
85 bool emitEntryReady(Node *node, QObject *target, const char *member);
86};
87
89
90#endif
\inmodule QtCore
Definition qbasictimer.h:18
\inmodule QtCore
Definition qbytearray.h:57
QHash< QByteArray, Node * > NodeHash
bool hasEntry(const QByteArray &key) const
void removeEntry(const QByteArray &key)
CacheableObject * requestEntryNow(const QByteArray &key)
void addEntry(const QByteArray &key, CacheableObject *entry, qint64 connectionCacheExpiryTimeoutSeconds=-1)
void entryReady(QNetworkAccessCache::CacheableObject *)
void releaseEntry(const QByteArray &key)
void timerEvent(QTimerEvent *) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qcoreevent.h:366
\inmodule QtCore
Definition qurl.h:94
QHash< int, QWidget * > hash
[35multi]
Combined button and popup list for selecting options.
GLuint64 key
GLenum target
GLboolean enable
GLuint entry
#define Q_OBJECT
#define signals
long long qint64
Definition qtypes.h:60
QTimer * timer
[3]