Bug 1311935 - P2. Process fullHashes.find response. r=francois

This patch includes following changes:

1. nsUrlClassifierHashCompleter.js
   nsUrlClassifierHashCompleter.idl
   - Add completionV4 interface for hashCompleter to pass response data to
     DB service.
   - Process response data includes negative cache duration, matched full
     hashes and cache duration for each match. Full matches are passed through
     nsIFullHashMatch interface.
   - Change _requests.responses from array contains matched fullhashes to
     dictionary so that it can store additional information likes negative cache
     duration.
2. nsUrlClassifierDBService.cpp
   - Implement CompletionV4 interface, store response data to CacheResultV4
     object. Expired duration to expired time is handled here.
   - Add CacheResultToTableUpdate function to convert V2 & V4 cache result
     to TableUpdate object.
3. LookupCache.h
   - Extend CacheResult to CacheResultV2 and CacheResultV4 so we can store
     response data in CompletionV2 and CompletionV4.
4. HashStore.h
   - Add API and member variable in TableUpdateV4 to store response data.
     TableUpdate object is used by DB service to pass update data or gethash
     response to Classifier, so we need to extend TableUpdateV4 to be able
     to store fullHashes.find response.
6. Entry.h
   - Define the structure about how we cache fullHashes.find response.

MozReview-Commit-ID: KgR1NASl7GC
This commit is contained in:
dimi
2017-04-10 16:20:09 +08:00
parent c4fc0215be
commit 5856f89d1f
14 changed files with 449 additions and 97 deletions

View File

@@ -193,6 +193,19 @@ TableUpdateV4::NewChecksum(const std::string& aChecksum)
mChecksum.Assign(aChecksum.data(), aChecksum.size());
}
nsresult
TableUpdateV4::NewFullHashResponse(const nsACString& aPrefix,
CachedFullHashResponse& aResponse)
{
CachedFullHashResponse* response =
mFullHashResponseMap.LookupOrAdd(aPrefix);
if (!response) {
return NS_ERROR_OUT_OF_MEMORY;
}
*response = aResponse;
return NS_OK;
}
HashStore::HashStore(const nsACString& aTableName,
const nsACString& aProvider,
nsIFile* aRootStoreDir)