qabstractnetworkcache.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qabstractnetworkcache.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qabstractnetworkcache.h"-
35#include "qabstractnetworkcache_p.h"-
36-
37#include <qdatastream.h>-
38#include <qdatetime.h>-
39#include <qurl.h>-
40-
41#include <qdebug.h>-
42-
43QT_BEGIN_NAMESPACE-
44-
45class QNetworkCacheMetaDataPrivate : public QSharedData-
46{-
47-
48public:-
49 QNetworkCacheMetaDataPrivate()-
50 : QSharedData()-
51 , saveToDisk(true)-
52 {}
executed 708 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
708
53-
54 bool operator==(const QNetworkCacheMetaDataPrivate &other) const-
55 {-
56 return
executed 372 times by 4 tests: return url == other.url && lastModified == other.lastModified && expirationDate == other.expirationDate && headers == other.headers && saveToDisk == other.saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
372
57 url == other.url
executed 372 times by 4 tests: return url == other.url && lastModified == other.lastModified && expirationDate == other.expirationDate && headers == other.headers && saveToDisk == other.saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
url == other.urlDescription
TRUEevaluated 102 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
FALSEevaluated 270 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
102-372
58 && lastModified == other.lastModified
executed 372 times by 4 tests: return url == other.url && lastModified == other.lastModified && expirationDate == other.expirationDate && headers == other.headers && saveToDisk == other.saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
lastModified =...r.lastModifiedDescription
TRUEevaluated 97 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qnetworkcachemetadata - unknown status
5-372
59 && expirationDate == other.expirationDate
executed 372 times by 4 tests: return url == other.url && lastModified == other.lastModified && expirationDate == other.expirationDate && headers == other.headers && saveToDisk == other.saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
expirationDate...expirationDateDescription
TRUEevaluated 86 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
FALSEevaluated 11 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
11-372
60 && headers == other.headers
executed 372 times by 4 tests: return url == other.url && lastModified == other.lastModified && expirationDate == other.expirationDate && headers == other.headers && saveToDisk == other.saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
headers == other.headersDescription
TRUEevaluated 81 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_qnetworkcachemetadata - unknown status
5-372
61 && saveToDisk == other.saveToDisk;
executed 372 times by 4 tests: return url == other.url && lastModified == other.lastModified && expirationDate == other.expirationDate && headers == other.headers && saveToDisk == other.saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
saveToDisk == other.saveToDiskDescription
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcachemetadata - unknown status
2-372
62 }-
63-
64 QUrl url;-
65 QDateTime lastModified;-
66 QDateTime expirationDate;-
67 QNetworkCacheMetaData::RawHeaderList headers;-
68 QNetworkCacheMetaData::AttributesMap attributes;-
69 bool saveToDisk;-
70-
71 static void save(QDataStream &out, const QNetworkCacheMetaData &metaData);-
72 static void load(QDataStream &in, QNetworkCacheMetaData &metaData);-
73};-
74Q_GLOBAL_STATIC(QNetworkCacheMetaDataPrivate, metadata_shared_invalid)
executed 3 times by 3 tests: end of block
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qnetworkcachemetadata - unknown status
  • tst_qnetworkdiskcache - unknown status
executed 3 times by 3 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qnetworkcachemetadata - unknown status
  • tst_qnetworkdiskcache - unknown status
executed 337 times by 4 tests: return &holder.value;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
guard.load() =...c::InitializedDescription
TRUEevaluated 3 times by 3 tests
Evaluated by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qnetworkcachemetadata - unknown status
  • tst_qnetworkdiskcache - unknown status
