1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_ViaductRequest_h
6 #define mozilla_ViaductRequest_h
8 #include "mozilla/Monitor.h"
9 #include "mozilla/fetch_msg_types.pb.h"
10 #include "mozilla/Viaduct.h"
13 #include "nsIChannel.h"
14 #include "nsIChannelEventSink.h"
15 #include "nsIStreamListener.h"
20 // A mapping of the ByteBuffer repr(C) Rust struct.
21 struct ViaductByteBuffer
{
26 class ViaductRequest final
: public nsIStreamListener
,
27 public nsITimerCallback
,
29 public nsIChannelEventSink
{
31 NS_DECL_THREADSAFE_ISUPPORTS
32 NS_DECL_NSIREQUESTOBSERVER
33 NS_DECL_NSISTREAMLISTENER
34 NS_DECL_NSITIMERCALLBACK
36 NS_DECL_NSICHANNELEVENTSINK
39 : mDone(false), mChannel(nullptr), mMonitor("ViaductRequest") {}
40 ViaductByteBuffer
MakeRequest(ViaductByteBuffer reqBuf
);
43 nsresult
LaunchRequest(appservices::httpconfig::protobuf::Request
&);
47 nsCOMPtr
<nsIChannel
> mChannel
;
48 nsCString mBodyBuffer
;
49 nsCOMPtr
<nsITimer
> mConnectTimeoutTimer
;
50 nsCOMPtr
<nsITimer
> mReadTimeoutTimer
;
51 appservices::httpconfig::protobuf::Response mResponse
;
52 Monitor mMonitor MOZ_UNANNOTATED
;
56 }; // namespace mozilla
58 #endif // mozilla_ViaductRequest_h