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
7c0b8ad663
commit
d028e48340
@ -174,6 +174,9 @@ nsresult
|
|||||||
LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
||||||
const AddCompleteArray& aAddCompletes)
|
const AddCompleteArray& aAddCompletes)
|
||||||
{
|
{
|
||||||
|
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
|
||||||
|
static_cast<PRUint32>(aAddCompletes.Length()));
|
||||||
|
|
||||||
mCompletions.Clear();
|
mCompletions.Clear();
|
||||||
mCompletions.SetCapacity(aAddCompletes.Length());
|
mCompletions.SetCapacity(aAddCompletes.Length());
|
||||||
for (uint32 i = 0; i < aAddCompletes.Length(); i++) {
|
for (uint32 i = 0; i < aAddCompletes.Length(); i++) {
|
||||||
@ -181,16 +184,13 @@ LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
|||||||
}
|
}
|
||||||
mCompletions.Sort();
|
mCompletions.Sort();
|
||||||
|
|
||||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
|
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
|
||||||
static_cast<PRUint32>(mCompletions.Length()));
|
static_cast<PRUint32>(aAddPrefixes.Length()));
|
||||||
|
|
||||||
nsresult rv = ConstructPrefixSet(aAddPrefixes);
|
nsresult rv = ConstructPrefixSet(aAddPrefixes);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
mPrimed = true;
|
mPrimed = true;
|
||||||
|
|
||||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
|
|
||||||
static_cast<PRUint32>(aAddPrefixes.Length()));
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,8 +683,12 @@ LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
|
|||||||
{
|
{
|
||||||
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;
|
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;
|
||||||
|
|
||||||
nsTArray<PRUint32> array;
|
FallibleTArray<PRUint32> array;
|
||||||
array.SetCapacity(aAddPrefixes.Length());
|
nsresult rv;
|
||||||
|
if (!array.SetCapacity(aAddPrefixes.Length())) {
|
||||||
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
goto error_bailout;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
|
for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
|
||||||
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
|
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
|
||||||
@ -699,7 +703,7 @@ LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
|
|||||||
array.Sort();
|
array.Sort();
|
||||||
|
|
||||||
// construct new one, replace old entries
|
// 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)) {
|
if (NS_FAILED(rv)) {
|
||||||
goto error_bailout;
|
goto error_bailout;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user