tor-browser

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

ClientSourceOpParent.cpp (1814B)


      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 "ClientSourceOpParent.h"
      8 
      9 #include "ClientSourceParent.h"
     10 
     11 namespace mozilla::dom {
     12 
     13 using mozilla::ipc::IPCResult;
     14 
     15 void ClientSourceOpParent::ActorDestroy(ActorDestroyReason aReason) {
     16  if (mPromise) {
     17    CopyableErrorResult rv;
     18    rv.ThrowAbortError("Client torn down");
     19    mPromise->Reject(rv, __func__);
     20    mPromise = nullptr;
     21  }
     22 }
     23 
     24 IPCResult ClientSourceOpParent::Recv__delete__(const ClientOpResult& aResult) {
     25  if (aResult.type() == ClientOpResult::TCopyableErrorResult &&
     26      aResult.get_CopyableErrorResult().Failed()) {
     27    // If a control message fails then clear the controller from
     28    // the ClientSourceParent.  We eagerly marked it controlled at
     29    // the start of the operation.
     30    if (mArgs.type() == ClientOpConstructorArgs::TClientControlledArgs) {
     31      auto source = static_cast<ClientSourceParent*>(Manager());
     32      if (source) {
     33        source->ClearController();
     34      }
     35    }
     36 
     37    mPromise->Reject(aResult.get_CopyableErrorResult(), __func__);
     38    mPromise = nullptr;
     39    return IPC_OK();
     40  }
     41 
     42  mPromise->Resolve(aResult, __func__);
     43  mPromise = nullptr;
     44  return IPC_OK();
     45 }
     46 
     47 ClientSourceOpParent::ClientSourceOpParent(ClientOpConstructorArgs&& aArgs,
     48                                           ClientOpPromise::Private* aPromise)
     49    : mArgs(std::move(aArgs)), mPromise(aPromise) {
     50  MOZ_DIAGNOSTIC_ASSERT(mPromise);
     51 }
     52 
     53 ClientSourceOpParent::~ClientSourceOpParent() {
     54  MOZ_DIAGNOSTIC_ASSERT(!mPromise);
     55 }
     56 
     57 }  // namespace mozilla::dom