aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/urlinterceptor.cpp17
-rw-r--r--src/webengine/urlinterceptor.h4
2 files changed, 5 insertions, 16 deletions
diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp
index 815018b..4fc23e0 100644
--- a/src/webengine/urlinterceptor.cpp
+++ b/src/webengine/urlinterceptor.cpp
@@ -9,7 +9,6 @@
#include "urlinterceptor.h"
#include <QDir>
#include <QTextStream>
-#include <QtConcurrent>
UrlRequestInterceptor::UrlRequestInterceptor(const QString &path, QObject *parent)
: QWebEngineUrlRequestInterceptor(parent)
@@ -18,28 +17,20 @@ UrlRequestInterceptor::UrlRequestInterceptor(const QString &path, QObject *paren
const QStringList hostFiles = hostsD.entryList(QDir::Files);
for(const QString &file : hostFiles) {
const QString absPath = hostsD.absoluteFilePath(file);
- QtConcurrent::run([this, absPath]() {
- auto r = parse(absPath);
+ auto r = parse(absPath);
#ifdef QT_DEBUG
- qDebug("Parsed %i rules from %s", r.count(), qUtf8Printable(absPath));
+ qDebug("Parsed %i rules from %s", r.count(), qUtf8Printable(absPath));
#endif
- rulesLock.lock();
- rules.unite(r);
- rulesLock.unlock();
- });
+ rules.unite(r);
}
}
-UrlRequestInterceptor::~UrlRequestInterceptor() = default;
-
void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
- rulesLock.lock();
if(rules.contains(info.requestUrl().host())) {
info.block(rules.value(info.requestUrl().host()).isBlocking);
}
- rulesLock.unlock();
}
QHash<QString, UrlRequestInterceptor::HostRule> parse(const QString &filename)
@@ -88,4 +79,4 @@ QHash<QString, UrlRequestInterceptor::HostRule> parse(const QString &filename)
}
return rules;
-};
+}
diff --git a/src/webengine/urlinterceptor.h b/src/webengine/urlinterceptor.h
index 951eb52..2a5c50d 100644
--- a/src/webengine/urlinterceptor.h
+++ b/src/webengine/urlinterceptor.h
@@ -9,7 +9,6 @@
#ifndef URLREQUESTINTERCEPTOR_H
#define URLREQUESTINTERCEPTOR_H
-#include <QMutex>
#include <QWebEngineUrlRequestInterceptor>
class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
@@ -21,13 +20,12 @@ public:
};
explicit UrlRequestInterceptor(const QString &path, QObject *parent = nullptr);
- ~UrlRequestInterceptor() override;
+ ~UrlRequestInterceptor() = default;
void interceptRequest(QWebEngineUrlRequestInfo &info) override;
private:
QHash<QString, HostRule> rules;
- QMutex rulesLock;
};
QHash<QString, UrlRequestInterceptor::HostRule> parse(const QString &filename);