tor-browser

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

IPDLUnitTestParent.h (1646B)


      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 #ifndef mozilla__ipdltest_IPDLUnitTestParent_h
      8 #define mozilla__ipdltest_IPDLUnitTestParent_h
      9 
     10 #include "mozilla/_ipdltest/PIPDLUnitTestParent.h"
     11 #include "mozilla/ipc/GeckoChildProcessHost.h"
     12 #include "nsISupportsImpl.h"
     13 
     14 namespace mozilla::_ipdltest {
     15 
     16 class IPDLUnitTestParent : public PIPDLUnitTestParent {
     17 public:
     18  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(IPDLUnitTestParent, override)
     19 
     20  static already_AddRefed<IPDLUnitTestParent> CreateCrossProcess();
     21  static already_AddRefed<IPDLUnitTestParent> CreateCrossThread();
     22 
     23  // Try to start a connection with the given name and open `aParentActor` with
     24  // it. Fails the current test and returns false on failure.
     25  bool Start(const char* aName, IToplevelProtocol* aParentActor);
     26 
     27  bool ReportedComplete() const { return mComplete; }
     28 
     29 private:
     30  friend class PIPDLUnitTestParent;
     31 
     32  ipc::IPCResult RecvReport(const TestPartResult& aResult);
     33  ipc::IPCResult RecvComplete();
     34 
     35  void KillHard();
     36 
     37  ~IPDLUnitTestParent();
     38 
     39  // Only one of these two will be set depending.
     40  nsCOMPtr<nsIThread> mOtherThread;
     41  mozilla::ipc::GeckoChildProcessHost* mSubprocess = nullptr;
     42 
     43  // Set to true when the test is complete.
     44  bool mComplete = false;
     45  bool mCalledKillHard = false;
     46 };
     47 
     48 }  // namespace mozilla::_ipdltest
     49 
     50 #endif  // mozilla__ipdltest_IPDLUnitTestParent_h