mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 726002 - More OOM handling in UrlClassifier. r=dcamp
This commit is contained in:
parent
1caaad7538
commit
d705e725b0
@ -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,12 @@ 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;
|
||||
if (!array.SetCapacity(aAddPrefixes.Length())) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto error_bailout;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
|
||||
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
|
||||
@ -699,7 +703,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user