1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "ExternalHelperAppChild.h"
8 #include "nsIInputStream.h"
9 #include "nsIRequest.h"
10 #include "nsIResumableChannel.h"
11 #include "nsNetUtil.h"
16 NS_IMPL_ISUPPORTS2(ExternalHelperAppChild
,
20 ExternalHelperAppChild::ExternalHelperAppChild()
25 ExternalHelperAppChild::~ExternalHelperAppChild()
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 ExternalHelperAppChild::OnDataAvailable(nsIRequest
*request
,
35 nsIInputStream
*input
,
39 if (NS_FAILED(mStatus
))
43 nsresult rv
= NS_ReadInputStreamToString(input
, data
, count
);
47 if (!SendOnDataAvailable(data
, offset
, count
))
48 return NS_ERROR_UNEXPECTED
;
53 //////////////////////////////////////////////////////////////////////////////
55 //////////////////////////////////////////////////////////////////////////////
58 ExternalHelperAppChild::OnStartRequest(nsIRequest
*request
, nsISupports
*ctx
)
60 nsresult rv
= mHandler
->OnStartRequest(request
, ctx
);
61 NS_ENSURE_SUCCESS(rv
, NS_ERROR_UNEXPECTED
);
64 nsCOMPtr
<nsIResumableChannel
> resumable(do_QueryInterface(request
));
66 resumable
->GetEntityID(entityID
);
67 SendOnStartRequest(entityID
);
73 ExternalHelperAppChild::OnStopRequest(nsIRequest
*request
,
77 nsresult rv
= mHandler
->OnStopRequest(request
, ctx
, status
);
78 SendOnStopRequest(status
);
80 NS_ENSURE_SUCCESS(rv
, NS_ERROR_UNEXPECTED
);
86 ExternalHelperAppChild::RecvCancel(const nsresult
& aStatus
)
93 } // namespace mozilla