mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +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 <QDebug>
|
||||
|
||||
//#define ADBLOCK_DEBUG
|
||||
|
||||
#ifdef ADBLOCK_DEBUG
|
||||
#include <QElapsedTimer>
|
||||
#endif
|
||||
|
||||
AdBlockManager* AdBlockManager::s_adBlockManager = 0;
|
||||
|
||||
AdBlockManager::AdBlockManager(QObject* parent)
|
||||
@ -75,6 +81,10 @@ QList<AdBlockSubscription*> AdBlockManager::subscriptions() const
|
||||
|
||||
QNetworkReply* AdBlockManager::block(const QNetworkRequest &request)
|
||||
{
|
||||
#ifdef ADBLOCK_DEBUG
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
#endif
|
||||
const QString &urlString = request.url().toEncoded();
|
||||
const QString &urlDomain = request.url().host();
|
||||
const QString &urlScheme = request.url().scheme();
|
||||
@ -100,10 +110,18 @@ QNetworkReply* AdBlockManager::block(const QNetworkRequest &request)
|
||||
AdBlockBlockedNetworkReply* reply = new AdBlockBlockedNetworkReply(subscription, blockedRule, this);
|
||||
reply->setRequest(request);
|
||||
|
||||
#ifdef ADBLOCK_DEBUG
|
||||
qDebug() << "BLOCKED: " << timer.elapsed() << blockedRule->filter() << request.url();
|
||||
#endif
|
||||
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ADBLOCK_DEBUG
|
||||
qDebug() << timer.elapsed() << request.url();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -184,6 +202,11 @@ void AdBlockManager::load()
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ADBLOCK_DEBUG
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
#endif
|
||||
|
||||
Settings settings;
|
||||
settings.beginGroup("AdBlock");
|
||||
m_enabled = settings.value("enabled", m_enabled).toBool();
|
||||
@ -249,6 +272,10 @@ void AdBlockManager::load()
|
||||
QTimer::singleShot(1000 * 60, this, SLOT(updateAllSubscriptions()));
|
||||
}
|
||||
|
||||
#ifdef ADBLOCK_DEBUG
|
||||
qDebug() << "AdBlock loaded in" << timer.elapsed();
|
||||
#endif
|
||||
|
||||
m_loaded = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user