Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccessbackend.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | - | |||||||
7 | - | |||||||
8 | - | |||||||
9 | class QNetworkAccessBackendFactoryData: public QList<QNetworkAccessBackendFactory *> | - | ||||||
10 | { | - | ||||||
11 | public: | - | ||||||
12 | QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) | - | ||||||
13 | { | - | ||||||
14 | valid.ref(); | - | ||||||
15 | } executed 9 times by 9 tests: end of block Executed by:
| 9 | ||||||
16 | ~QNetworkAccessBackendFactoryData() | - | ||||||
17 | { | - | ||||||
18 | QMutexLocker locker(&mutex); | - | ||||||
19 | valid.deref(); | - | ||||||
20 | } executed 10 times by 10 tests: end of block Executed by:
| 10 | ||||||
21 | - | |||||||
22 | QMutex mutex; | - | ||||||
23 | - | |||||||
24 | static QBasicAtomicInt valid; | - | ||||||
25 | }; | - | ||||||
26 | namespace { namespace Q_QGS_factoryData { typedef QNetworkAccessBackendFactoryData Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
executed 10 times by 10 tests: }guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 10 times by 10 tests: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of block Executed by:
executed 438 times by 20 tests: &holder.value;return &holder.value; Executed by:
executed 438 times by 20 tests: } } } static QGlobalStatic<QNetworkAccessBackendFactoryData, Q_QGS_factoryData::innerFunction, Q_QGS_factoryData::guard> factoryData;return &holder.value; Executed by:
| 0-438 | ||||||
27 | QBasicAtomicInt QNetworkAccessBackendFactoryData::valid = { 0 }; | - | ||||||
28 | - | |||||||
29 | QNetworkAccessBackendFactory::QNetworkAccessBackendFactory() | - | ||||||
30 | { | - | ||||||
31 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||
32 | factoryData()->append(this); | - | ||||||
33 | } executed 27 times by 9 tests: end of block Executed by:
| 27 | ||||||
34 | - | |||||||
35 | QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() | - | ||||||
36 | { | - | ||||||
37 | if (QNetworkAccessBackendFactoryData::valid.load()
| 0-30 | ||||||
38 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||
39 | factoryData()->removeAll(this); | - | ||||||
40 | } executed 30 times by 10 tests: end of block Executed by:
| 30 | ||||||
41 | } executed 30 times by 10 tests: end of block Executed by:
| 30 | ||||||
42 | - | |||||||
43 | QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessManager::Operation op, | - | ||||||
44 | const QNetworkRequest &request) | - | ||||||
45 | { | - | ||||||
46 | if (QNetworkAccessBackendFactoryData::valid.load()
| 0-108 | ||||||
47 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||
48 | QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(), | - | ||||||
49 | end = factoryData()->constEnd(); | - | ||||||
50 | while (it != end
| 4-209 | ||||||
51 | QNetworkAccessBackend *backend = (*it)->create(op, request); | - | ||||||
52 | if (backend
| 104-105 | ||||||
53 | backend->manager = this; | - | ||||||
54 | return executed 104 times by 1 test: backend;return backend; Executed by:
executed 104 times by 1 test: return backend; Executed by:
| 104 | ||||||
55 | } | - | ||||||
56 | ++it; | - | ||||||
57 | } executed 105 times by 1 test: end of block Executed by:
| 105 | ||||||
58 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
59 | return executed 4 times by 1 test: 0;return 0; Executed by:
executed 4 times by 1 test: return 0; Executed by:
| 4 | ||||||
60 | } | - | ||||||
61 | - | |||||||
62 | QStringList QNetworkAccessManagerPrivate::backendSupportedSchemes() const | - | ||||||
63 | { | - | ||||||
64 | if (QNetworkAccessBackendFactoryData::valid.load()
| 0 | ||||||
65 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||
66 | QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(); | - | ||||||
67 | QNetworkAccessBackendFactoryData::ConstIterator end = factoryData()->constEnd(); | - | ||||||
68 | QStringList schemes; | - | ||||||
69 | while (it != end
| 0 | ||||||
70 | schemes += (*it)->supportedSchemes(); | - | ||||||
71 | ++it; | - | ||||||
72 | } never executed: end of block | 0 | ||||||
73 | return never executed: schemes;return schemes; never executed: return schemes; | 0 | ||||||
74 | } | - | ||||||
75 | return never executed: QStringList();return QStringList(); never executed: return QStringList(); | 0 | ||||||
76 | } | - | ||||||
77 | - | |||||||
78 | QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice() | - | ||||||
79 | { | - | ||||||
80 | if (reply->outgoingDataBuffer
| 0-59 | ||||||
81 | uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingDataBuffer); never executed: uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingDataBuffer); | 0 | ||||||
82 | else if (reply->outgoingData
| 0-59 | ||||||
83 | uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingData); | - | ||||||
84 | } executed 59 times by 1 test: else {end of block Executed by:
| 59 | ||||||
85 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
86 | } | - | ||||||
87 | - | |||||||
88 | - | |||||||
89 | if (!isSynchronous()
| 0-59 | ||||||
90 | connect(uploadByteDevice.data(), qFlagLocation("2""readProgress(qint64,qint64)" "\0" __FILE__ ":" "133"), this, qFlagLocation("1""emitReplyUploadProgress(qint64,qint64)" "\0" __FILE__ ":" "133")); executed 59 times by 1 test: connect(uploadByteDevice.data(), qFlagLocation("2""readProgress(qint64,qint64)" "\0" __FILE__ ":" "133"), this, qFlagLocation("1""emitReplyUploadProgress(qint64,qint64)" "\0" __FILE__ ":" "133")); Executed by:
| 59 | ||||||
91 | - | |||||||
92 | return executed 59 times by 1 test: uploadByteDevice.data();return uploadByteDevice.data(); Executed by:
executed 59 times by 1 test: return uploadByteDevice.data(); Executed by:
| 59 | ||||||
93 | } | - | ||||||
94 | - | |||||||
95 | - | |||||||
96 | - | |||||||
97 | void QNetworkAccessBackend::emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal) | - | ||||||
98 | { | - | ||||||
99 | if (reply->isFinished
| 0-1053 | ||||||
100 | return; never executed: return; | 0 | ||||||
101 | reply->emitUploadProgress(bytesSent, bytesTotal); | - | ||||||
102 | } executed 1053 times by 1 test: end of block Executed by:
| 1053 | ||||||
103 | - | |||||||
104 | QNetworkAccessBackend::QNetworkAccessBackend() | - | ||||||
105 | : manager(0) | - | ||||||
106 | , reply(0) | - | ||||||
107 | , synchronous(false) | - | ||||||
108 | { | - | ||||||
109 | } executed 118 times by 3 tests: end of block Executed by:
| 118 | ||||||
110 | - | |||||||
111 | QNetworkAccessBackend::~QNetworkAccessBackend() | - | ||||||
112 | { | - | ||||||
113 | } | - | ||||||
114 | - | |||||||
115 | void QNetworkAccessBackend::downstreamReadyWrite() | - | ||||||
116 | { | - | ||||||
117 | - | |||||||
118 | } | - | ||||||
119 | - | |||||||
120 | void QNetworkAccessBackend::setDownstreamLimited(bool b) | - | ||||||
121 | { | - | ||||||
122 | (void)b;; | - | ||||||
123 | - | |||||||
124 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
125 | - | |||||||
126 | void QNetworkAccessBackend::copyFinished(QIODevice *) | - | ||||||
127 | { | - | ||||||
128 | - | |||||||
129 | } | - | ||||||
130 | - | |||||||
131 | void QNetworkAccessBackend::ignoreSslErrors() | - | ||||||
132 | { | - | ||||||
133 | - | |||||||
134 | } | - | ||||||
135 | - | |||||||
136 | void QNetworkAccessBackend::ignoreSslErrors(const QList<QSslError> &errors) | - | ||||||
137 | { | - | ||||||
138 | (void)errors;; | - | ||||||
139 | - | |||||||
140 | } never executed: end of block | 0 | ||||||
141 | - | |||||||
142 | void QNetworkAccessBackend::fetchSslConfiguration(QSslConfiguration &) const | - | ||||||
143 | { | - | ||||||
144 | - | |||||||
145 | } | - | ||||||
146 | - | |||||||
147 | void QNetworkAccessBackend::setSslConfiguration(const QSslConfiguration &) | - | ||||||
148 | { | - | ||||||
149 | - | |||||||
150 | } | - | ||||||
151 | - | |||||||
152 | QNetworkCacheMetaData QNetworkAccessBackend::fetchCacheMetaData(const QNetworkCacheMetaData &) const | - | ||||||
153 | { | - | ||||||
154 | return never executed: QNetworkCacheMetaData();return QNetworkCacheMetaData(); never executed: return QNetworkCacheMetaData(); | 0 | ||||||
155 | } | - | ||||||
156 | - | |||||||
157 | QNetworkAccessManager::Operation QNetworkAccessBackend::operation() const | - | ||||||
158 | { | - | ||||||
159 | return executed 462 times by 2 tests: reply->operation;return reply->operation; Executed by:
executed 462 times by 2 tests: return reply->operation; Executed by:
| 462 | ||||||
160 | } | - | ||||||
161 | - | |||||||
162 | QNetworkRequest QNetworkAccessBackend::request() const | - | ||||||
163 | { | - | ||||||
164 | return executed 125 times by 2 tests: reply->request;return reply->request; Executed by:
executed 125 times by 2 tests: return reply->request; Executed by:
| 125 | ||||||
165 | } | - | ||||||
166 | - | |||||||
167 | - | |||||||
168 | QList<QNetworkProxy> QNetworkAccessBackend::proxyList() const | - | ||||||
169 | { | - | ||||||
170 | return executed 53 times by 1 test: reply->proxyList;return reply->proxyList; Executed by:
executed 53 times by 1 test: return reply->proxyList; Executed by:
| 53 | ||||||
171 | } | - | ||||||
172 | - | |||||||
173 | - | |||||||
174 | QAbstractNetworkCache *QNetworkAccessBackend::networkCache() const | - | ||||||
175 | { | - | ||||||
176 | if (!manager
| 0-43 | ||||||
177 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
178 | return executed 43 times by 2 tests: manager->networkCache;return manager->networkCache; Executed by:
executed 43 times by 2 tests: return manager->networkCache; Executed by:
| 43 | ||||||
179 | } | - | ||||||
180 | - | |||||||
181 | void QNetworkAccessBackend::setCachingEnabled(bool enable) | - | ||||||
182 | { | - | ||||||
183 | reply->setCachingEnabled(enable); | - | ||||||
184 | } executed 43 times by 2 tests: end of block Executed by:
| 43 | ||||||
185 | - | |||||||
186 | bool QNetworkAccessBackend::isCachingEnabled() const | - | ||||||
187 | { | - | ||||||
188 | return never executed: reply->isCachingEnabled();return reply->isCachingEnabled(); never executed: return reply->isCachingEnabled(); | 0 | ||||||
189 | } | - | ||||||
190 | - | |||||||
191 | qint64 QNetworkAccessBackend::nextDownstreamBlockSize() const | - | ||||||
192 | { | - | ||||||
193 | return executed 38 times by 1 test: reply->nextDownstreamBlockSize();return reply->nextDownstreamBlockSize(); Executed by:
executed 38 times by 1 test: return reply->nextDownstreamBlockSize(); Executed by:
| 38 | ||||||
194 | } | - | ||||||
195 | - | |||||||
196 | void QNetworkAccessBackend::writeDownstreamData(QByteDataBuffer &list) | - | ||||||
197 | { | - | ||||||
198 | reply->appendDownstreamData(list); | - | ||||||
199 | } executed 602 times by 1 test: end of block Executed by:
| 602 | ||||||
200 | - | |||||||
201 | void QNetworkAccessBackend::writeDownstreamData(QIODevice *data) | - | ||||||
202 | { | - | ||||||
203 | reply->appendDownstreamData(data); | - | ||||||
204 | } executed 9 times by 2 tests: end of block Executed by:
| 9 | ||||||
205 | - | |||||||
206 | - | |||||||
207 | void QNetworkAccessBackend::writeDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal) | - | ||||||
208 | { | - | ||||||
209 | reply->appendDownstreamDataDownloadBuffer(bytesReceived, bytesTotal); | - | ||||||
210 | } never executed: end of block | 0 | ||||||
211 | - | |||||||
212 | char* QNetworkAccessBackend::getDownloadBuffer(qint64 size) | - | ||||||
213 | { | - | ||||||
214 | return never executed: reply->getDownloadBuffer(size);return reply->getDownloadBuffer(size); never executed: return reply->getDownloadBuffer(size); | 0 | ||||||
215 | } | - | ||||||
216 | - | |||||||
217 | QVariant QNetworkAccessBackend::header(QNetworkRequest::KnownHeaders header) const | - | ||||||
218 | { | - | ||||||
219 | return never executed: reply->q_func()->header(header);return reply->q_func()->header(header); never executed: return reply->q_func()->header(header); | 0 | ||||||
220 | } | - | ||||||
221 | - | |||||||
222 | void QNetworkAccessBackend::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value) | - | ||||||
223 | { | - | ||||||
224 | reply->setCookedHeader(header, value); | - | ||||||
225 | } executed 69 times by 1 test: end of block Executed by:
| 69 | ||||||
226 | - | |||||||
227 | bool QNetworkAccessBackend::hasRawHeader(const QByteArray &headerName) const | - | ||||||
228 | { | - | ||||||
229 | return never executed: reply->q_func()->hasRawHeader(headerName);return reply->q_func()->hasRawHeader(headerName); never executed: return reply->q_func()->hasRawHeader(headerName); | 0 | ||||||
230 | } | - | ||||||
231 | - | |||||||
232 | QByteArray QNetworkAccessBackend::rawHeader(const QByteArray &headerName) const | - | ||||||
233 | { | - | ||||||
234 | return never executed: reply->q_func()->rawHeader(headerName);return reply->q_func()->rawHeader(headerName); never executed: return reply->q_func()->rawHeader(headerName); | 0 | ||||||
235 | } | - | ||||||
236 | - | |||||||
237 | QList<QByteArray> QNetworkAccessBackend::rawHeaderList() const | - | ||||||
238 | { | - | ||||||
239 | return never executed: reply->q_func()->rawHeaderList();return reply->q_func()->rawHeaderList(); never executed: return reply->q_func()->rawHeaderList(); | 0 | ||||||
240 | } | - | ||||||
241 | - | |||||||
242 | void QNetworkAccessBackend::setRawHeader(const QByteArray &headerName, const QByteArray &headerValue) | - | ||||||
243 | { | - | ||||||
244 | reply->setRawHeader(headerName, headerValue); | - | ||||||
245 | } executed 36 times by 2 tests: end of block Executed by:
| 36 | ||||||
246 | - | |||||||
247 | QVariant QNetworkAccessBackend::attribute(QNetworkRequest::Attribute code) const | - | ||||||
248 | { | - | ||||||
249 | return never executed: reply->q_func()->attribute(code);return reply->q_func()->attribute(code); never executed: return reply->q_func()->attribute(code); | 0 | ||||||
250 | } | - | ||||||
251 | - | |||||||
252 | void QNetworkAccessBackend::setAttribute(QNetworkRequest::Attribute code, const QVariant &value) | - | ||||||
253 | { | - | ||||||
254 | if (value.isValid()
| 8-25 | ||||||
255 | reply->attributes.insert(code, value); executed 25 times by 2 tests: reply->attributes.insert(code, value); Executed by:
| 25 | ||||||
256 | else | - | ||||||
257 | reply->attributes.remove(code); executed 8 times by 1 test: reply->attributes.remove(code); Executed by:
| 8 | ||||||
258 | } | - | ||||||
259 | QUrl QNetworkAccessBackend::url() const | - | ||||||
260 | { | - | ||||||
261 | return executed 425 times by 2 tests: reply->url;return reply->url; Executed by:
executed 425 times by 2 tests: return reply->url; Executed by:
| 425 | ||||||
262 | } | - | ||||||
263 | - | |||||||
264 | void QNetworkAccessBackend::setUrl(const QUrl &url) | - | ||||||
265 | { | - | ||||||
266 | reply->url = url; | - | ||||||
267 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
268 | - | |||||||
269 | void QNetworkAccessBackend::finished() | - | ||||||
270 | { | - | ||||||
271 | reply->finished(); | - | ||||||
272 | } executed 114 times by 2 tests: end of block Executed by:
| 114 | ||||||
273 | - | |||||||
274 | void QNetworkAccessBackend::error(QNetworkReply::NetworkError code, const QString &errorString) | - | ||||||
275 | { | - | ||||||
276 | reply->error(code, errorString); | - | ||||||
277 | } executed 17 times by 2 tests: end of block Executed by:
| 17 | ||||||
278 | - | |||||||
279 | - | |||||||
280 | void QNetworkAccessBackend::proxyAuthenticationRequired(const QNetworkProxy &proxy, | - | ||||||
281 | QAuthenticator *authenticator) | - | ||||||
282 | { | - | ||||||
283 | manager->proxyAuthenticationRequired(QUrl(), proxy, synchronous, authenticator, &reply->lastProxyAuthentication); | - | ||||||
284 | } never executed: end of block | 0 | ||||||
285 | - | |||||||
286 | - | |||||||
287 | void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator) | - | ||||||
288 | { | - | ||||||
289 | manager->authenticationRequired(authenticator, reply->q_func(), synchronous, reply->url, &reply->urlForLastAuthentication); | - | ||||||
290 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||
291 | - | |||||||
292 | void QNetworkAccessBackend::metaDataChanged() | - | ||||||
293 | { | - | ||||||
294 | reply->metaDataChanged(); | - | ||||||
295 | } executed 54 times by 2 tests: end of block Executed by:
| 54 | ||||||
296 | - | |||||||
297 | void QNetworkAccessBackend::redirectionRequested(const QUrl &target) | - | ||||||
298 | { | - | ||||||
299 | reply->redirectionRequested(target); | - | ||||||
300 | } never executed: end of block | 0 | ||||||
301 | - | |||||||
302 | void QNetworkAccessBackend::encrypted() | - | ||||||
303 | { | - | ||||||
304 | - | |||||||
305 | reply->encrypted(); | - | ||||||
306 | - | |||||||
307 | } never executed: end of block | 0 | ||||||
308 | - | |||||||
309 | void QNetworkAccessBackend::sslErrors(const QList<QSslError> &errors) | - | ||||||
310 | { | - | ||||||
311 | - | |||||||
312 | reply->sslErrors(errors); | - | ||||||
313 | - | |||||||
314 | - | |||||||
315 | - | |||||||
316 | } never executed: end of block | 0 | ||||||
317 | - | |||||||
318 | - | |||||||
319 | - | |||||||
320 | - | |||||||
321 | - | |||||||
322 | - | |||||||
323 | bool QNetworkAccessBackend::start() | - | ||||||
324 | { | - | ||||||
325 | - | |||||||
326 | - | |||||||
327 | QSharedPointer<QNetworkSession> networkSession(manager->getNetworkSession()); | - | ||||||
328 | if (networkSession
| 0-119 | ||||||
329 | - | |||||||
330 | if (networkSession->isOpen()
| 3-116 | ||||||
331 | networkSession->state() == QNetworkSession::Connected
| 0-116 | ||||||
332 | - | |||||||
333 | - | |||||||
334 | setProperty("_q_networksession", QVariant::fromValue(networkSession)); | - | ||||||
335 | } executed 116 times by 2 tests: else {end of block Executed by:
| 116 | ||||||
336 | - | |||||||
337 | - | |||||||
338 | - | |||||||
339 | const QString host = reply->url.host(); | - | ||||||
340 | - | |||||||
341 | if (host == QLatin1String("localhost")
| 0-3 | ||||||
342 | QHostAddress(host).isLoopback()
| 0-3 | ||||||
343 | reply->url.isLocalFile()
| 0-3 | ||||||
344 | - | |||||||
345 | } never executed: else {end of block | 0 | ||||||
346 | - | |||||||
347 | return executed 3 times by 1 test: false;return false; Executed by:
executed 3 times by 1 test: return false; Executed by:
| 3 | ||||||
348 | } | - | ||||||
349 | } | - | ||||||
350 | } | - | ||||||
351 | - | |||||||
352 | - | |||||||
353 | - | |||||||
354 | - | |||||||
355 | - | |||||||
356 | - | |||||||
357 | QNetworkSession *session = networkSession.data(); | - | ||||||
358 | QNetworkConfiguration config; | - | ||||||
359 | if (session
| 0-116 | ||||||
360 | QNetworkConfigurationManager configManager; | - | ||||||
361 | - | |||||||
362 | QVariant v = session->sessionProperty(QLatin1String("ActiveConfiguration")); | - | ||||||
363 | if (v.isValid()
| 0-116 | ||||||
364 | config = configManager.configurationFromIdentifier(qvariant_cast<QString>(v)); executed 116 times by 2 tests: config = configManager.configurationFromIdentifier(qvariant_cast<QString>(v)); Executed by:
| 116 | ||||||
365 | - | |||||||
366 | if (!config.isValid()
| 0-116 | ||||||
367 | config = session->configuration(); never executed: config = session->configuration(); | 0 | ||||||
368 | - | |||||||
369 | if (!config.isValid()
| 0-116 | ||||||
370 | config = QNetworkConfiguration(); never executed: config = QNetworkConfiguration(); | 0 | ||||||
371 | } executed 116 times by 2 tests: end of block Executed by:
| 116 | ||||||
372 | reply->proxyList = manager->queryProxy(QNetworkProxyQuery(config, url())); | - | ||||||
373 | - | |||||||
374 | - | |||||||
375 | - | |||||||
376 | - | |||||||
377 | - | |||||||
378 | - | |||||||
379 | - | |||||||
380 | open(); | - | ||||||
381 | return executed 116 times by 2 tests: true;return true; Executed by:
executed 116 times by 2 tests: return true; Executed by:
| 116 | ||||||
382 | } | - | ||||||
383 | - | |||||||
384 | - | |||||||
Switch to Source code | Preprocessed file |