Bug 1279208, r=mak

MozReview-Commit-ID: KOuTjwn9MSx

--HG--
extra : rebase_source : 9ab3fbb75019e6a7ccfca4164d18c9b756c43d7d
extra : amend_source : bdf3328e53f56c37cca745e03254f3483fd188df
This commit is contained in:
Gijs Kruitbosch 2016-06-09 13:25:07 +01:00
parent a967cdb984
commit a60614a313
2 changed files with 17 additions and 7 deletions

View File

@ -91,7 +91,7 @@ let InternalFaviconLoader = {
*/
observe(subject, topic, data) {
let innerWindowID = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
this.onInnerDestroyed(innerWindowID);
this.removeRequestsForInner(innerWindowID);
},
/**
@ -113,12 +113,12 @@ let InternalFaviconLoader = {
/**
* Called for every inner that gets destroyed, only in the parent process.
*/
onInnerDestroyed(innerID) {
removeRequestsForInner(innerID) {
for (let [window, loadDataForWindow] of gFaviconLoadDataMap) {
let newLoadDataForWindow = loadDataForWindow.filter(loadData => {
let innerWasDestroyed = loadData.innerWindowID == innerID;
if (innerWasDestroyed) {
this._cancelRequest(loadData, "the inner window was destroyed");
this._cancelRequest(loadData, "the inner window was destroyed or a new favicon was loaded for it");
}
// Keep the items whose inner is still alive.
return !innerWasDestroyed;
@ -180,7 +180,7 @@ let InternalFaviconLoader = {
Services.obs.addObserver(this, "inner-window-destroyed", false);
Services.ppmm.addMessageListener("Toolkit:inner-window-destroyed", msg => {
this.onInnerDestroyed(msg.data);
this.removeRequestsForInner(msg.data);
});
},
@ -191,8 +191,8 @@ let InternalFaviconLoader = {
gFaviconLoadDataMap.set(win, []);
let unloadHandler = event => {
let doc = event.target;
let eventWin = doc.defaultview;
if (win == win.top && doc.documentURI != "about:blank") {
let eventWin = doc.defaultView;
if (eventWin == win) {
win.removeEventListener("unload", unloadHandler);
this.onUnload(win);
}
@ -200,6 +200,9 @@ let InternalFaviconLoader = {
win.addEventListener("unload", unloadHandler, true);
}
// Immediately cancel any earlier requests
this.removeRequestsForInner(innerWindowID);
// First we do the actual setAndFetch call:
let {innerWindowID, currentURI} = browser;
let loadType = PrivateBrowsingUtils.isWindowPrivate(win)

View File

@ -441,7 +441,11 @@ AsyncFetchAndSetIconForPage::FetchFromNetwork() {
priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST);
}
return channel->AsyncOpen2(this);
rv = channel->AsyncOpen2(this);
if (NS_SUCCEEDED(rv)) {
mRequest = channel;
}
return rv;
}
NS_IMETHODIMP
@ -462,6 +466,9 @@ NS_IMETHODIMP
AsyncFetchAndSetIconForPage::OnStartRequest(nsIRequest* aRequest,
nsISupports* aContext)
{
// mRequest should already be set from ::FetchFromNetwork, but in the case of
// a redirect we might get a new request, and we should make sure we keep a
// reference to the most current request.
mRequest = aRequest;
if (mCanceled) {
mRequest->Cancel(NS_BINDING_ABORTED);