Bug 591081 - Keep using nsExternalAppHandler in the child process after forwarding download request, r=dwitte, a=blocking-fennec2.0b1

This commit is contained in:
Brian Crowder 2010-09-13 11:37:00 -07:00
Родитель bec0f06b6f
Коммит f0be8f4dd4
2 изменённых файлов: 32 добавлений и 31 удалений

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

@ -89,8 +89,9 @@ ExternalHelperAppChild::OnDataAvailable(nsIRequest *request,
NS_IMETHODIMP NS_IMETHODIMP
ExternalHelperAppChild::OnStartRequest(nsIRequest *request, nsISupports *ctx) ExternalHelperAppChild::OnStartRequest(nsIRequest *request, nsISupports *ctx)
{ {
// FIXME: Eventually we should implement this: nsresult rv = mHandler->OnStartRequest(request, ctx);
// mHandler->OnStartRequest(request, ctx); NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
nsCString entityID; nsCString entityID;
nsCOMPtr<nsIResumableChannel> resumable(do_QueryInterface(request)); nsCOMPtr<nsIResumableChannel> resumable(do_QueryInterface(request));
if (resumable) if (resumable)
@ -105,9 +106,10 @@ ExternalHelperAppChild::OnStopRequest(nsIRequest *request,
nsISupports *ctx, nsISupports *ctx,
nsresult status) nsresult status)
{ {
// FIXME: Eventually we should implement this: nsresult rv = mHandler->OnStopRequest(request, ctx, status);
// mHandler->OnStopRequest(request, ctx, status);
SendOnStopRequest(status); SendOnStopRequest(status);
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
return NS_OK; return NS_OK;
} }

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

@ -719,18 +719,13 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
NS_ADDREF(*aStreamListener = childListener); NS_ADDREF(*aStreamListener = childListener);
// FIXME: Eventually we'll use this original listener to finish up client-side nsRefPtr<nsExternalAppHandler> handler =
// work, such as closing a no-longer-needed window. (Bug 588255) new nsExternalAppHandler(nsnull, EmptyCString(), aWindowContext, fileName,
// nsExternalAppHandler * handler = new nsExternalAppHandler(nsnull, reason, aForceSave);
// EmptyCString(), if (!handler)
// aWindowContext, return NS_ERROR_OUT_OF_MEMORY;
// fileName,
// reason, childListener->SetHandler(handler);
// aForceSave);
// if (!handler)
// return NS_ERROR_OUT_OF_MEMORY;
//
// childListener->SetHandler(handler);
return NS_OK; return NS_OK;
} }
@ -1578,21 +1573,6 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
aChannel->GetURI(getter_AddRefs(mSourceUrl)); aChannel->GetURI(getter_AddRefs(mSourceUrl));
} }
rv = SetUpTempFile(aChannel);
if (NS_FAILED(rv)) {
mCanceled = PR_TRUE;
request->Cancel(rv);
nsAutoString path;
if (mTempFile)
mTempFile->GetPath(path);
SendStatusChange(kWriteError, rv, request, path);
return NS_OK;
}
// Extract mime type for later use below.
nsCAutoString MIMEType;
mMimeInfo->GetMIMEType(MIMEType);
// retarget all load notifications to our docloader instead of the original window's docloader... // retarget all load notifications to our docloader instead of the original window's docloader...
RetargetLoadNotifications(request); RetargetLoadNotifications(request);
@ -1613,6 +1593,22 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
// and it was opened specifically for the download // and it was opened specifically for the download
MaybeCloseWindow(); MaybeCloseWindow();
// At this point, the child process has done everything it can usefully do
// for OnStartRequest.
if (XRE_GetProcessType() == GeckoProcessType_Content)
return NS_OK;
rv = SetUpTempFile(aChannel);
if (NS_FAILED(rv)) {
mCanceled = PR_TRUE;
request->Cancel(rv);
nsAutoString path;
if (mTempFile)
mTempFile->GetPath(path);
SendStatusChange(kWriteError, rv, request, path);
return NS_OK;
}
nsCOMPtr<nsIEncodedChannel> encChannel = do_QueryInterface( aChannel ); nsCOMPtr<nsIEncodedChannel> encChannel = do_QueryInterface( aChannel );
if (encChannel) if (encChannel)
{ {
@ -1687,6 +1683,9 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
handlerSvc->Exists(mMimeInfo, &mimeTypeIsInDatastore); handlerSvc->Exists(mMimeInfo, &mimeTypeIsInDatastore);
if (!handlerSvc || !mimeTypeIsInDatastore) if (!handlerSvc || !mimeTypeIsInDatastore)
{ {
nsCAutoString MIMEType;
mMimeInfo->GetMIMEType(MIMEType);
if (!GetNeverAskFlagFromPref(NEVER_ASK_FOR_SAVE_TO_DISK_PREF, MIMEType.get())) if (!GetNeverAskFlagFromPref(NEVER_ASK_FOR_SAVE_TO_DISK_PREF, MIMEType.get()))
{ {
// Don't need to ask after all. // Don't need to ask after all.