Bug 635977. Make sure to always send OnStartRequest to our listener from nsIndexedToHTML. r=jduell, a=bsmedberg

This commit is contained in:
Boris Zbarsky 2011-02-24 13:42:15 -05:00
Родитель 7a06b32073
Коммит c779a23e49
2 изменённых файлов: 28 добавлений и 13 удалений

Просмотреть файл

@ -151,6 +151,29 @@ nsIndexedToHTML::AsyncConvertData(const char *aFromType,
NS_IMETHODIMP
nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
nsString buffer;
nsresult rv = DoOnStartRequest(request, aContext, buffer);
if (NS_FAILED(rv)) {
request->Cancel(rv);
}
rv = mListener->OnStartRequest(request, aContext);
if (NS_FAILED(rv)) return rv;
// The request may have been canceled, and if that happens, we want to
// suppress calls to OnDataAvailable.
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
// Push our buffer to the listener.
rv = FormatInputStream(request, aContext, buffer);
return rv;
}
nsresult
nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
nsString& aBuffer) {
nsresult rv;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
@ -670,18 +693,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
" </thead>\n");
buffer.AppendLiteral(" <tbody>\n");
// Push buffer to the listener now, so the initial HTML will not
// be parsed in OnDataAvailable().
rv = mListener->OnStartRequest(request, aContext);
if (NS_FAILED(rv)) return rv;
// The request may have been canceled, and if that happens, we want to
// suppress calls to OnDataAvailable.
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
rv = FormatInputStream(request, aContext, buffer);
aBuffer = buffer;
return rv;
}

Просмотреть файл

@ -75,7 +75,10 @@ public:
protected:
void FormatSizeString(PRInt64 inSize, nsString& outSizeString);
nsresult FormatInputStream(nsIRequest* aRequest, nsISupports *aContext, const nsAString &aBuffer);
nsresult FormatInputStream(nsIRequest* aRequest, nsISupports *aContext, const nsAString &aBuffer);
// Helper to properly implement OnStartRequest
nsresult DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
nsString& aBuffer);
protected:
nsCOMPtr<nsIDirIndexParser> mParser;