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