Bug 1885565 - Part 1: Add mozac_ic_avatar_circle_24 to ui-icons r=android-reviewers...
[gecko.git] / toolkit / components / viaduct / ViaductRequest.h
blob8e5963c236c3e4040721e00b6fa9e015bb6f23be
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"
12 #include "nsCOMPtr.h"
13 #include "nsIChannel.h"
14 #include "nsIChannelEventSink.h"
15 #include "nsIStreamListener.h"
16 #include "nsITimer.h"
18 namespace mozilla {
20 // A mapping of the ByteBuffer repr(C) Rust struct.
21 struct ViaductByteBuffer {
22 int64_t len;
23 uint8_t* data;
26 class ViaductRequest final : public nsIStreamListener,
27 public nsITimerCallback,
28 public nsINamed,
29 public nsIChannelEventSink {
30 public:
31 NS_DECL_THREADSAFE_ISUPPORTS
32 NS_DECL_NSIREQUESTOBSERVER
33 NS_DECL_NSISTREAMLISTENER
34 NS_DECL_NSITIMERCALLBACK
35 NS_DECL_NSINAMED
36 NS_DECL_NSICHANNELEVENTSINK
38 ViaductRequest()
39 : mDone(false), mChannel(nullptr), mMonitor("ViaductRequest") {}
40 ViaductByteBuffer MakeRequest(ViaductByteBuffer reqBuf);
42 private:
43 nsresult LaunchRequest(appservices::httpconfig::protobuf::Request&);
44 void ClearTimers();
45 void NotifyMonitor();
46 bool mDone;
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;
53 ~ViaductRequest();
56 }; // namespace mozilla
58 #endif // mozilla_ViaductRequest_h