1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=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 #ifndef mozilla_dom_ChildProcessChannelListener_h
8 #define mozilla_dom_ChildProcessChannelListener_h
12 #include "mozilla/extensions/StreamFilterParent.h"
13 #include "mozilla/net/NeckoChannelParams.h"
14 #include "nsDOMNavigationTiming.h"
15 #include "nsTHashMap.h"
16 #include "nsIChannel.h"
17 #include "mozilla/ipc/BackgroundUtils.h"
19 namespace mozilla::dom
{
21 class ChildProcessChannelListener final
{
22 NS_INLINE_DECL_REFCOUNTING(ChildProcessChannelListener
)
24 using Endpoint
= mozilla::ipc::Endpoint
<extensions::PStreamFilterParent
>;
25 using Resolver
= std::function
<void(const nsresult
&)>;
26 using Callback
= std::function
<nsresult(
27 nsDocShellLoadState
*, nsTArray
<Endpoint
>&&, nsDOMNavigationTiming
*)>;
29 void RegisterCallback(uint64_t aIdentifier
, Callback
&& aCallback
);
31 void OnChannelReady(nsDocShellLoadState
* aLoadState
, uint64_t aIdentifier
,
32 nsTArray
<Endpoint
>&& aStreamFilterEndpoints
,
33 nsDOMNavigationTiming
* aTiming
, Resolver
&& aResolver
);
35 static already_AddRefed
<ChildProcessChannelListener
> GetSingleton();
38 ChildProcessChannelListener() = default;
39 ~ChildProcessChannelListener();
41 RefPtr
<nsDocShellLoadState
> mLoadState
;
42 nsTArray
<Endpoint
> mStreamFilterEndpoints
;
43 RefPtr
<nsDOMNavigationTiming
> mTiming
;
48 nsTHashMap
<nsUint64HashKey
, Callback
> mCallbacks
;
49 nsTHashMap
<nsUint64HashKey
, CallbackArgs
> mChannelArgs
;
52 } // namespace mozilla::dom
54 #endif // !defined(mozilla_dom_ChildProcessChannelListener_h)