| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccesscache.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 | - | |||||||||||||
| 48 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | enum ExpiryTimeEnum { | - | ||||||||||||
| 51 | ExpiryTime = 120 | - | ||||||||||||
| 52 | }; | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | namespace { | - | ||||||||||||
| 55 | struct Receiver | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | QPointer<QObject> object; | - | ||||||||||||
| 58 | const char *member; | - | ||||||||||||
| 59 | }; | - | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | // idea copied from qcache.h | - | ||||||||||||
| 63 | struct 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 blockExecuted by:
| 905 | ||||||||||||
| 77 | }; | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | QNetworkAccessCache::CacheableObject::CacheableObject() | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | // leave the members uninitialized | - | ||||||||||||
| 82 | // they must be initialized by the derived class's constructor | - | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | QNetworkAccessCache::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 | - | |||||||||||||
| 94 | void QNetworkAccessCache::CacheableObject::setExpires(bool enable) | - | ||||||||||||
| 95 | { | - | ||||||||||||
| 96 | expires = enable; | - | ||||||||||||
| 97 | } executed 914 times by 8 tests: end of blockExecuted by:
| 914 | ||||||||||||
| 98 | - | |||||||||||||
| 99 | void QNetworkAccessCache::CacheableObject::setShareable(bool enable) | - | ||||||||||||
| 100 | { | - | ||||||||||||
| 101 | shareable = enable; | - | ||||||||||||
| 102 | } executed 914 times by 8 tests: end of blockExecuted by:
| 914 | ||||||||||||
| 103 | - | |||||||||||||
| 104 | QNetworkAccessCache::QNetworkAccessCache() | - | ||||||||||||
| 105 | : oldest(0), newest(0) | - | ||||||||||||
| 106 | { | - | ||||||||||||
| 107 | } executed 722 times by 11 tests: end of blockExecuted by:
| 722 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | QNetworkAccessCache::~QNetworkAccessCache() | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | clear(); | - | ||||||||||||
| 112 | } executed 723 times by 12 tests: end of blockExecuted by:
| 723 | ||||||||||||
| 113 | - | |||||||||||||
| 114 | void 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) {
| 895-2015 | ||||||||||||
| 123 | it->object->key.clear(); | - | ||||||||||||
| 124 | it->object->dispose(); | - | ||||||||||||
| 125 | } executed 895 times by 9 tests: end of blockExecuted by:
| 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 blockExecuted by:
| 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 | */ | - | ||||||||||||
| 139 | void QNetworkAccessCache::linkEntry(const QByteArray &key) | - | ||||||||||||
| 140 | { | - | ||||||||||||
| 141 | NodeHash::Iterator it = hash.find(key); | - | ||||||||||||
| 142 | if (it == hash.end())
| 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) {
| 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 blockExecuted by:
| 22 | ||||||||||||
| 155 | if (!oldest) {
| 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 blockExecuted by:
| 606 | ||||||||||||
| 159 | - | |||||||||||||
| 160 | node->timestamp = QDateTime::currentDateTimeUtc().addSecs(ExpiryTime); | - | ||||||||||||
| 161 | newest = node; | - | ||||||||||||
| 162 | } executed 628 times by 8 tests: end of blockExecuted by:
| 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 | */ | - | ||||||||||||
| 168 | bool QNetworkAccessCache::unlinkEntry(const QByteArray &key) | - | ||||||||||||
| 169 | { | - | ||||||||||||
| 170 | NodeHash::Iterator it = hash.find(key); | - | ||||||||||||
| 171 | if (it == hash.end())
| 59-905 | ||||||||||||
| 172 | return false; executed 905 times by 8 tests: return false;Executed by:
| 905 | ||||||||||||
| 173 | - | |||||||||||||
| 174 | Node *const node = &it.value(); | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | bool wasOldest = false; | - | ||||||||||||
| 177 | if (node == oldest) {
| 29-30 | ||||||||||||
| 178 | oldest = node->newer; | - | ||||||||||||
| 179 | wasOldest = true; | - | ||||||||||||
| 180 | } executed 29 times by 3 tests: end of blockExecuted by:
| 29 | ||||||||||||
| 181 | if (node == newest)
| 25-34 | ||||||||||||
| 182 | newest = node->older; executed 34 times by 3 tests: newest = node->older;Executed by:
| 34 | ||||||||||||
| 183 | if (node->older)
| 12-47 | ||||||||||||
| 184 | node->older->newer = node->newer; executed 12 times by 1 test: node->older->newer = node->newer;Executed by:
| 12 | ||||||||||||
| 185 | if (node->newer)
| 7-52 | ||||||||||||
| 186 | node->newer->older = node->older; executed 7 times by 1 test: node->newer->older = node->older;Executed by:
| 7 | ||||||||||||
| 187 | - | |||||||||||||
| 188 | node->newer = node->older = 0; | - | ||||||||||||
| 189 | return wasOldest; executed 59 times by 3 tests: return wasOldest;Executed by:
| 59 | ||||||||||||
| 190 | } | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | void QNetworkAccessCache::updateTimer() | - | ||||||||||||
| 193 | { | - | ||||||||||||
| 194 | timer.stop(); | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | if (!oldest)
| 28-607 | ||||||||||||
| 197 | return; executed 28 times by 2 tests: return;Executed by:
| 28 | ||||||||||||
| 198 | - | |||||||||||||
| 199 | int interval = QDateTime::currentDateTimeUtc().secsTo(oldest->timestamp); | - | ||||||||||||
| 200 | if (interval <= 0) {
| 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 blockExecuted by:
| 607 | ||||||||||||
| 206 | - | |||||||||||||
| 207 | timer.start(interval * 1000, this); | - | ||||||||||||
| 208 | } executed 607 times by 8 tests: end of blockExecuted by:
| 607 | ||||||||||||
| 209 | - | |||||||||||||
| 210 | bool QNetworkAccessCache::emitEntryReady(Node *node, QObject *target, const char *member) | - | ||||||||||||
| 211 | { | - | ||||||||||||
| 212 | if (!connect(this, SIGNAL(entryReady(QNetworkAccessCache::CacheableObject*)),
| 0-1 | ||||||||||||
| 213 | target, member, Qt::QueuedConnection))
| 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:
| 1 | ||||||||||||
| 220 | } | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | void QNetworkAccessCache::timerEvent(QTimerEvent *) | - | ||||||||||||
| 223 | { | - | ||||||||||||
| 224 | // expire old items | - | ||||||||||||
| 225 | const QDateTime now = QDateTime::currentDateTimeUtc(); | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | while (oldest && oldest->timestamp < now) {
| 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)
| 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 | - | |||||||||||||
| 244 | void QNetworkAccessCache::addEntry(const QByteArray &key, CacheableObject *entry) | - | ||||||||||||
| 245 | { | - | ||||||||||||
| 246 | Q_ASSERT(!key.isEmpty()); | - | ||||||||||||
| 247 | - | |||||||||||||
| 248 | if (unlinkEntry(key))
| 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)
| 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:
| 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:
| 9 | ||||||||||||
| 255 | if (node.object)
| 9-905 | ||||||||||||
| 256 | node.object->dispose(); executed 9 times by 1 test: node.object->dispose();Executed by:
| 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 blockExecuted by:
| 914 | ||||||||||||
| 262 | - | |||||||||||||
| 263 | bool QNetworkAccessCache::hasEntry(const QByteArray &key) const | - | ||||||||||||
| 264 | { | - | ||||||||||||
| 265 | return hash.contains(key); executed 997 times by 4 tests: return hash.contains(key);Executed by:
| 997 | ||||||||||||
| 266 | } | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | bool QNetworkAccessCache::requestEntry(const QByteArray &key, QObject *target, const char *member) | - | ||||||||||||
| 269 | { | - | ||||||||||||
| 270 | NodeHash::Iterator it = hash.find(key); | - | ||||||||||||
| 271 | if (it == hash.end())
| 1-48 | ||||||||||||
| 272 | return false; // no such entry executed 48 times by 1 test: return false;Executed by:
| 48 | ||||||||||||
| 273 | - | |||||||||||||
| 274 | Node *node = &it.value(); | - | ||||||||||||
| 275 | - | |||||||||||||
| 276 | if (node->useCount > 0 && !node->object->shareable) {
| 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:
| 1 | ||||||||||||
| 287 | } else { | - | ||||||||||||
| 288 | // node not in use or is shareable | - | ||||||||||||
| 289 | if (unlinkEntry(key))
| 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 | - | |||||||||||||
| 297 | QNetworkAccessCache::CacheableObject *QNetworkAccessCache::requestEntryNow(const QByteArray &key) | - | ||||||||||||
| 298 | { | - | ||||||||||||
| 299 | NodeHash::Iterator it = hash.find(key); | - | ||||||||||||
| 300 | if (it == hash.end())
| 551-718 | ||||||||||||
| 301 | return 0; executed 551 times by 8 tests: return 0;Executed by:
| 551 | ||||||||||||
| 302 | if (it->useCount > 0) {
| 41-677 | ||||||||||||
| 303 | if (it->object->shareable) {
| 0-677 | ||||||||||||
| 304 | ++it->useCount; | - | ||||||||||||
| 305 | return it->object; executed 677 times by 3 tests: return it->object;Executed by:
| 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)
| 12-29 | ||||||||||||
| 317 | updateTimer(); executed 29 times by 3 tests: updateTimer();Executed by:
| 29 | ||||||||||||
| 318 | return it->object; executed 41 times by 3 tests: return it->object;Executed by:
| 41 | ||||||||||||
| 319 | } | - | ||||||||||||
| 320 | - | |||||||||||||
| 321 | void QNetworkAccessCache::releaseEntry(const QByteArray &key) | - | ||||||||||||
| 322 | { | - | ||||||||||||
| 323 | NodeHash::Iterator it = hash.find(key); | - | ||||||||||||
| 324 | if (it == hash.end()) {
| 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()) {
| 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 blockExecuted by:
| 0-1 | ||||||||||||
| 340 | - | |||||||||||||
| 341 | if (!receiver.object.isNull()) {
| 0-1 | ||||||||||||
| 342 | emitEntryReady(node, receiver.object, receiver.member); | - | ||||||||||||
| 343 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||
| 344 | } | - | ||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||
| 346 | - | |||||||||||||
| 347 | if (!--node->useCount) {
| 628-675 | ||||||||||||
| 348 | // no objects waiting; add it back to the expiry list | - | ||||||||||||
| 349 | if (node->object->expires)
| 0-628 | ||||||||||||
| 350 | linkEntry(key); executed 628 times by 8 tests: linkEntry(key);Executed by:
| 628 | ||||||||||||
| 351 | - | |||||||||||||
| 352 | if (oldest == node)
| 22-606 | ||||||||||||
| 353 | updateTimer(); executed 606 times by 8 tests: updateTimer();Executed by:
| 606 | ||||||||||||
| 354 | } executed 628 times by 8 tests: end of blockExecuted by:
| 628 | ||||||||||||
| 355 | } executed 1303 times by 8 tests: end of blockExecuted by:
| 1303 | ||||||||||||
| 356 | - | |||||||||||||
| 357 | void QNetworkAccessCache::removeEntry(const QByteArray &key) | - | ||||||||||||
| 358 | { | - | ||||||||||||
| 359 | NodeHash::Iterator it = hash.find(key); | - | ||||||||||||
| 360 | if (it == hash.end()) {
| 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))
| 0-9 | ||||||||||||
| 368 | updateTimer(); never executed: updateTimer(); | 0 | ||||||||||||
| 369 | if (node->useCount > 1)
| 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 blockExecuted by:
| 9 | ||||||||||||
| 376 | - | |||||||||||||
| 377 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |