Bug 1498736 - Log the number of prefixes loaded from disk. r=dimi

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Francois Marier 2018-10-13 20:21:45 +00:00
Родитель fe4f74eb20
Коммит da7c3b0f8c
3 изменённых файлов: 15 добавлений и 2 удалений

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

@ -39,6 +39,7 @@ VariableLengthPrefixSet::VariableLengthPrefixSet()
nsresult nsresult
VariableLengthPrefixSet::Init(const nsACString& aName) VariableLengthPrefixSet::Init(const nsACString& aName)
{ {
mName = aName;
mMemoryReportPath = mMemoryReportPath =
nsPrintfCString( nsPrintfCString(
"explicit/storage/prefix-set/%s", "explicit/storage/prefix-set/%s",
@ -304,7 +305,7 @@ VariableLengthPrefixSet::LoadPrefixes(nsCOMPtr<nsIInputStream>& in)
NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE); NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE);
if (magic != PREFIXSET_VERSION_MAGIC) { if (magic != PREFIXSET_VERSION_MAGIC) {
LOG(("Version magic mismatch, not loading")); LOG(("[%s] Version magic mismatch, not loading", mName.get()));
return NS_ERROR_FILE_CORRUPTED; return NS_ERROR_FILE_CORRUPTED;
} }
@ -315,6 +316,7 @@ VariableLengthPrefixSet::LoadPrefixes(nsCOMPtr<nsIInputStream>& in)
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE); NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE);
uint32_t totalPrefixes = 0;
for(;count > 0; count--) { for(;count > 0; count--) {
uint8_t prefixSize; uint8_t prefixSize;
rv = in->Read(reinterpret_cast<char*>(&prefixSize), sizeof(uint8_t), &read); rv = in->Read(reinterpret_cast<char*>(&prefixSize), sizeof(uint8_t), &read);
@ -330,6 +332,9 @@ VariableLengthPrefixSet::LoadPrefixes(nsCOMPtr<nsIInputStream>& in)
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE); NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(stringLength % prefixSize == 0, NS_ERROR_FILE_CORRUPTED);
uint32_t prefixCount = stringLength / prefixSize;
nsCString* vlPrefixes = new nsCString(); nsCString* vlPrefixes = new nsCString();
if (!vlPrefixes->SetLength(stringLength, fallible)) { if (!vlPrefixes->SetLength(stringLength, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -340,8 +345,14 @@ VariableLengthPrefixSet::LoadPrefixes(nsCOMPtr<nsIInputStream>& in)
NS_ENSURE_TRUE(read == stringLength, NS_ERROR_FAILURE); NS_ENSURE_TRUE(read == stringLength, NS_ERROR_FAILURE);
mVLPrefixSet.Put(prefixSize, vlPrefixes); mVLPrefixSet.Put(prefixSize, vlPrefixes);
totalPrefixes += prefixCount;
LOG(("[%s] Loaded %u %u-byte prefixes", mName.get(), prefixCount,
prefixSize));
} }
LOG(("[%s] Loading VLPrefixSet successful (%u total prefixes)", mName.get(),
totalPrefixes));
return NS_OK; return NS_OK;
} }

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

@ -62,6 +62,7 @@ private:
const RefPtr<nsUrlClassifierPrefixSet> mFixedPrefixSet; const RefPtr<nsUrlClassifierPrefixSet> mFixedPrefixSet;
mozilla::safebrowsing::PrefixStringMap mVLPrefixSet; mozilla::safebrowsing::PrefixStringMap mVLPrefixSet;
nsCString mName;
nsCString mMemoryReportPath; nsCString mMemoryReportPath;
}; };

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

@ -519,7 +519,8 @@ nsUrlClassifierPrefixSet::LoadPrefixes(nsCOMPtr<nsIInputStream>& in)
} }
MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length()); MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length());
LOG(("[%s] Loading PrefixSet successful", mName.get())); LOG(("[%s] Loading PrefixSet successful (%u total prefixes)", mName.get(),
mTotalPrefixes));
return NS_OK; return NS_OK;
} }