Bug 1873666 [wpt PR 43897] - Add VideoTrackGenerator IDL tests, a=testonly
[gecko.git] / netwerk / ipc / NeckoTargetHolder.cpp
blob90d80ce7d50a565da3d6e73bbc1d67061dc7fdd3
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 #include "NeckoTargetHolder.h"
10 #include "nsContentUtils.h"
12 namespace mozilla {
13 namespace net {
15 already_AddRefed<nsISerialEventTarget> NeckoTargetHolder::GetNeckoTarget() {
16 nsCOMPtr<nsISerialEventTarget> target = mNeckoTarget;
18 if (!target) {
19 target = GetMainThreadSerialEventTarget();
21 return target.forget();
24 nsresult NeckoTargetHolder::Dispatch(already_AddRefed<nsIRunnable>&& aRunnable,
25 uint32_t aDispatchFlags) {
26 if (mNeckoTarget) {
27 return mNeckoTarget->Dispatch(std::move(aRunnable), aDispatchFlags);
30 nsCOMPtr<nsISerialEventTarget> mainThreadTarget =
31 GetMainThreadSerialEventTarget();
32 MOZ_ASSERT(mainThreadTarget);
34 return mainThreadTarget->Dispatch(std::move(aRunnable), aDispatchFlags);
37 } // namespace net
38 } // namespace mozilla