Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnetworkreplywasmimpl_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QNETWORKREPLYWASMIMPL_H
5#define QNETWORKREPLYWASMIMPL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the Network Access API. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qnetworkreply.h"
19#include "qnetworkreply_p.h"
21
22#include <QtCore/qfile.h>
23
24#include <private/qtnetworkglobal_p.h>
25#include <private/qabstractfileengine_p.h>
26
27#include <emscripten.h>
28#include <emscripten/fetch.h>
29
30#include <memory>
31#include <mutex>
32
34
35class QIODevice;
36
39{
41public:
44 virtual void abort() override;
45
46 // reimplemented from QNetworkReply
47 virtual void close() override;
48 virtual qint64 bytesAvailable() const override;
49 virtual bool isSequential () const override;
50 qint64 size() const override;
51
52 virtual qint64 readData(char *data, qint64 maxlen) override;
53
55 QIODevice *outgoingData);
56
57 Q_DECLARE_PRIVATE(QNetworkReplyWasmImpl)
58
59 Q_PRIVATE_SLOT(d_func(), void emitReplyError(QNetworkReply::NetworkError errorCode, const QString &errorString))
61 Q_PRIVATE_SLOT(d_func(), void dataReceived(const QByteArray &buffer))
62
64 QByteArray methodName() const;
65};
66
68
79{
80 enum class State { SCHEDULED, SENT, FINISHED, CANCELED, TO_BE_DESTROYED };
81
82 FetchContext(QNetworkReplyWasmImplPrivate *networkReply) : reply(networkReply) { }
83
85 std::mutex mutex;
87 State state{ State::SCHEDULED };
88};
89
91{
92public:
95
97 void doSendRequest();
98 static void setReplyAttributes(quintptr data, int statusCode, const QString &statusReason);
99
100 void emitReplyError(QNetworkReply::NetworkError errorCode, const QString &);
101 void emitDataReadProgress(qint64 done, qint64 total);
102 void dataReceived(const QByteArray &buffer);
103 void headersReceived(const QByteArray &buffer);
104
105 void setStatusCode(int status, const QByteArray &statusText);
106
108 QIODevice *outgoingData);
109
111 void _q_bufferOutgoingData();
112 void _q_bufferOutgoingDataFinished();
113
114 std::shared_ptr<QAtomicInt> pendingDownloadData;
115 std::shared_ptr<QAtomicInt> pendingDownloadProgress;
116
119
125
127 std::shared_ptr<QRingBuffer> outgoingDataBuffer;
128
129 static void downloadProgress(emscripten_fetch_t *fetch);
130 static void downloadFailed(emscripten_fetch_t *fetch);
131 static void downloadSucceeded(emscripten_fetch_t *fetch);
132 static void stateChange(emscripten_fetch_t *fetch);
133
134 static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url);
135
136 emscripten_fetch_t *m_fetch;
138 void setReplyFinished();
139 void setCanceled();
140
141 Q_DECLARE_PUBLIC(QNetworkReplyWasmImpl)
142};
143
145
146#endif // QNETWORKREPLYWASMIMPL_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore \reentrant
Definition qiodevice.h:34
QString errorString() const
Returns a human-readable description of the last device error that occurred.
Operation
Indicates the operation this reply is processing.
std::shared_ptr< QRingBuffer > outgoingDataBuffer
std::shared_ptr< QAtomicInt > pendingDownloadData
std::shared_ptr< QAtomicInt > pendingDownloadProgress
QNetworkAccessManagerPrivate * managerPrivate
qint64 size() const override
For open random-access devices, this function returns the size of the device.
virtual qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
void emitDataReadProgress(qint64 done, qint64 total)) Q_PRIVATE_SLOT(d_func()
virtual void abort() override
Aborts the operation immediately and close down any network connections still open.
void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
virtual bool isSequential() const override
QNetworkReplyWasmImpl(QObject *parent=nullptr)
virtual void close() override
Closes this device for reading.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
NetworkError
Indicates all possible error conditions found during the processing of the request.
QNetworkRequest request() const
Returns the request that was posted for this reply.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
else opt state
[0]
Combined button and popup list for selecting options.
static QString methodName(const QDBusIntrospection::Method &method)
static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint buffer
#define Q_OBJECT
#define Q_PRIVATE_SLOT(d, signature)
size_t quintptr
Definition qtypes.h:167
long long qint64
Definition qtypes.h:60
QUrl url("example.com")
[constructor-url-reference]
QByteArray readData()
QNetworkRequest request(url)
QNetworkReply * reply
The FetchContext class ensures the requestData object remains valid while a fetch operation is pendin...
FetchContext(QNetworkReplyWasmImplPrivate *networkReply)