Bug 806422 - Do not cache Complete's across a SafeBrowsing update. r=dcamp

This commit is contained in:
Gian-Carlo Pascutto
2012-11-06 15:38:16 +01:00
parent 9a5591a690
commit 0aba543f82
5 changed files with 46 additions and 8 deletions

View File

@@ -95,8 +95,7 @@ LookupCache::Open()
// Simply lacking a .cache file is a recoverable error,
// as unlike the .pset/.sbstore files it is a pure cache.
// Just create a new empty one.
Clear();
UpdateHeader();
ClearCompleteCache();
} else {
// Read in the .cache file
rv = ReadHeader(inputStream);
@@ -144,7 +143,7 @@ LookupCache::Reset()
rv = prefixsetFile->Remove(false);
NS_ENSURE_SUCCESS(rv, rv);
Clear();
ClearAll();
return NS_OK;
}
@@ -273,13 +272,20 @@ LookupCache::WriteFile()
}
void
LookupCache::Clear()
LookupCache::ClearAll()
{
mCompletions.Clear();
ClearCompleteCache();
mPrefixSet->SetPrefixes(nullptr, 0);
mPrimed = false;
}
void
LookupCache::ClearCompleteCache()
{
mCompletions.Clear();
UpdateHeader();
}
void
LookupCache::UpdateHeader()
{
@@ -320,8 +326,7 @@ nsresult
LookupCache::ReadHeader(nsIInputStream* aInputStream)
{
if (!aInputStream) {
Clear();
UpdateHeader();
ClearCompleteCache();
return NS_OK;
}