mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[AdBlock] Added debug output with ADBLOCK_DEBUG define.
It will print the time needed to load all rules and also to block each url.
This commit is contained in:
parent
cf4daaa37a
commit
a25e189904
@ -32,6 +32,12 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
//#define ADBLOCK_DEBUG
|
||||||
|
|
||||||
|
#ifdef ADBLOCK_DEBUG
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
#endif
|
||||||
|
|
||||||
AdBlockManager* AdBlockManager::s_adBlockManager = 0;
|
AdBlockManager* AdBlockManager::s_adBlockManager = 0;
|
||||||
|
|
||||||
AdBlockManager::AdBlockManager(QObject* parent)
|
AdBlockManager::AdBlockManager(QObject* parent)
|
||||||
@ -75,6 +81,10 @@ QList<AdBlockSubscription*> AdBlockManager::subscriptions() const
|
|||||||
|
|
||||||
QNetworkReply* AdBlockManager::block(const QNetworkRequest &request)
|
QNetworkReply* AdBlockManager::block(const QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
|
#ifdef ADBLOCK_DEBUG
|
||||||
|
QElapsedTimer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
const QString &urlString = request.url().toEncoded();
|
const QString &urlString = request.url().toEncoded();
|
||||||
const QString &urlDomain = request.url().host();
|
const QString &urlDomain = request.url().host();
|
||||||
const QString &urlScheme = request.url().scheme();
|
const QString &urlScheme = request.url().scheme();
|
||||||
@ -100,10 +110,18 @@ QNetworkReply* AdBlockManager::block(const QNetworkRequest &request)
|
|||||||
AdBlockBlockedNetworkReply* reply = new AdBlockBlockedNetworkReply(subscription, blockedRule, this);
|
AdBlockBlockedNetworkReply* reply = new AdBlockBlockedNetworkReply(subscription, blockedRule, this);
|
||||||
reply->setRequest(request);
|
reply->setRequest(request);
|
||||||
|
|
||||||
|
#ifdef ADBLOCK_DEBUG
|
||||||
|
qDebug() << "BLOCKED: " << timer.elapsed() << blockedRule->filter() << request.url();
|
||||||
|
#endif
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADBLOCK_DEBUG
|
||||||
|
qDebug() << timer.elapsed() << request.url();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +202,11 @@ void AdBlockManager::load()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADBLOCK_DEBUG
|
||||||
|
QElapsedTimer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("AdBlock");
|
settings.beginGroup("AdBlock");
|
||||||
m_enabled = settings.value("enabled", m_enabled).toBool();
|
m_enabled = settings.value("enabled", m_enabled).toBool();
|
||||||
@ -249,6 +272,10 @@ void AdBlockManager::load()
|
|||||||
QTimer::singleShot(1000 * 60, this, SLOT(updateAllSubscriptions()));
|
QTimer::singleShot(1000 * 60, this, SLOT(updateAllSubscriptions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADBLOCK_DEBUG
|
||||||
|
qDebug() << "AdBlock loaded in" << timer.elapsed();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user