1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
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/. */
8 #ifndef mozilla_net_NeckoTargetHolder_h
9 #define mozilla_net_NeckoTargetHolder_h
11 #include "nsIEventTarget.h"
12 #include "nsThreadUtils.h"
17 // A helper class that implements GetNeckoTarget(). Basically, all e10s child
18 // channels should inherit this class in order to get a labeled event target.
19 class NeckoTargetHolder
{
21 explicit NeckoTargetHolder(nsISerialEventTarget
* aNeckoTarget
)
22 : mNeckoTarget(aNeckoTarget
) {}
25 virtual ~NeckoTargetHolder() = default;
26 // Get event target for processing network events.
27 virtual already_AddRefed
<nsISerialEventTarget
> GetNeckoTarget();
28 // When |mNeckoTarget| is not null, use it to dispatch the runnable.
29 // Otherwise, dispatch the runnable to the main thread.
30 nsresult
Dispatch(already_AddRefed
<nsIRunnable
>&& aRunnable
,
31 uint32_t aDispatchFlags
= NS_DISPATCH_NORMAL
);
33 // EventTarget for labeling networking events.
34 nsCOMPtr
<nsISerialEventTarget
> mNeckoTarget
;
38 } // namespace mozilla