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

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