зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1576292 - Avoid using directory service off-main-thread in URL Classifier gtest. r=gcp
Differential Revision: https://phabricator.services.mozilla.com/D44728 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
44ad3cfc99
Коммит
da8b128c32
|
@ -212,6 +212,20 @@ static nsresult BuildCache(LookupCacheV4* cache,
|
||||||
return cache->Build(map);
|
return cache->Build(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
RefPtr<T> SetupLookupCache(const _PrefixArray& aPrefixArray,
|
||||||
|
nsCOMPtr<nsIFile>& aFile) {
|
||||||
|
RefPtr<T> cache = new T(GTEST_TABLE_V4, EmptyCString(), aFile);
|
||||||
|
|
||||||
|
nsresult rv = cache->Init();
|
||||||
|
EXPECT_EQ(rv, NS_OK);
|
||||||
|
|
||||||
|
rv = BuildCache(cache, aPrefixArray);
|
||||||
|
EXPECT_EQ(rv, NS_OK);
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
RefPtr<T> SetupLookupCache(const _PrefixArray& aPrefixArray) {
|
RefPtr<T> SetupLookupCache(const _PrefixArray& aPrefixArray) {
|
||||||
nsCOMPtr<nsIFile> file;
|
nsCOMPtr<nsIFile> file;
|
||||||
|
|
|
@ -69,6 +69,10 @@ void CheckContent(LookupCacheV4* aCache, PrefixStringMap& aExpected);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
RefPtr<T> SetupLookupCache(const _PrefixArray& aPrefixArray);
|
RefPtr<T> SetupLookupCache(const _PrefixArray& aPrefixArray);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
RefPtr<T> SetupLookupCache(const _PrefixArray& aPrefixArray,
|
||||||
|
nsCOMPtr<nsIFile>& aFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Classifer class
|
* Retrieve Classifer class
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,8 +12,12 @@ static void TestHasPrefix(const nsCString& aURL, bool aExpectedHas,
|
||||||
CreatePrefixFromURL("gound.com/", 5),
|
CreatePrefixFromURL("gound.com/", 5),
|
||||||
CreatePrefixFromURL("small.com/", 4)};
|
CreatePrefixFromURL("small.com/", 4)};
|
||||||
|
|
||||||
|
nsCOMPtr<nsIFile> file;
|
||||||
|
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
|
||||||
|
file->AppendNative(GTEST_SAFEBROWSING_DIR);
|
||||||
|
|
||||||
RunTestInNewThread([&]() -> void {
|
RunTestInNewThread([&]() -> void {
|
||||||
RefPtr<LookupCache> cache = SetupLookupCache<LookupCacheV4>(array);
|
RefPtr<LookupCache> cache = SetupLookupCache<LookupCacheV4>(array, file);
|
||||||
|
|
||||||
Completion lookupHash;
|
Completion lookupHash;
|
||||||
lookupHash.FromPlaintext(aURL);
|
lookupHash.FromPlaintext(aURL);
|
||||||
|
|
|
@ -62,10 +62,10 @@ static void VerifyPrivateStorePath(T* target, const nsCString& aTableName,
|
||||||
|
|
||||||
TEST(UrlClassifierPerProviderDirectory, LookupCache)
|
TEST(UrlClassifierPerProviderDirectory, LookupCache)
|
||||||
{
|
{
|
||||||
RunTestInNewThread([]() -> void {
|
nsCOMPtr<nsIFile> rootDir;
|
||||||
nsCOMPtr<nsIFile> rootDir;
|
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir));
|
||||||
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir));
|
|
||||||
|
|
||||||
|
RunTestInNewThread([&]() -> void {
|
||||||
// For V2 tables (NOT ending with '-proto'), root directory should be
|
// For V2 tables (NOT ending with '-proto'), root directory should be
|
||||||
// used as the private store.
|
// used as the private store.
|
||||||
{
|
{
|
||||||
|
@ -96,10 +96,10 @@ TEST(UrlClassifierPerProviderDirectory, LookupCache)
|
||||||
|
|
||||||
TEST(UrlClassifierPerProviderDirectory, HashStore)
|
TEST(UrlClassifierPerProviderDirectory, HashStore)
|
||||||
{
|
{
|
||||||
RunTestInNewThread([]() -> void {
|
nsCOMPtr<nsIFile> rootDir;
|
||||||
nsCOMPtr<nsIFile> rootDir;
|
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir));
|
||||||
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir));
|
|
||||||
|
|
||||||
|
RunTestInNewThread([&]() -> void {
|
||||||
// For V2 tables (NOT ending with '-proto'), root directory should be
|
// For V2 tables (NOT ending with '-proto'), root directory should be
|
||||||
// used as the private store.
|
// used as the private store.
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче