author | Ed Morley <emorley@mozilla.com> |
Tue, 22 Apr 2014 17:37:01 +0100 | |
changeset 179620 | 22e57c335fc5bbd8e0b919c624e047106978536d |
parent 179619 | ec50db58f17b650f21b2df06eeee12cd76dd4be0 |
child 179621 | 4d232ce4ffb53d5fe15b3d1849088a7841323462 |
push id | 26632 |
push user | kwierso@gmail.com |
push date | Wed, 23 Apr 2014 00:54:42 +0000 |
treeherder | mozilla-central@02515cf4fcfd [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 998396 |
milestone | 31.0a1 |
backs out | 73bb0c592bf166daf7a3de30e4c1b677387afed1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -25,17 +25,16 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsTArray.h" #include "nsNetUtil.h" #include "nsNetCID.h" #include "nsThreadUtils.h" #include "nsXPCOMStrings.h" #include "nsProxyRelease.h" -#include "nsString.h" #include "mozilla/Atomics.h" #include "mozilla/DebugOnly.h" #include "mozilla/Mutex.h" #include "mozilla/Preferences.h" #include "mozilla/TimeStamp.h" #include "mozilla/Telemetry.h" #include "prlog.h" #include "prprf.h" @@ -65,17 +64,16 @@ PRLogModuleInfo *gUrlClassifierDbService #define CHECK_MALWARE_DEFAULT false #define CHECK_PHISHING_PREF "browser.safebrowsing.enabled" #define CHECK_PHISHING_DEFAULT false #define GETHASH_NOISE_PREF "urlclassifier.gethashnoise" #define GETHASH_NOISE_DEFAULT 4 -// Comma-separated lists #define MALWARE_TABLE_PREF "urlclassifier.malware_table" #define PHISH_TABLE_PREF "urlclassifier.phish_table" #define DOWNLOAD_BLOCK_TABLE_PREF "urlclassifier.downloadBlockTable" #define DOWNLOAD_ALLOW_TABLE_PREF "urlclassifier.downloadAllowTable" #define DISALLOW_COMPLETION_TABLE_PREF "urlclassifier.disallow_completions" #define CONFIRM_AGE_PREF "urlclassifier.max-complete-age" #define CONFIRM_AGE_DEFAULT_SEC (45 * 60) @@ -1068,66 +1066,41 @@ nsUrlClassifierDBService::nsUrlClassifie } nsUrlClassifierDBService::~nsUrlClassifierDBService() { sUrlClassifierDBService = nullptr; } nsresult -nsUrlClassifierDBService::ReadTablesFromPrefs() -{ - nsCString allTables; - nsCString tables; - Preferences::GetCString(PHISH_TABLE_PREF, &allTables); - - Preferences::GetCString(MALWARE_TABLE_PREF, &tables); - if (!tables.IsEmpty()) { - allTables.Append(','); - allTables.Append(tables); - } - - Preferences::GetCString(DOWNLOAD_BLOCK_TABLE_PREF, &tables); - if (!tables.IsEmpty()) { - allTables.Append(','); - allTables.Append(tables); - } - - Preferences::GetCString(DOWNLOAD_ALLOW_TABLE_PREF, &tables); - if (!tables.IsEmpty()) { - allTables.Append(','); - allTables.Append(tables); - } - - Classifier::SplitTables(allTables, mGethashTables); - - Preferences::GetCString(DISALLOW_COMPLETION_TABLE_PREF, &tables); - Classifier::SplitTables(tables, mDisallowCompletionsTables); - - return NS_OK; -} - -nsresult nsUrlClassifierDBService::Init() { #if defined(PR_LOGGING) if (!gUrlClassifierDbServiceLog) gUrlClassifierDbServiceLog = PR_NewLogModule("UrlClassifierDbService"); #endif // Retrieve all the preferences. mCheckMalware = Preferences::GetBool(CHECK_MALWARE_PREF, CHECK_MALWARE_DEFAULT); mCheckPhishing = Preferences::GetBool(CHECK_PHISHING_PREF, CHECK_PHISHING_DEFAULT); uint32_t gethashNoise = Preferences::GetUint(GETHASH_NOISE_PREF, GETHASH_NOISE_DEFAULT); gFreshnessGuarantee = Preferences::GetInt(CONFIRM_AGE_PREF, CONFIRM_AGE_DEFAULT_SEC); - ReadTablesFromPrefs(); + mGethashTables.AppendElement(Preferences::GetCString(PHISH_TABLE_PREF)); + mGethashTables.AppendElement(Preferences::GetCString(MALWARE_TABLE_PREF)); + mGethashTables.AppendElement(Preferences::GetCString( + DOWNLOAD_BLOCK_TABLE_PREF)); + mGethashTables.AppendElement(Preferences::GetCString( + DOWNLOAD_ALLOW_TABLE_PREF)); + nsCString tables; + Preferences::GetCString(DISALLOW_COMPLETION_TABLE_PREF, &tables); + Classifier::SplitTables(tables, mDisallowCompletionsTables); // Do we *really* need to be able to change all of these at runtime? Preferences::AddStrongObserver(this, CHECK_MALWARE_PREF); Preferences::AddStrongObserver(this, CHECK_PHISHING_PREF); Preferences::AddStrongObserver(this, GETHASH_NOISE_PREF); Preferences::AddStrongObserver(this, CONFIRM_AGE_PREF); Preferences::AddStrongObserver(this, PHISH_TABLE_PREF); Preferences::AddStrongObserver(this, MALWARE_TABLE_PREF); @@ -1194,17 +1167,16 @@ nsUrlClassifierDBService::Classify(nsIPr } nsRefPtr<nsUrlClassifierClassifyCallback> callback = new nsUrlClassifierClassifyCallback(c, mCheckMalware, mCheckPhishing); if (!callback) return NS_ERROR_OUT_OF_MEMORY; nsAutoCString tables; nsAutoCString malware; - // LookupURI takes a comma-separated list already. Preferences::GetCString(MALWARE_TABLE_PREF, &malware); if (!malware.IsEmpty()) { tables.Append(malware); } nsAutoCString phishing; Preferences::GetCString(PHISH_TABLE_PREF, &phishing); if (!phishing.IsEmpty()) { tables.Append(","); @@ -1433,19 +1405,16 @@ nsUrlClassifierDBService::GetCompleter(c // If we don't know about this table at all, or are disallowing completions // for it, skip completion checks. if (!mGethashTables.Contains(tableName) || mDisallowCompletionsTables.Contains(tableName)) { return false; } - // We should never fetch hash completions for test tables. - MOZ_ASSERT(!StringBeginsWith(tableName, "test-")); - // Otherwise, call gethash to find the hash completions. return NS_SUCCEEDED(CallGetService(NS_URLCLASSIFIERHASHCOMPLETER_CONTRACTID, completer)); } NS_IMETHODIMP nsUrlClassifierDBService::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) @@ -1455,24 +1424,33 @@ nsUrlClassifierDBService::Observe(nsISup nsCOMPtr<nsIPrefBranch> prefs(do_QueryInterface(aSubject, &rv)); NS_ENSURE_SUCCESS(rv, rv); if (NS_LITERAL_STRING(CHECK_MALWARE_PREF).Equals(aData)) { mCheckMalware = Preferences::GetBool(CHECK_MALWARE_PREF, CHECK_MALWARE_DEFAULT); } else if (NS_LITERAL_STRING(CHECK_PHISHING_PREF).Equals(aData)) { mCheckPhishing = Preferences::GetBool(CHECK_PHISHING_PREF, CHECK_PHISHING_DEFAULT); - } else if ( - NS_LITERAL_STRING(PHISH_TABLE_PREF).Equals(aData) || - NS_LITERAL_STRING(MALWARE_TABLE_PREF).Equals(aData) || - NS_LITERAL_STRING(DOWNLOAD_BLOCK_TABLE_PREF).Equals(aData) || - NS_LITERAL_STRING(DOWNLOAD_ALLOW_TABLE_PREF).Equals(aData) || - NS_LITERAL_STRING(DISALLOW_COMPLETION_TABLE_PREF).Equals(aData)) { + } else if (NS_LITERAL_STRING(PHISH_TABLE_PREF).Equals(aData) || + NS_LITERAL_STRING(MALWARE_TABLE_PREF).Equals(aData) || + NS_LITERAL_STRING(DOWNLOAD_BLOCK_TABLE_PREF).Equals(aData) || + NS_LITERAL_STRING(DOWNLOAD_ALLOW_TABLE_PREF).Equals(aData)) { // Just read everything again. - ReadTablesFromPrefs(); + mGethashTables.Clear(); + mGethashTables.AppendElement(Preferences::GetCString(PHISH_TABLE_PREF)); + mGethashTables.AppendElement(Preferences::GetCString(MALWARE_TABLE_PREF)); + mGethashTables.AppendElement(Preferences::GetCString( + DOWNLOAD_BLOCK_TABLE_PREF)); + mGethashTables.AppendElement(Preferences::GetCString( + DOWNLOAD_ALLOW_TABLE_PREF)); + } else if (NS_LITERAL_STRING(DISALLOW_COMPLETION_TABLE_PREF).Equals(aData)) { + mDisallowCompletionsTables.Clear(); + nsCString tables; + Preferences::GetCString(DISALLOW_COMPLETION_TABLE_PREF, &tables); + Classifier::SplitTables(tables, mDisallowCompletionsTables); } else if (NS_LITERAL_STRING(CONFIRM_AGE_PREF).Equals(aData)) { gFreshnessGuarantee = Preferences::GetInt(CONFIRM_AGE_PREF, CONFIRM_AGE_DEFAULT_SEC); } } else if (!strcmp(aTopic, "profile-before-change") || !strcmp(aTopic, "xpcom-shutdown-threads")) { Shutdown(); } else {
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.h +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.h @@ -77,19 +77,16 @@ private: // Close db connection and join the background thread if it exists. nsresult Shutdown(); // Check if the key is on a known-clean host. nsresult CheckClean(const nsACString &lookupKey, bool *clean); - // Read everything into mGethashTables and mDisallowCompletionTables - nsresult ReadTablesFromPrefs(); - nsRefPtr<nsUrlClassifierDBServiceWorker> mWorker; nsCOMPtr<nsIUrlClassifierDBServiceWorker> mWorkerProxy; nsInterfaceHashtable<nsCStringHashKey, nsIUrlClassifierHashCompleter> mCompleters; // TRUE if the nsURIClassifier implementation should check for malware // uris on document loads. bool mCheckMalware;