aboutsummaryrefslogtreecommitdiff
path: root/launcher/net/Sink.h
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-04-27 18:36:11 -0300
committerflow <thiagodonato300@gmail.com>2022-05-12 18:11:55 -0300
commit040ee919e5ea71364daa08c30e09c843976f5734 (patch)
treec65db37c7aa199592135020d3114aa808415764c /launcher/net/Sink.h
parentefa3fbff39bf0dabebdf1c6330090ee320895a4d (diff)
downloadPrismLauncher-040ee919e5ea71364daa08c30e09c843976f5734.tar.gz
PrismLauncher-040ee919e5ea71364daa08c30e09c843976f5734.tar.bz2
PrismLauncher-040ee919e5ea71364daa08c30e09c843976f5734.zip
refactor: more net cleanup
This runs clang-tidy on some other files in launcher/net/. This also makes use of some JSON wrappers in HttpMetaCache, instead of using the Qt stuff directly. Lastly, this removes useless null checks (crashes don't occur because of this, but because of concurrent usage / free of the QByteArray pointer), and fix a fixme in Download.h
Diffstat (limited to 'launcher/net/Sink.h')
-rw-r--r--launcher/net/Sink.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/launcher/net/Sink.h b/launcher/net/Sink.h
index 3b2a7f8d..c8800220 100644
--- a/launcher/net/Sink.h
+++ b/launcher/net/Sink.h
@@ -8,14 +8,15 @@ namespace Net {
class Sink {
public:
Sink() = default;
- virtual ~Sink(){};
+ virtual ~Sink() = default;
public:
- virtual Task::State init(QNetworkRequest& request) = 0;
- virtual Task::State write(QByteArray& data) = 0;
- virtual Task::State abort() = 0;
- virtual Task::State finalize(QNetworkReply& reply) = 0;
- virtual bool hasLocalData() = 0;
+ virtual auto init(QNetworkRequest& request) -> Task::State = 0;
+ virtual auto write(QByteArray& data) -> Task::State = 0;
+ virtual auto abort() -> Task::State = 0;
+ virtual auto finalize(QNetworkReply& reply) -> Task::State = 0;
+
+ virtual auto hasLocalData() -> bool = 0;
void addValidator(Validator* validator)
{
@@ -24,7 +25,15 @@ class Sink {
}
}
- protected: /* methods */
+ protected:
+ bool initAllValidators(QNetworkRequest& request)
+ {
+ for (auto& validator : validators) {
+ if (!validator->init(request))
+ return false;
+ }
+ return true;
+ }
bool finalizeAllValidators(QNetworkReply& reply)
{
for (auto& validator : validators) {
@@ -41,14 +50,6 @@ class Sink {
}
return success;
}
- bool initAllValidators(QNetworkRequest& request)
- {
- for (auto& validator : validators) {
- if (!validator->init(request))
- return false;
- }
- return true;
- }
bool writeAllValidators(QByteArray& data)
{
for (auto& validator : validators) {
@@ -58,7 +59,7 @@ class Sink {
return true;
}
- protected: /* data */
+ protected:
std::vector<std::shared_ptr<Validator>> validators;
};
} // namespace Net