tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

NeckoTargetHolder.cpp (1136B)


      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 #include "NeckoTargetHolder.h"
      9 
     10 #include "nsContentUtils.h"
     11 
     12 namespace mozilla {
     13 namespace net {
     14 
     15 already_AddRefed<nsISerialEventTarget> NeckoTargetHolder::GetNeckoTarget() {
     16  nsCOMPtr<nsISerialEventTarget> target = mNeckoTarget;
     17 
     18  if (!target) {
     19    target = GetMainThreadSerialEventTarget();
     20  }
     21  return target.forget();
     22 }
     23 
     24 nsresult NeckoTargetHolder::Dispatch(
     25    already_AddRefed<nsIRunnable>&& aRunnable,
     26    nsIEventTarget::DispatchFlags aDispatchFlags) {
     27  if (mNeckoTarget) {
     28    return mNeckoTarget->Dispatch(std::move(aRunnable), aDispatchFlags);
     29  }
     30 
     31  nsCOMPtr<nsISerialEventTarget> mainThreadTarget =
     32      GetMainThreadSerialEventTarget();
     33  MOZ_ASSERT(mainThreadTarget);
     34 
     35  return mainThreadTarget->Dispatch(std::move(aRunnable), aDispatchFlags);
     36 }
     37 
     38 }  // namespace net
     39 }  // namespace mozilla