FALSEnever evaluated
0-337
75-
76/*!-
77 \class QNetworkCacheMetaData-
78 \since 4.5-
79 \ingroup shared-
80 \inmodule QtNetwork-
81-
82 \brief The QNetworkCacheMetaData class provides cache information.-
83-
84 QNetworkCacheMetaData provides information about a cache file including-
85 the url, when it was last modified, when the cache file was created, headers-
86 for file and if the file should be saved onto a disk.-
87-
88 \sa QAbstractNetworkCache-
89*/-
90-
91/*!-
92 \typedef QNetworkCacheMetaData::RawHeader-
93-
94 Synonym for QPair<QByteArray, QByteArray>-
95*/-
96-
97/*!-
98 \typedef QNetworkCacheMetaData::RawHeaderList-
99-
100 Synonym for QList<RawHeader>-
101*/-
102-
103/*!-
104 \typedef QNetworkCacheMetaData::AttributesMap-
105-
106 Synonym for QHash<QNetworkRequest::Attribute, QVariant>-
107*/-
108-
109/*!-
110 Constructs an invalid network cache meta data.-
111-
112 \sa isValid()-
113 */-
114QNetworkCacheMetaData::QNetworkCacheMetaData()-
115 : d(new QNetworkCacheMetaDataPrivate)-
116{-
117}
executed 704 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
704
118-
119/*!-
120 Destroys the network cache meta data.-
121 */-
122QNetworkCacheMetaData::~QNetworkCacheMetaData()-
123{-
124 // QSharedDataPointer takes care of freeing d-
125}-
126-
127/*!-
128 Constructs a copy of the \a other QNetworkCacheMetaData.-
129 */-
130QNetworkCacheMetaData::QNetworkCacheMetaData(const QNetworkCacheMetaData &other)-
131 : d(other.d)-
132{-
133}
executed 335 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
335
134-
135/*!-
136 Makes a copy of the \a other QNetworkCacheMetaData and returns a reference to the copy.-
137 */-
138QNetworkCacheMetaData &QNetworkCacheMetaData::operator=(const QNetworkCacheMetaData &other)-
139{-
140 d = other.d;-
141 return *this;
executed 92 times by 4 tests: return *this;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
92
142}-
143-
144/*!-
145 \fn void QNetworkCacheMetaData::swap(QNetworkCacheMetaData &other)-
146 \since 5.0-
147-
148 Swaps this metadata instance with \a other. This function is very-
149 fast and never fails.-
150 */-
151-
152/*!-
153 Returns \c true if this meta data is equal to the \a other meta data; otherwise returns \c false.-
154-
155 \sa operator!=()-
156 */-
157bool QNetworkCacheMetaData::operator==(const QNetworkCacheMetaData &other) const-
158{-
159 if (d == other.d)
d == other.dDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qnetworkcachemetadata - unknown status
FALSEevaluated 35 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
7-35
160 return true;
executed 7 times by 1 test: return true;
Executed by:
  • tst_qnetworkcachemetadata - unknown status
7
161 if (d && other.d)-
162 return *d == *other.d;
executed 35 times by 4 tests: return *d == *other.d;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
35
163 return false;
never executed: return false;
0
164}-
165-
166/*!-
167 \fn bool QNetworkCacheMetaData::operator!=(const QNetworkCacheMetaData &other) const-
168-
169 Returns \c true if this meta data is not equal to the \a other meta data; otherwise returns \c false.-
170-
171 \sa operator==()-
172 */-
173-
174/*!-
175 Returns \c true if this network cache meta data has attributes that have been set otherwise false.-
176 */-
177bool QNetworkCacheMetaData::isValid() const-
178{-
179 return !(*d == *metadata_shared_invalid());
executed 337 times by 4 tests: return !(*d == *metadata_shared_invalid());
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
337
180}-
181-
182/*!-
183 Returns is this cache should be allowed to be stored on disk.-
184-
185 Some cache implementations can keep these cache items in memory for performance reasons,-
186 but for security reasons they should not be written to disk.-
187-
188 Specifically with http, documents marked with Pragma: no-cache, or have a Cache-control set to-
189 no-store or no-cache or any https document that doesn't have "Cache-control: public" set will-
190 set the saveToDisk to false.-
191-
192 \sa setSaveToDisk()-
193 */-
194bool QNetworkCacheMetaData::saveToDisk() const-
195{-
196 return d->saveToDisk;
executed 310 times by 4 tests: return d->saveToDisk;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
310
197}-
198-
199/*!-
200 Sets whether this network cache meta data and associated content should be-
201 allowed to be stored on disk to \a allow.-
202-
203 \sa saveToDisk()-
204 */-
205void QNetworkCacheMetaData::setSaveToDisk(bool allow)-
206{-
207 d->saveToDisk = allow;-
208}
executed 79 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
79
209-
210/*!-
211 Returns the URL this network cache meta data is referring to.-
212-
213 \sa setUrl()-
214 */-
215QUrl QNetworkCacheMetaData::url() const-
216{-
217 return d->url;
executed 692 times by 4 tests: return d->url;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
692
218}-
219-
220/*!-
221 Sets the URL this network cache meta data to be \a url.-
222-
223 The password and fragment are removed from the url.-
224-
225 \sa url()-
226 */-
227void QNetworkCacheMetaData::setUrl(const QUrl &url)-
228{-
229 d->url = url;-
230 d->url.setPassword(QString());-
231 d->url.setFragment(QString());-
232}
executed 120 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
120
233-
234/*!-
235 Returns a list of all raw headers that are set in this meta data.-
236 The list is in the same order that the headers were set.-
237-
238 \sa setRawHeaders()-
239 */-
240QNetworkCacheMetaData::RawHeaderList QNetworkCacheMetaData::rawHeaders() const-
241{-
242 return d->headers;
executed 501 times by 4 tests: return d->headers;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
501
243}-
244-
245/*!-
246 Sets the raw headers to \a list.-
247-
248 \sa rawHeaders()-
249 */-
250void QNetworkCacheMetaData::setRawHeaders(const RawHeaderList &list)-
251{-
252 d->headers = list;-
253}
executed 98 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
98
254-
255/*!-
256 Returns the date and time when the meta data was last modified.-
257 */-
258QDateTime QNetworkCacheMetaData::lastModified() const-
259{-
260 return d->lastModified;
executed 131 times by 4 tests: return d->lastModified;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
131
261}-
262-
263/*!-
264 Sets the date and time when the meta data was last modified to \a dateTime.-
265 */-
266void QNetworkCacheMetaData::setLastModified(const QDateTime &dateTime)-
267{-
268 d->lastModified = dateTime;-
269}
executed 43 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
43
270-
271/*!-
272 Returns the date and time when the meta data expires.-
273 */-
274QDateTime QNetworkCacheMetaData::expirationDate() const-
275{-
276 return d->expirationDate;
executed 125 times by 4 tests: return d->expirationDate;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
125
277}-
278-
279/*!-
280 Sets the date and time when the meta data expires to \a dateTime.-
281 */-
282void QNetworkCacheMetaData::setExpirationDate(const QDateTime &dateTime)-
283{-
284 d->expirationDate = dateTime;-
285}
executed 49 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
49
286-
287/*!-
288 \since 4.6-
289-
290 Returns all the attributes stored with this cache item.-
291-
292 \sa setAttributes(), QNetworkRequest::Attribute-
293*/-
294QNetworkCacheMetaData::AttributesMap QNetworkCacheMetaData::attributes() const-
295{-
296 return d->attributes;
executed 139 times by 4 tests: return d->attributes;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
139
297}-
298-
299/*!-
300 \since 4.6-
301-
302 Sets all attributes of this cache item to be the map \a attributes.-
303-
304 \sa attributes(), QNetworkRequest::setAttribute()-
305*/-
306void QNetworkCacheMetaData::setAttributes(const AttributesMap &attributes)-
307{-
308 d->attributes = attributes;-
309}
executed 70 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
70
310-
311/*!-
312 \relates QNetworkCacheMetaData-
313 \since 4.5-
314-
315 Writes \a metaData to the \a out stream.-
316-
317 \sa {Serializing Qt Data Types}-
318*/-
319QDataStream &operator<<(QDataStream &out, const QNetworkCacheMetaData &metaData)-
320{-
321 QNetworkCacheMetaDataPrivate::save(out, metaData);-
322 return out;
executed 91 times by 4 tests: return out;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
91
323}-
324-
325static inline QDataStream &operator<<(QDataStream &out, const QNetworkCacheMetaData::AttributesMap &hash)-
326{-
327 out << quint32(hash.size());-
328 QNetworkCacheMetaData::AttributesMap::ConstIterator it = hash.end();-
329 QNetworkCacheMetaData::AttributesMap::ConstIterator begin = hash.begin();-
330 while (it != begin) {
it != beginDescription
TRUEevaluated 118 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 91 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
91-118
331 --it;-
332 out << int(it.key()) << it.value();-
333 }
executed 118 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
118
334 return out;
executed 91 times by 4 tests: return out;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
91
335}-
336-
337void QNetworkCacheMetaDataPrivate::save(QDataStream &out, const QNetworkCacheMetaData &metaData)-
338{-
339 // note: if you change the contents of the meta data here-
340 // remember to bump the cache version in qnetworkdiskcache.cpp CurrentCacheVersion-
341 out << metaData.url();-
342 out << metaData.expirationDate();-
343 out << metaData.lastModified();-
344 out << metaData.saveToDisk();-
345 out << metaData.attributes();-
346 out << metaData.rawHeaders();-
347}
executed 91 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
91
348-
349/*!-
350 \relates QNetworkCacheMetaData-
351 \since 4.5-
352-
353 Reads a QNetworkCacheMetaData from the stream \a in into \a metaData.-
354-
355 \sa {Serializing Qt Data Types}-
356*/-
357QDataStream &operator>>(QDataStream &in, QNetworkCacheMetaData &metaData)-
358{-
359 QNetworkCacheMetaDataPrivate::load(in, metaData);-
360 return in;
executed 86 times by 4 tests: return in;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
86
361}-
362-
363static inline QDataStream &operator>>(QDataStream &in, QNetworkCacheMetaData::AttributesMap &hash)-
364{-
365 hash.clear();-
366 QDataStream::Status oldStatus = in.status();-
367 in.resetStatus();-
368 hash.clear();-
369-
370 quint32 n;-
371 in >> n;-
372-
373 for (quint32 i = 0; i < n; ++i) {
i < nDescription
TRUEevaluated 126 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 86 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
86-126
374 if (in.status() != QDataStream::Ok)
in.status() != QDataStream::OkDescription
TRUEnever evaluated
FALSEevaluated 126 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-126
375 break;
never executed: break;
0
376-
377 int k;-
378 QVariant t;-
379 in >> k >> t;-
380 hash.insertMulti(QNetworkRequest::Attribute(k), t);-
381 }
executed 126 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
126
382-
383 if (in.status() != QDataStream::Ok)
in.status() != QDataStream::OkDescription
TRUEnever evaluated
FALSEevaluated 86 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
0-86
384 hash.clear();
never executed: hash.clear();
0
385 if (oldStatus != QDataStream::Ok)
oldStatus != QDataStream::OkDescription
TRUEnever evaluated
FALSEevaluated 86 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
0-86
386 in.setStatus(oldStatus);
never executed: in.setStatus(oldStatus);
0
387 return in;
executed 86 times by 4 tests: return in;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
86
388}-
389-
390void QNetworkCacheMetaDataPrivate::load(QDataStream &in, QNetworkCacheMetaData &metaData)-
391{-
392 in >> metaData.d->url;-
393 in >> metaData.d->expirationDate;-
394 in >> metaData.d->lastModified;-
395 in >> metaData.d->saveToDisk;-
396 in >> metaData.d->attributes;-
397 in >> metaData.d->headers;-
398}
executed 86 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcachemetadata - unknown status
86
399-
400/*!-
401 \class QAbstractNetworkCache-
402 \since 4.5-
403 \inmodule QtNetwork-
404-
405 \brief The QAbstractNetworkCache class provides the interface for cache implementations.-
406-
407 QAbstractNetworkCache is the base class for every standard cache that is used by-
408 QNetworkAccessManager. QAbstractNetworkCache is an abstract class and cannot be-
409 instantiated.-
410-
411 \sa QNetworkDiskCache-
412*/-
413-
414/*!-
415 Constructs an abstract network cache with the given \a parent.-
416*/-
417QAbstractNetworkCache::QAbstractNetworkCache(QObject *parent)-
418 : QObject(*new QAbstractNetworkCachePrivate, parent)-
419{-
420}
executed 23 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
23
421-
422/*!-
423 \internal-
424*/-
425QAbstractNetworkCache::QAbstractNetworkCache(QAbstractNetworkCachePrivate &dd, QObject *parent)-
426 : QObject(dd, parent)-
427{-
428}
executed 66 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
66
429-
430/*!-
431 Destroys the cache.-
432-
433 Any operations that have not been inserted are discarded.-
434-
435 \sa insert()-
436 */-
437QAbstractNetworkCache::~QAbstractNetworkCache()-
438{-
439}-
440-
441/*!-
442 \fn QNetworkCacheMetaData QAbstractNetworkCache::metaData(const QUrl &url) = 0-
443 Returns the meta data for the url \a url.-
444-
445 If the url is valid and the cache contains the data for url,-
446 a valid QNetworkCacheMetaData is returned.-
447-
448 In the base class this is a pure virtual function.-
449-
450 \sa updateMetaData(), data()-
451*/-
452-
453/*!-
454 \fn void QAbstractNetworkCache::updateMetaData(const QNetworkCacheMetaData &metaData) = 0-
455 Updates the cache meta date for the metaData's url to \a metaData-
456-
457 If the cache does not contains a cache item for the url then no action is taken.-
458-
459 In the base class this is a pure virtual function.-
460-
461 \sa metaData(), prepare()-
462*/-
463-
464/*!-
465 \fn QIODevice *QAbstractNetworkCache::data(const QUrl &url) = 0-
466 Returns the data associated with \a url.-
467-
468 It is up to the application that requests the data to delete-
469 the QIODevice when done with it.-
470-
471 If there is no cache for \a url, the url is invalid, or if there-
472 is an internal cache error 0 is returned.-
473-
474 In the base class this is a pure virtual function.-
475-
476 \sa metaData(), prepare()-
477*/-
478-
479/*!-
480 \fn bool QAbstractNetworkCache::remove(const QUrl &url) = 0-
481 Removes the cache entry for \a url, returning true if success otherwise false.-
482-
483 In the base class this is a pure virtual function.-
484-
485 \sa clear(), prepare()-
486*/-
487-
488/*!-
489 \fn QIODevice *QAbstractNetworkCache::prepare(const QNetworkCacheMetaData &metaData) = 0-
490 Returns the device that should be populated with the data for-
491 the cache item \a metaData. When all of the data has been written-
492 insert() should be called. If metaData is invalid or the url in-
493 the metadata is invalid 0 is returned.-
494-
495 The cache owns the device and will take care of deleting it when-
496 it is inserted or removed.-
497-
498 To cancel a prepared inserted call remove() on the metadata's url.-
499-
500 In the base class this is a pure virtual function.-
501-
502 \sa remove(), updateMetaData(), insert()-
503*/-
504-
505/*!-
506 \fn void QAbstractNetworkCache::insert(QIODevice *device) = 0-
507 Inserts the data in \a device and the prepared meta data into the cache.-
508 After this function is called the data and meta data should be retrievable-
509 using data() and metaData().-
510-
511 To cancel a prepared inserted call remove() on the metadata's url.-
512-
513 In the base class this is a pure virtual function.-
514-
515 \sa prepare(), remove()-
516*/-
517-
518/*!-
519 \fn qint64 QAbstractNetworkCache::cacheSize() const = 0-
520 Returns the current size taken up by the cache. Depending upon-
521 the cache implementation this might be disk or memory size.-
522-
523 In the base class this is a pure virtual function.-
524-
525 \sa clear()-
526*/-
527-
528/*!-
529 \fn void QAbstractNetworkCache::clear() = 0-
530 Removes all items from the cache. Unless there was failures-
531 clearing the cache cacheSize() should return 0 after a call to clear.-
532-
533 In the base class this is a pure virtual function.-
534-
535 \sa cacheSize(), remove()-
536*/-
537-
538QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9