tor-browser

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

ClientManagerOpChild.cpp (1651B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "ClientManagerOpChild.h"
      8 
      9 #include "mozilla/dom/ClientManager.h"
     10 #include "mozilla/ipc/ProtocolUtils.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 void ClientManagerOpChild::ActorDestroy(ActorDestroyReason aReason) {
     15  mClientManager = nullptr;
     16  if (mPromise) {
     17    CopyableErrorResult rv;
     18    rv.ThrowAbortError("Client aborted");
     19    mPromise->Reject(rv, __func__);
     20    mPromise = nullptr;
     21  }
     22 }
     23 
     24 mozilla::ipc::IPCResult ClientManagerOpChild::Recv__delete__(
     25    const ClientOpResult& aResult) {
     26  mClientManager = nullptr;
     27  if (aResult.type() == ClientOpResult::TCopyableErrorResult &&
     28      aResult.get_CopyableErrorResult().Failed()) {
     29    mPromise->Reject(aResult.get_CopyableErrorResult(), __func__);
     30    mPromise = nullptr;
     31    return IPC_OK();
     32  }
     33  mPromise->Resolve(aResult, __func__);
     34  mPromise = nullptr;
     35  return IPC_OK();
     36 }
     37 
     38 ClientManagerOpChild::ClientManagerOpChild(ClientManager* aClientManager,
     39                                           const ClientOpConstructorArgs& aArgs,
     40                                           ClientOpPromise::Private* aPromise)
     41    : mClientManager(aClientManager), mPromise(aPromise) {
     42  MOZ_DIAGNOSTIC_ASSERT(mClientManager);
     43  MOZ_DIAGNOSTIC_ASSERT(mPromise);
     44 }
     45 
     46 ClientManagerOpChild::~ClientManagerOpChild() {
     47  MOZ_DIAGNOSTIC_ASSERT(!mPromise);
     48 }
     49 
     50 }  // namespace mozilla::dom