Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set sw=2 ts=8 et tw=80 : */
3 :
4 : /* This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 :
8 : #ifndef mozilla_net_HttpBackgroundChannelParent_h
9 : #define mozilla_net_HttpBackgroundChannelParent_h
10 :
11 : #include "mozilla/net/PHttpBackgroundChannelParent.h"
12 : #include "mozilla/Atomics.h"
13 : #include "nsID.h"
14 : #include "nsISupportsImpl.h"
15 :
16 : class nsIEventTarget;
17 :
18 : namespace mozilla {
19 : namespace net {
20 :
21 : class HttpChannelParent;
22 :
23 : class HttpBackgroundChannelParent final : public PHttpBackgroundChannelParent
24 : {
25 : public:
26 : explicit HttpBackgroundChannelParent();
27 :
28 70 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(HttpBackgroundChannelParent)
29 :
30 : // Try to find associated HttpChannelParent with the same
31 : // channel Id.
32 : nsresult Init(const uint64_t& aChannelId);
33 :
34 : // Callbacks for BackgroundChannelRegistrar to notify
35 : // the associated HttpChannelParent is found.
36 : void LinkToChannel(HttpChannelParent* aChannelParent);
37 :
38 : // Callbacks for HttpChannelParent to close the background
39 : // IPC channel.
40 : void OnChannelClosed();
41 :
42 : // To send OnStartRequestSend message over background channel.
43 : bool OnStartRequestSent();
44 :
45 : // To send OnTransportAndData message over background channel.
46 : bool OnTransportAndData(const nsresult& aChannelStatus,
47 : const nsresult& aTransportStatus,
48 : const uint64_t& aOffset,
49 : const uint32_t& aCount,
50 : const nsCString& aData);
51 :
52 : // To send OnStopRequest message over background channel.
53 : bool OnStopRequest(const nsresult& aChannelStatus,
54 : const ResourceTimingStruct& aTiming);
55 :
56 : // To send OnProgress message over background channel.
57 : bool OnProgress(const int64_t& aProgress,
58 : const int64_t& aProgressMax);
59 :
60 : // To send OnStatus message over background channel.
61 : bool OnStatus(const nsresult& aStatus);
62 :
63 : // To send FlushedForDiversion and DivertMessages messages
64 : // over background channel.
65 : bool OnDiversion();
66 :
67 : // To send NotifyTrackingProtectionDisabled message over background channel.
68 : bool OnNotifyTrackingProtectionDisabled();
69 :
70 : // To send NotifyTrackingResource message over background channel.
71 : bool OnNotifyTrackingResource();
72 :
73 : // To send SetClassifierMatchedInfo message over background channel.
74 : bool OnSetClassifierMatchedInfo(const nsACString& aList,
75 : const nsACString& aProvider,
76 : const nsACString& aPrefix);
77 :
78 : protected:
79 : void ActorDestroy(ActorDestroyReason aWhy) override;
80 :
81 : private:
82 : virtual ~HttpBackgroundChannelParent();
83 :
84 : Atomic<bool> mIPCOpened;
85 :
86 : nsCOMPtr<nsIEventTarget> mBackgroundThread;
87 :
88 : // associated HttpChannelParent for generating the channel events
89 : RefPtr<HttpChannelParent> mChannelParent;
90 : };
91 :
92 : } // namespace net
93 : } // namespace mozilla
94 :
95 : #endif // mozilla_net_HttpBackgroundChannelParent_h
|