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
parent 596bb218c5
commit 98de6694fc
3 changed files with 685 additions and 369 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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,

View File

@ -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),