tor-browser

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

BackgroundThreadObject.cpp (1172B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "BackgroundThreadObject.h"
      8 
      9 #include "mozilla/ipc/BackgroundParent.h"
     10 #include "nsThreadUtils.h"
     11 
     12 namespace mozilla::dom::quota {
     13 
     14 BackgroundThreadObject::BackgroundThreadObject()
     15    : mOwningThread(GetCurrentSerialEventTarget()) {
     16  AssertIsOnOwningThread();
     17 }
     18 
     19 BackgroundThreadObject::BackgroundThreadObject(
     20    nsISerialEventTarget* aOwningThread)
     21    : mOwningThread(aOwningThread) {}
     22 
     23 #ifdef DEBUG
     24 
     25 void BackgroundThreadObject::AssertIsOnOwningThread() const {
     26  mozilla::ipc::AssertIsOnBackgroundThread();
     27  MOZ_ASSERT(mOwningThread);
     28  bool current;
     29  MOZ_ASSERT(NS_SUCCEEDED(mOwningThread->IsOnCurrentThread(&current)));
     30  MOZ_ASSERT(current);
     31 }
     32 
     33 #endif  // DEBUG
     34 
     35 nsISerialEventTarget* BackgroundThreadObject::OwningThread() const {
     36  MOZ_ASSERT(mOwningThread);
     37  return mOwningThread;
     38 }
     39 
     40 }  // namespace mozilla::dom::quota