mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 420370: nsUrlClassifierHashCompleter not configured immediately at startup. r=tony, blocking-firefox3=beltzner
This commit is contained in:
parent
d3365453db
commit
09fbf95030
@ -105,7 +105,7 @@ function PROT_ListManager() {
|
|||||||
.getService(Ci.nsIUrlClassifierDBService);
|
.getService(Ci.nsIUrlClassifierDBService);
|
||||||
|
|
||||||
this.hashCompleter_ = Cc["@mozilla.org/url-classifier/hashcompleter;1"]
|
this.hashCompleter_ = Cc["@mozilla.org/url-classifier/hashcompleter;1"]
|
||||||
.createInstance(Ci.nsIUrlClassifierHashCompleter);
|
.getService(Ci.nsIUrlClassifierHashCompleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +178,6 @@ PROT_ListManager.prototype.registerTable = function(tableName,
|
|||||||
opt_requireMac) {
|
opt_requireMac) {
|
||||||
this.tablesData[tableName] = {};
|
this.tablesData[tableName] = {};
|
||||||
this.tablesData[tableName].needsUpdate = false;
|
this.tablesData[tableName].needsUpdate = false;
|
||||||
this.dbService_.setHashCompleter(tableName, this.hashCompleter_);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3720,6 +3720,18 @@ nsUrlClassifierDBService::CacheCompletions(nsTArray<nsUrlClassifierLookupResult>
|
|||||||
return mWorkerProxy->CacheCompletions(results);
|
return mWorkerProxy->CacheCompletions(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool
|
||||||
|
nsUrlClassifierDBService::GetCompleter(const nsACString &tableName,
|
||||||
|
nsIUrlClassifierHashCompleter **completer)
|
||||||
|
{
|
||||||
|
if (mCompleters.Get(tableName, completer)) {
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_SUCCEEDED(CallGetService(NS_URLCLASSIFIERHASHCOMPLETER_CONTRACTID,
|
||||||
|
completer));
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsUrlClassifierDBService::Observe(nsISupports *aSubject, const char *aTopic,
|
nsUrlClassifierDBService::Observe(nsISupports *aSubject, const char *aTopic,
|
||||||
const PRUnichar *aData)
|
const PRUnichar *aData)
|
||||||
|
@ -87,10 +87,7 @@ public:
|
|||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
|
|
||||||
PRBool GetCompleter(const nsACString& tableName,
|
PRBool GetCompleter(const nsACString& tableName,
|
||||||
nsIUrlClassifierHashCompleter** completer) {
|
nsIUrlClassifierHashCompleter** completer);
|
||||||
return mCompleters.Get(tableName, completer);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult CacheCompletions(nsTArray<nsUrlClassifierLookupResult> *results);
|
nsresult CacheCompletions(nsTArray<nsUrlClassifierLookupResult> *results);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -530,8 +530,12 @@ nsUrlClassifierHashCompleter::Complete(const nsACString &partialHash,
|
|||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule ourselves to start this request on the main loop.
|
// If we don't have a gethash url yet, don't bother scheduling
|
||||||
NS_DispatchToCurrentThread(this);
|
// the request until we have one.
|
||||||
|
if (!mGethashUrl.IsEmpty()) {
|
||||||
|
// Schedule ourselves to start this request on the main loop.
|
||||||
|
NS_DispatchToCurrentThread(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mRequest->Add(partialHash, c);
|
return mRequest->Add(partialHash, c);
|
||||||
@ -541,6 +545,12 @@ NS_IMETHODIMP
|
|||||||
nsUrlClassifierHashCompleter::SetGethashUrl(const nsACString &url)
|
nsUrlClassifierHashCompleter::SetGethashUrl(const nsACString &url)
|
||||||
{
|
{
|
||||||
mGethashUrl = url;
|
mGethashUrl = url;
|
||||||
|
|
||||||
|
if (mRequest) {
|
||||||
|
// Schedule any pending request.
|
||||||
|
NS_DispatchToCurrentThread(this);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,32 +318,6 @@ function testMixedSizesDifferentDomains() {
|
|||||||
doTest([update1, update2], assertions);
|
doTest([update1, update2], assertions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMixedSizesNoCompleter() {
|
|
||||||
var add1Urls = [ "foo.com/a" ];
|
|
||||||
var add2Urls = [ "foo.com/b" ];
|
|
||||||
|
|
||||||
var update1 = buildPhishingUpdate(
|
|
||||||
[
|
|
||||||
{ "chunkNum" : 1,
|
|
||||||
"urls" : add1Urls }],
|
|
||||||
4);
|
|
||||||
var update2 = buildPhishingUpdate(
|
|
||||||
[
|
|
||||||
{ "chunkNum" : 2,
|
|
||||||
"urls" : add2Urls }],
|
|
||||||
32);
|
|
||||||
|
|
||||||
var assertions = {
|
|
||||||
"tableData" : "test-phish-simple;a:1-2",
|
|
||||||
// add1Urls shouldn't work, because there is no completer.
|
|
||||||
"urlsDontExist" : add1Urls,
|
|
||||||
// but add2Urls were complete, they should work.
|
|
||||||
"urlsExist" : add2Urls
|
|
||||||
};
|
|
||||||
|
|
||||||
doTest([update1, update2], assertions);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testInvalidHashSize()
|
function testInvalidHashSize()
|
||||||
{
|
{
|
||||||
var addUrls = [ "foo.com/a", "foo.com/b", "bar.com/c" ];
|
var addUrls = [ "foo.com/a", "foo.com/b", "bar.com/c" ];
|
||||||
@ -530,7 +504,6 @@ function run_test()
|
|||||||
testCompleterFailure,
|
testCompleterFailure,
|
||||||
testMixedSizesSameDomain,
|
testMixedSizesSameDomain,
|
||||||
testMixedSizesDifferentDomains,
|
testMixedSizesDifferentDomains,
|
||||||
testMixedSizesNoCompleter,
|
|
||||||
testInvalidHashSize,
|
testInvalidHashSize,
|
||||||
testCachedResults,
|
testCachedResults,
|
||||||
testCachedResultsWithSub,
|
testCachedResultsWithSub,
|
||||||
|
Loading…
Reference in New Issue
Block a user