/work/obj-fuzz/dist/include/mozilla/net/NeckoTargetHolder.h
Line | Count | Source (jump to first uncovered line) |
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_NeckoTargetHolder_h |
9 | | #define mozilla_net_NeckoTargetHolder_h |
10 | | |
11 | | #include "nsIEventTarget.h" |
12 | | #include "nsThreadUtils.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace net { |
16 | | |
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 |
20 | | { |
21 | | public: |
22 | | explicit NeckoTargetHolder(nsIEventTarget *aNeckoTarget) |
23 | | : mNeckoTarget(aNeckoTarget) |
24 | 0 | {} |
25 | | |
26 | | protected: |
27 | 0 | virtual ~NeckoTargetHolder() = default; |
28 | | // Get event target for processing network events. |
29 | | virtual already_AddRefed<nsIEventTarget> GetNeckoTarget(); |
30 | | // When |mNeckoTarget| is not null, use it to dispatch the runnable. |
31 | | // Otherwise, dispatch the runnable to the main thread. |
32 | | nsresult Dispatch(already_AddRefed<nsIRunnable>&& aRunnable, |
33 | | uint32_t aDispatchFlags = NS_DISPATCH_NORMAL); |
34 | | |
35 | | // EventTarget for labeling networking events. |
36 | | nsCOMPtr<nsIEventTarget> mNeckoTarget; |
37 | | }; |
38 | | |
39 | | } // namespace net |
40 | | } // namespace mozilla |
41 | | |
42 | | #endif |