tor-browser

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

ClientHandleChild.cpp (1974B)


      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 "ClientHandleChild.h"
      8 
      9 #include "ClientHandle.h"
     10 #include "ClientHandleOpChild.h"
     11 #include "mozilla/dom/ClientIPCTypes.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 using mozilla::ipc::IPCResult;
     16 
     17 IPCResult ClientHandleChild::RecvExecutionReady(
     18    const IPCClientInfo& aClientInfo) {
     19  if (mHandle) {
     20    mHandle->ExecutionReady(ClientInfo(aClientInfo));
     21  }
     22  return IPC_OK();
     23 }
     24 
     25 void ClientHandleChild::ActorDestroy(ActorDestroyReason aReason) {
     26  if (mHandle) {
     27    mHandle->RevokeActor(this);
     28 
     29    // Revoking the actor link should automatically cause the owner
     30    // to call RevokeOwner() as well.
     31    MOZ_DIAGNOSTIC_ASSERT(!mHandle);
     32  }
     33 }
     34 
     35 PClientHandleOpChild* ClientHandleChild::AllocPClientHandleOpChild(
     36    const ClientOpConstructorArgs& aArgs) {
     37  MOZ_ASSERT_UNREACHABLE("ClientHandleOpChild must be explicitly constructed.");
     38  return nullptr;
     39 }
     40 
     41 bool ClientHandleChild::DeallocPClientHandleOpChild(
     42    PClientHandleOpChild* aActor) {
     43  delete aActor;
     44  return true;
     45 }
     46 
     47 ClientHandleChild::ClientHandleChild()
     48    : mHandle(nullptr), mTeardownStarted(false) {}
     49 
     50 void ClientHandleChild::SetOwner(ClientThing<ClientHandleChild>* aThing) {
     51  MOZ_DIAGNOSTIC_ASSERT(!mHandle);
     52  mHandle = static_cast<ClientHandle*>(aThing);
     53  MOZ_DIAGNOSTIC_ASSERT(mHandle);
     54 }
     55 
     56 void ClientHandleChild::RevokeOwner(ClientThing<ClientHandleChild>* aThing) {
     57  MOZ_DIAGNOSTIC_ASSERT(mHandle);
     58  MOZ_DIAGNOSTIC_ASSERT(mHandle == static_cast<ClientHandle*>(aThing));
     59  mHandle = nullptr;
     60 }
     61 
     62 void ClientHandleChild::MaybeStartTeardown() {
     63  if (mTeardownStarted) {
     64    return;
     65  }
     66  mTeardownStarted = true;
     67  (void)SendTeardown();
     68 }
     69 
     70 }  // namespace mozilla::dom