tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit efc509c727b2b23d58a8d2244f263515887d0e86
parent d74d54cb383709071f19f988c53966f486e8b6df
Author: Markus Stange <mstange.moz@gmail.com>
Date:   Tue, 11 Nov 2025 04:09:07 +0000

Bug 1956923 - Warm up URL classifier earlier. r=valentin,geckoview-reviewers,ohall

In the past we were opening the URL classifier DB on demand when
we made the first network request. This delays the first network
request slightly. Warming it up earlier will let the first request
go out sooner.

Differential Revision: https://phabricator.services.mozilla.com/D272041

Diffstat:
Mnetwerk/url-classifier/AsyncUrlChannelClassifier.cpp | 8++++++++
Mnetwerk/url-classifier/AsyncUrlChannelClassifier.h | 3+++
Mwidget/android/nsWindow.cpp | 3+++
3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp b/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp @@ -858,6 +858,14 @@ nsresult FeatureData::InitializeList( } // namespace /* static */ +void AsyncUrlChannelClassifier::WarmUp() { + // Trigger the construction of the singleton instance. + nsresult rv; + RefPtr<nsUrlClassifierDBService> service = + nsUrlClassifierDBService::GetInstance(&rv); +} + +/* static */ nsresult AsyncUrlChannelClassifier::CheckChannel( nsIChannel* aChannel, std::function<void()>&& aCallback) { MOZ_ASSERT(XRE_IsParentProcess()); diff --git a/netwerk/url-classifier/AsyncUrlChannelClassifier.h b/netwerk/url-classifier/AsyncUrlChannelClassifier.h @@ -17,6 +17,9 @@ namespace net { class AsyncUrlChannelClassifier final { public: + // Warm up the classifier, i.e. launch the classifier thread and load the DB. + static void WarmUp(); + static nsresult CheckChannel(nsIChannel* aChannel, std::function<void()>&& aCallback); }; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp @@ -103,6 +103,7 @@ #include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/UiCompositorControllerChild.h" #include "mozilla/layers/IAPZCTreeManager.h" +#include "mozilla/net/AsyncUrlChannelClassifier.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/widget/AndroidVsync.h" #include "mozilla/widget/Screen.h" @@ -1809,6 +1810,8 @@ void GeckoViewSupport::Open( // start. gfxPlatform::GetPlatform(); + mozilla::net::AsyncUrlChannelClassifier::WarmUp(); + nsCOMPtr<nsIWindowWatcher> ww = do_GetService(NS_WINDOWWATCHER_CONTRACTID); MOZ_RELEASE_ASSERT(ww);