зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1351472 - Skip AddNoise if the table is unknown or disallowed to getHash r=francois
MozReview-Commit-ID: GMWs2UpiyiP --HG-- extra : rebase_source : 9b24bf9fa6ad5aa12077f6e4ffa2ac65b0862b40
This commit is contained in:
Родитель
39669a550b
Коммит
52ed9fd77e
|
@ -144,10 +144,12 @@ nsUrlClassifierDBServiceWorker::~nsUrlClassifierDBServiceWorker()
|
|||
|
||||
nsresult
|
||||
nsUrlClassifierDBServiceWorker::Init(uint32_t aGethashNoise,
|
||||
nsCOMPtr<nsIFile> aCacheDir)
|
||||
nsCOMPtr<nsIFile> aCacheDir,
|
||||
nsUrlClassifierDBService *aDBService)
|
||||
{
|
||||
mGethashNoise = aGethashNoise;
|
||||
mCacheDir = aCacheDir;
|
||||
mDBService = aDBService;
|
||||
|
||||
ResetUpdate();
|
||||
|
||||
|
@ -276,7 +278,9 @@ nsUrlClassifierDBServiceWorker::DoLookup(const nsACString& spec,
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < completes->Length(); i++) {
|
||||
if (!completes->ElementAt(i).Confirmed()) {
|
||||
if (!completes->ElementAt(i).Confirmed() &&
|
||||
mDBService->CanComplete(completes->ElementAt(i).mTableName)) {
|
||||
|
||||
// We're going to be doing a gethash request, add some extra entries.
|
||||
// Note that we cannot pass the first two by reference, because we
|
||||
// add to completes, whicah can cause completes to reallocate and move.
|
||||
|
@ -1719,7 +1723,7 @@ nsUrlClassifierDBService::Init()
|
|||
if (!mWorker)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = mWorker->Init(sGethashNoise, cacheDir);
|
||||
rv = mWorker->Init(sGethashNoise, cacheDir, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
mWorker = nullptr;
|
||||
return rv;
|
||||
|
@ -2261,6 +2265,13 @@ nsUrlClassifierDBService::CacheMisses(PrefixArray *results)
|
|||
return mWorkerProxy->CacheMisses(results);
|
||||
}
|
||||
|
||||
bool
|
||||
nsUrlClassifierDBService::CanComplete(const nsACString &aTableName)
|
||||
{
|
||||
return mGethashTables.Contains(aTableName) &&
|
||||
!mDisallowCompletionsTables.Contains(aTableName);
|
||||
}
|
||||
|
||||
bool
|
||||
nsUrlClassifierDBService::GetCompleter(const nsACString &tableName,
|
||||
nsIUrlClassifierHashCompleter **completer)
|
||||
|
@ -2271,10 +2282,7 @@ nsUrlClassifierDBService::GetCompleter(const nsACString &tableName,
|
|||
return true;
|
||||
}
|
||||
|
||||
// If we don't know about this table at all, or are disallowing completions
|
||||
// for it, skip completion checks.
|
||||
if (!mGethashTables.Contains(tableName) ||
|
||||
mDisallowCompletionsTables.Contains(tableName)) {
|
||||
if (!CanComplete(tableName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2371,6 +2379,8 @@ nsUrlClassifierDBService::Shutdown()
|
|||
backgroundThread->Shutdown();
|
||||
NS_RELEASE(backgroundThread);
|
||||
}
|
||||
|
||||
mWorker = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,9 @@ public:
|
|||
NS_DECL_NSIURICLASSIFIER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
bool CanComplete(const nsACString &tableName);
|
||||
bool GetCompleter(const nsACString& tableName,
|
||||
nsIUrlClassifierHashCompleter** completer);
|
||||
nsIUrlClassifierHashCompleter** completer);
|
||||
nsresult CacheCompletions(mozilla::safebrowsing::CacheResultArray *results);
|
||||
nsresult CacheMisses(mozilla::safebrowsing::PrefixArray *results);
|
||||
|
||||
|
@ -190,7 +191,9 @@ public:
|
|||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIURLCLASSIFIERDBSERVICE
|
||||
|
||||
nsresult Init(uint32_t aGethashNoise, nsCOMPtr<nsIFile> aCacheDir);
|
||||
nsresult Init(uint32_t aGethashNoise,
|
||||
nsCOMPtr<nsIFile> aCacheDir,
|
||||
nsUrlClassifierDBService* aDBService);
|
||||
|
||||
// Queue a lookup for the worker to perform, called in the main thread.
|
||||
// tables is a comma-separated list of tables to query
|
||||
|
@ -268,6 +271,8 @@ private:
|
|||
// Directory where to store the SB databases.
|
||||
nsCOMPtr<nsIFile> mCacheDir;
|
||||
|
||||
RefPtr<nsUrlClassifierDBService> mDBService;
|
||||
|
||||
// XXX: maybe an array of autoptrs. Or maybe a class specifically
|
||||
// storing a series of updates.
|
||||
nsTArray<mozilla::safebrowsing::TableUpdate*> mTableUpdates;
|
||||
|
|
Загрузка…
Ссылка в новой задаче