Bug 1516133 - Avoid extra main-thread jumps during the URL-classification, r=dimi

This commit is contained in:
Andrea Marchesini 2019-01-17 09:33:25 +01:00
Родитель 20c9e44215
Коммит 5018c31d19
4 изменённых файлов: 719 добавлений и 370 удалений

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/Preferences.h"
#include "nsIChannel.h"
#include "nsIURI.h"
#include "nsProxyRelease.h"
namespace mozilla {
namespace net {
@ -84,7 +85,14 @@ TrackingDummyChannel::TrackingDummyChannel(nsIURI* aURI, nsIURI* aTopWindowURI,
SetLoadInfo(aLoadInfo);
}
TrackingDummyChannel::~TrackingDummyChannel() = default;
TrackingDummyChannel::~TrackingDummyChannel() {
NS_ReleaseOnMainThreadSystemGroup("TrackingDummyChannel::mLoadInfo",
mLoadInfo.forget());
NS_ReleaseOnMainThreadSystemGroup("TrackingDummyChannel::mURI",
mURI.forget());
NS_ReleaseOnMainThreadSystemGroup("TrackingDummyChannel::mTopWindowURI",
mTopWindowURI.forget());
}
bool TrackingDummyChannel::IsTrackingResource() const {
return mIsTrackingResource;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -51,7 +51,6 @@
#include "mozilla/net/UrlClassifierFeatureResult.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/SyncRunnable.h"
#include "nsProxyRelease.h"
#include "UrlClassifierTelemetryUtils.h"
#include "nsIURLFormatter.h"
#include "nsIUploadChannel.h"
@ -167,7 +166,7 @@ class FeatureHolder final {
NS_ENSURE_SUCCESS(rv, rv);
for (TableData* tableData : mTableData) {
nsresult rv = aWorker->DoSingleLocalLookupWithURIFragments(
rv = aWorker->DoSingleLocalLookupWithURIFragments(
fragments, tableData->mTable, tableData->mResults);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -2451,6 +2450,15 @@ bool nsUrlClassifierDBService::ShutdownHasStarted() {
return gShuttingDownThread;
}
// static
nsUrlClassifierDBServiceWorker* nsUrlClassifierDBService::GetWorker() {
if (!sUrlClassifierDBService) {
return nullptr;
}
return sUrlClassifierDBService->mWorker;
}
NS_IMETHODIMP
nsUrlClassifierDBService::AsyncClassifyLocalWithFeatures(
nsIURI* aURI, const nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures,

Просмотреть файл

@ -70,7 +70,9 @@ class nsUrlClassifierDBServiceWorker;
class nsIThread;
class nsIURI;
class UrlClassifierDBServiceWorkerProxy;
namespace mozilla {
namespace safebrowsing {
class Classifier;
class ProtocolParser;
@ -78,6 +80,11 @@ class ProtocolParser;
nsresult TablesToResponse(const nsACString& tables);
} // namespace safebrowsing
namespace net {
class AsyncUrlChannelClassifier;
}
} // namespace mozilla
// This is a proxy class that just creates a background thread and delegates
@ -86,6 +93,8 @@ class nsUrlClassifierDBService final : public nsIUrlClassifierDBService,
public nsIURIClassifier,
public nsIUrlClassifierInfo,
public nsIObserver {
friend class mozilla::net::AsyncUrlChannelClassifier;
public:
// This is thread safe. It throws an exception if the thread is busy.
nsUrlClassifierDBService();
@ -113,6 +122,10 @@ class nsUrlClassifierDBService final : public nsIUrlClassifierDBService,
static bool ShutdownHasStarted();
private:
// This method is used only by AsyncUrlChannelClassifier. If you want to use
// it, please contact a safebrowsing/URL-Classifier peer.
static nsUrlClassifierDBServiceWorker* GetWorker();
const nsTArray<nsCString> kObservedPrefs = {
NS_LITERAL_CSTRING(CHECK_MALWARE_PREF),
NS_LITERAL_CSTRING(CHECK_PHISHING_PREF),