OpenCoverage

qnetworkaccesscache.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccesscache.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
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 https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qnetworkaccesscache_p.h"-
41#include "QtCore/qpointer.h"-
42#include "QtCore/qdatetime.h"-
43#include "QtCore/qqueue.h"-
44#include "qnetworkaccessmanager_p.h"-
45#include "qnetworkreply_p.h"-
46#include "qnetworkrequest.h"-
47-
48QT_BEGIN_NAMESPACE-
49-
50enum ExpiryTimeEnum {-
51 ExpiryTime = 120-
52};-
53-
54namespace {-
55 struct Receiver-
56 {-
57 QPointer<QObject> object;-
58 const char *member;-
59 };-
60}-
61-
62// idea copied from qcache.h-
63struct QNetworkAccessCache::Node-
64{-
65 QDateTime timestamp;-
66 QQueue<Receiver> receiverQueue;-
67 QByteArray key;-
68-
69 Node *older, *newer;-
70 CacheableObject *object;-
71-
72 int useCount;-
73-
74 Node()-
75 : older(0), newer(0), object(0), useCount(0)-
76 { }
executed 905 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
905
77};-
78-
79QNetworkAccessCache::CacheableObject::CacheableObject()-
80{-
81 // leave the members uninitialized-
82 // they must be initialized by the derived class's constructor-
83}-
84-
85QNetworkAccessCache::CacheableObject::~CacheableObject()-
86{-
87#if 0 //def QT_DEBUG-
88 if (!key.isEmpty() && Ptr()->hasEntry(key))-
89 qWarning() << "QNetworkAccessCache: object" << (void*)this << "key" << key-
90 << "destroyed without being removed from cache first!";-
91#endif-
92}-
93-
94void QNetworkAccessCache::CacheableObject::setExpires(bool enable)-
95{-
96 expires = enable;-
97}
executed 914 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
914
98-
99void QNetworkAccessCache::CacheableObject::setShareable(bool enable)-
100{-
101 shareable = enable;-
102}
executed 914 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
914
103-
104QNetworkAccessCache::QNetworkAccessCache()-
105 : oldest(0), newest(0)-
106{-
107}
executed 722 times by 11 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
722
108-
109QNetworkAccessCache::~QNetworkAccessCache()-
110{-
111 clear();-
112}
executed 723 times by 12 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_spdy - unknown status
723
113-
114void QNetworkAccessCache::clear()-
115{-
116 NodeHash hashCopy = hash;-
117 hash.clear();-
118-
119 // remove all entries-
120 NodeHash::Iterator it = hashCopy.begin();-
121 NodeHash::Iterator end = hashCopy.end();-
122 for ( ; it != end; ++it) {
it != endDescription
TRUEevaluated 895 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
FALSEevaluated 2015 times by 12 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_spdy - unknown status
895-2015
123 it->object->key.clear();-
124 it->object->dispose();-
125 }
executed 895 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
895
126-
127 // now delete:-
128 hashCopy.clear();-
129-
130 timer.stop();-
131-
132 oldest = newest = 0;-
133}
executed 2015 times by 12 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_spdy - unknown status
2015
134-
135/*!-
136 Appends the entry given by \a key to the end of the linked list.-
137 (i.e., makes it the newest entry)-
138 */-
139void QNetworkAccessCache::linkEntry(const QByteArray &key)-
140{-
141 NodeHash::Iterator it = hash.find(key);-
142 if (it == hash.end())
it == hash.end()Description
TRUEnever evaluated
FALSEevaluated 628 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-628
143 return;
never executed: return;
0
144-
145 Node *const node = &it.value();-
146 Q_ASSERT(node != oldest && node != newest);-
147 Q_ASSERT(node->older == 0 && node->newer == 0);-
148 Q_ASSERT(node->useCount == 0);-
149-
150 if (newest) {
newestDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 606 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
22-606
151 Q_ASSERT(newest->newer == 0);-
152 newest->newer = node;-
153 node->older = newest;-
154 }
executed 22 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
22
155 if (!oldest) {
!oldestDescription
TRUEevaluated 606 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
22-606
156 // there are no entries, so this is the oldest one too-
157 oldest = node;-
158 }
executed 606 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
606
159-
160 node->timestamp = QDateTime::currentDateTimeUtc().addSecs(ExpiryTime);-
161 newest = node;-
162}
executed 628 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
628
163-
164/*!-
165 Removes the entry pointed by \a key from the linked list.-
166 Returns \c true if the entry removed was the oldest one.-
167 */-
168bool QNetworkAccessCache::unlinkEntry(const QByteArray &key)-
169{-
170 NodeHash::Iterator it = hash.find(key);-
171 if (it == hash.end())
it == hash.end()Description
TRUEevaluated 905 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 59 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
59-905
172 return false;
executed 905 times by 8 tests: return false;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
905
173-
174 Node *const node = &it.value();-
175-
176 bool wasOldest = false;-
177 if (node == oldest) {
node == oldestDescription
TRUEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
29-30
178 oldest = node->newer;-
179 wasOldest = true;-
180 }
executed 29 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
29
181 if (node == newest)
node == newestDescription
TRUEevaluated 34 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
25-34
182 newest = node->older;
executed 34 times by 3 tests: newest = node->older;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
34
183 if (node->older)
node->olderDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 47 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
12-47
184 node->older->newer = node->newer;
executed 12 times by 1 test: node->older->newer = node->newer;
Executed by:
  • tst_Spdy
12
185 if (node->newer)
node->newerDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 52 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
7-52
186 node->newer->older = node->older;
executed 7 times by 1 test: node->newer->older = node->older;
Executed by:
  • tst_Spdy
7
187-
188 node->newer = node->older = 0;-
189 return wasOldest;
executed 59 times by 3 tests: return wasOldest;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
59
190}-
191-
192void QNetworkAccessCache::updateTimer()-
193{-
194 timer.stop();-
195-
196 if (!oldest)
!oldestDescription
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 607 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
28-607
197 return;
executed 28 times by 2 tests: return;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
28
198-
199 int interval = QDateTime::currentDateTimeUtc().secsTo(oldest->timestamp);-
200 if (interval <= 0) {
interval <= 0Description
TRUEnever evaluated
FALSEevaluated 607 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-607
201 interval = 0;-
202 } else {
never executed: end of block
0
203 // round up the interval-
204 interval = (interval + 15) & ~16;-
205 }
executed 607 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
607
206-
207 timer.start(interval * 1000, this);-
208}
executed 607 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
607
209-
210bool QNetworkAccessCache::emitEntryReady(Node *node, QObject *target, const char *member)-
211{-
212 if (!connect(this, SIGNAL(entryReady(QNetworkAccessCache::CacheableObject*)),
!connect(this,...uedConnection)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
0-1
213 target, member, Qt::QueuedConnection))
!connect(this,...uedConnection)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
0-1
214 return false;
never executed: return false;
0
215-
216 emit entryReady(node->object);-
217 disconnect(SIGNAL(entryReady(QNetworkAccessCache::CacheableObject*)));-
218-
219 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkReply
1
220}-
221-
222void QNetworkAccessCache::timerEvent(QTimerEvent *)-
223{-
224 // expire old items-
225 const QDateTime now = QDateTime::currentDateTimeUtc();-
226-
227 while (oldest && oldest->timestamp < now) {
oldestDescription
TRUEnever evaluated
FALSEnever evaluated
oldest->timestamp < nowDescription
TRUEnever evaluated
FALSEnever evaluated
0
228 Node *next = oldest->newer;-
229 oldest->object->dispose();-
230-
231 hash.remove(oldest->key); // oldest gets deleted-
232 oldest = next;-
233 }
never executed: end of block
0
234-
235 // fixup the list-
236 if (oldest)
oldestDescription
TRUEnever evaluated
FALSEnever evaluated
0
237 oldest->older = 0;
never executed: oldest->older = 0;
0
238 else-
239 newest = 0;
never executed: newest = 0;
0
240-
241 updateTimer();-
242}
never executed: end of block
0
243-
244void QNetworkAccessCache::addEntry(const QByteArray &key, CacheableObject *entry)-
245{-
246 Q_ASSERT(!key.isEmpty());-
247-
248 if (unlinkEntry(key))
unlinkEntry(key)Description
TRUEnever evaluated
FALSEevaluated 914 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-914
249 updateTimer();
never executed: updateTimer();
0
250-
251 Node &node = hash[key]; // create the entry in the hash if it didn't exist-
252 if (node.useCount)
node.useCountDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 905 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
9-905
253 qWarning("QNetworkAccessCache::addEntry: overriding active cache entry '%s'",
executed 9 times by 1 test: QMessageLogger(__FILE__, 253, __PRETTY_FUNCTION__).warning("QNetworkAccessCache::addEntry: overriding active cache entry '%s'", key.constData());
Executed by:
  • tst_QNetworkReply
9
254 key.constData());
executed 9 times by 1 test: QMessageLogger(__FILE__, 253, __PRETTY_FUNCTION__).warning("QNetworkAccessCache::addEntry: overriding active cache entry '%s'", key.constData());
Executed by:
  • tst_QNetworkReply
9
255 if (node.object)
node.objectDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 905 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
9-905
256 node.object->dispose();
executed 9 times by 1 test: node.object->dispose();
Executed by:
  • tst_QNetworkReply
9
257 node.object = entry;-
258 node.object->key = key;-
259 node.key = key;-
260 node.useCount = 1;-
261}
executed 914 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
914
262-
263bool QNetworkAccessCache::hasEntry(const QByteArray &key) const-
264{-
265 return hash.contains(key);
executed 997 times by 4 tests: return hash.contains(key);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
997
266}-
267-
268bool QNetworkAccessCache::requestEntry(const QByteArray &key, QObject *target, const char *member)-
269{-
270 NodeHash::Iterator it = hash.find(key);-
271 if (it == hash.end())
it == hash.end()Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-48
272 return false; // no such entry
executed 48 times by 1 test: return false;
Executed by:
  • tst_QNetworkReply
48
273-
274 Node *node = &it.value();-
275-
276 if (node->useCount > 0 && !node->object->shareable) {
node->useCount > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
!node->object->shareableDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
277 // object is not shareable and is in use-
278 // queue for later use-
279 Q_ASSERT(node->older == 0 && node->newer == 0);-
280 Receiver receiver;-
281 receiver.object = target;-
282 receiver.member = member;-
283 node->receiverQueue.enqueue(receiver);-
284-
285 // request queued-
286 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QNetworkReply
1
287 } else {-
288 // node not in use or is shareable-
289 if (unlinkEntry(key))
unlinkEntry(key)Description
TRUEnever evaluated
FALSEnever evaluated
0
290 updateTimer();
never executed: updateTimer();
0
291-
292 ++node->useCount;-
293 return emitEntryReady(node, target, member);
never executed: return emitEntryReady(node, target, member);
0
294 }-
295}-
296-
297QNetworkAccessCache::CacheableObject *QNetworkAccessCache::requestEntryNow(const QByteArray &key)-
298{-
299 NodeHash::Iterator it = hash.find(key);-
300 if (it == hash.end())
it == hash.end()Description
TRUEevaluated 551 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 718 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
551-718
301 return 0;
executed 551 times by 8 tests: return 0;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
551
302 if (it->useCount > 0) {
it->useCount > 0Description
TRUEevaluated 677 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 41 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
41-677
303 if (it->object->shareable) {
it->object->shareableDescription
TRUEevaluated 677 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-677
304 ++it->useCount;-
305 return it->object;
executed 677 times by 3 tests: return it->object;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
677
306 }-
307-
308 // object in use and not shareable-
309 return 0;
never executed: return 0;
0
310 }-
311-
312 // entry not in use, let the caller have it-
313 bool wasOldest = unlinkEntry(key);-
314 ++it->useCount;-
315-
316 if (wasOldest)
wasOldestDescription
TRUEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_Spdy
12-29
317 updateTimer();
executed 29 times by 3 tests: updateTimer();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
29
318 return it->object;
executed 41 times by 3 tests: return it->object;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
41
319}-
320-
321void QNetworkAccessCache::releaseEntry(const QByteArray &key)-
322{-
323 NodeHash::Iterator it = hash.find(key);-
324 if (it == hash.end()) {
it == hash.end()Description
TRUEnever evaluated
FALSEevaluated 1304 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-1304
325 qWarning("QNetworkAccessCache::releaseEntry: trying to release key '%s' that is not in cache",-
326 key.constData());-
327 return;
never executed: return;
0
328 }-
329-
330 Node *node = &it.value();-
331 Q_ASSERT(node->useCount > 0);-
332-
333 // are there other objects waiting?-
334 if (!node->receiverQueue.isEmpty()) {
!node->receiverQueue.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1303 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1-1303
335 // queue another activation-
336 Receiver receiver;-
337 do {-
338 receiver = node->receiverQueue.dequeue();-
339 } while (receiver.object.isNull() && !node->receiverQueue.isEmpty());
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
receiver.object.isNull()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
!node->receiverQueue.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0-1
340-
341 if (!receiver.object.isNull()) {
!receiver.object.isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
342 emitEntryReady(node, receiver.object, receiver.member);-
343 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkReply
1
344 }-
345 }
never executed: end of block
0
346-
347 if (!--node->useCount) {
!--node->useCountDescription
TRUEevaluated 628 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 675 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
628-675
348 // no objects waiting; add it back to the expiry list-
349 if (node->object->expires)
node->object->expiresDescription
TRUEevaluated 628 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-628
350 linkEntry(key);
executed 628 times by 8 tests: linkEntry(key);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
628
351-
352 if (oldest == node)
oldest == nodeDescription
TRUEevaluated 606 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
22-606
353 updateTimer();
executed 606 times by 8 tests: updateTimer();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
606
354 }
executed 628 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
628
355}
executed 1303 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1303
356-
357void QNetworkAccessCache::removeEntry(const QByteArray &key)-
358{-
359 NodeHash::Iterator it = hash.find(key);-
360 if (it == hash.end()) {
it == hash.end()Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-9
361 qWarning("QNetworkAccessCache::removeEntry: trying to remove key '%s' that is not in cache",-
362 key.constData());-
363 return;
never executed: return;
0
364 }-
365-
366 Node *node = &it.value();-
367 if (unlinkEntry(key))
unlinkEntry(key)Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-9
368 updateTimer();
never executed: updateTimer();
0
369 if (node->useCount > 1)
node->useCount > 1Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-9
370 qWarning("QNetworkAccessCache::removeEntry: removing active cache entry '%s'",
never executed: QMessageLogger(__FILE__, 370, __PRETTY_FUNCTION__).warning("QNetworkAccessCache::removeEntry: removing active cache entry '%s'", key.constData());
0
371 key.constData());
never executed: QMessageLogger(__FILE__, 370, __PRETTY_FUNCTION__).warning("QNetworkAccessCache::removeEntry: removing active cache entry '%s'", key.constData());
0
372-
373 node->object->key.clear();-
374 hash.remove(node->key);-
375}
executed 9 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
9
376-
377QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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