diff --git a/image/src/imgRequest.cpp b/image/src/imgRequest.cpp index fa2cded54a8..1f6b7d1972f 100644 --- a/image/src/imgRequest.cpp +++ b/image/src/imgRequest.cpp @@ -685,6 +685,15 @@ NS_IMETHODIMP imgRequest::OnStopDecode(imgIRequest *aRequest, aStatusArg); } + if (NS_FAILED(aStatus)) { + // Some kind of problem has happened with image decoding. + // Report the URI to net:failed-to-decode-uri observers. + + nsCOMPtr os = mozilla::services::GetObserverService(); + if (os) + os->NotifyObservers(mURI, "net:failed-to-process-uri", nsnull); + } + // RasterImage and everything below it is completely correct and // bulletproof about its handling of decoder notifications. // Unfortunately, here and above we have to make some gross and diff --git a/image/test/mochitest/Makefile.in b/image/test/mochitest/Makefile.in index 39548c1d5a6..8c3cb873f64 100644 --- a/image/test/mochitest/Makefile.in +++ b/image/test/mochitest/Makefile.in @@ -118,6 +118,9 @@ _CHROME_FILES = imgutils.js \ test_undisplayed_iframe.html \ iframe.html \ ref-iframe.html \ + test_net_failedtoprocess.html \ + invalid.jpg \ + damon.jpg \ $(NULL) libs:: $(_TEST_FILES) diff --git a/image/test/mochitest/invalid.jpg b/image/test/mochitest/invalid.jpg new file mode 100644 index 00000000000..c677a81e29f --- /dev/null +++ b/image/test/mochitest/invalid.jpg @@ -0,0 +1 @@ +notajpg diff --git a/image/test/mochitest/test_net_failedtoprocess.html b/image/test/mochitest/test_net_failedtoprocess.html new file mode 100644 index 00000000000..207a061ba5f --- /dev/null +++ b/image/test/mochitest/test_net_failedtoprocess.html @@ -0,0 +1,48 @@ + + + + + Test for image net:failed-to-process-uri + + + + + +

+
+
+
+ + + + diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index a5487bc597c..5293dd6f59f 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -990,6 +990,29 @@ nsHttpConnectionMgr::PipelineFeedbackInfo(nsHttpConnectionInfo *ci, ent->OnPipelineFeedbackInfo(info, conn, data); } +void +nsHttpConnectionMgr::ReportFailedToProcess(nsIURI *uri) +{ + NS_ABORT_IF_FALSE(uri, "precondition"); + + nsCAutoString host; + PRInt32 port = -1; + bool usingSSL = false; + + nsresult rv = uri->SchemeIs("https", &usingSSL); + if (NS_SUCCEEDED(rv)) + rv = uri->GetAsciiHost(host); + if (NS_SUCCEEDED(rv)) + rv = uri->GetPort(&port); + if (NS_FAILED(rv) || host.IsEmpty()) + return; + + nsRefPtr ci = + new nsHttpConnectionInfo(host, port, nsnull, usingSSL); + + PipelineFeedbackInfo(ci, RedCorruptedContent, nsnull, 0); +} + // we're at the active connection limit if any one of the following conditions is true: // (1) at max-connections // (2) keep-alive enabled and at max-persistent-connections-per-server/proxy diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index 4da22a063cb..19bb3359434 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -205,6 +205,8 @@ public: nsHttpConnection *, PRUint32); + void ReportFailedToProcess(nsIURI *uri); + //------------------------------------------------------------------------- // NOTE: functions below may be called only on the socket thread. //------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index d134cb1a36e..5702498a4c0 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -343,6 +343,7 @@ nsHttpHandler::Init() mObserverService->AddObserver(this, "net:clear-active-logins", true); mObserverService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, true); mObserverService->AddObserver(this, "net:prune-dead-connections", true); + mObserverService->AddObserver(this, "net:failed-to-process-uri", true); } return NS_OK; @@ -1634,6 +1635,11 @@ nsHttpHandler::Observe(nsISupports *subject, mConnMgr->PruneDeadConnections(); } } + else if (strcmp(topic, "net:failed-to-process-uri") == 0) { + nsCOMPtr uri = do_QueryInterface(subject); + if (uri && mConnMgr) + mConnMgr->ReportFailedToProcess(uri); + } return NS_OK; }