зеркало из https://github.com/mozilla/gecko-dev.git
Bug 726002 - More OOM handling in UrlClassifier. r=dcamp
This commit is contained in:
Родитель
40e607b927
Коммит
f0c2ed80e9
|
@ -174,6 +174,9 @@ nsresult
|
|||
LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
||||
const AddCompleteArray& aAddCompletes)
|
||||
{
|
||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
|
||||
static_cast<PRUint32>(aAddCompletes.Length()));
|
||||
|
||||
mCompletions.Clear();
|
||||
mCompletions.SetCapacity(aAddCompletes.Length());
|
||||
for (uint32 i = 0; i < aAddCompletes.Length(); i++) {
|
||||
|
@ -181,16 +184,13 @@ LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
|||
}
|
||||
mCompletions.Sort();
|
||||
|
||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
|
||||
static_cast<PRUint32>(mCompletions.Length()));
|
||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
|
||||
static_cast<PRUint32>(aAddPrefixes.Length()));
|
||||
|
||||
nsresult rv = ConstructPrefixSet(aAddPrefixes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPrimed = true;
|
||||
|
||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
|
||||
static_cast<PRUint32>(aAddPrefixes.Length()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -683,8 +683,11 @@ LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
|
|||
{
|
||||
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;
|
||||
|
||||
nsTArray<PRUint32> array;
|
||||
array.SetCapacity(aAddPrefixes.Length());
|
||||
FallibleTArray<PRUint32> array;
|
||||
nsresult rv = array.SetCapacity(aAddPrefixes.Length());
|
||||
if (NS_FAILED(rv)) {
|
||||
goto error_bailout;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
|
||||
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
|
||||
|
@ -699,7 +702,7 @@ LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
|
|||
array.Sort();
|
||||
|
||||
// construct new one, replace old entries
|
||||
nsresult rv = mPrefixSet->SetPrefixes(array.Elements(), array.Length());
|
||||
rv = mPrefixSet->SetPrefixes(array.Elements(), array.Length());
|
||||
if (NS_FAILED(rv)) {
|
||||
goto error_bailout;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче