LCOV - code coverage report
Current view: top level - gfx/layers - IPDLActor.h (source / functions) Hit Total Coverage
Test: output.info Lines: 14 15 93.3 %
Date: 2017-07-14 16:53:18 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef MOZILLA_LAYERS_IPDLACTOR_H
       7             : #define MOZILLA_LAYERS_IPDLACTOR_H
       8             : 
       9             : #include "mozilla/ipc/ProtocolUtils.h"
      10             : #include "mozilla/layers/CompositableForwarder.h"
      11             : #include "mozilla/Unused.h"
      12             : #include "gfxPlatform.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace layers {
      16             : 
      17             : /// A base class to facilitate the deallocation of IPDL actors.
      18             : ///
      19             : /// Implements the parent side of the simple deallocation handshake.
      20             : /// Override the Destroy method rather than the ActorDestroy method.
      21             : template<typename Protocol>
      22             : class ParentActor : public Protocol
      23             : {
      24             : public:
      25           9 :   ParentActor() : mDestroyed(false) {}
      26             : 
      27           6 :   ~ParentActor() { MOZ_ASSERT(mDestroyed); }
      28             : 
      29             :   bool CanSend() const { return !mDestroyed; }
      30             : 
      31             :   // Override this rather than ActorDestroy
      32           0 :   virtual void Destroy() {}
      33             : 
      34           6 :   virtual mozilla::ipc::IPCResult RecvDestroy() override
      35             :   {
      36           6 :     DestroyIfNeeded();
      37           6 :     Unused << Protocol::Send__delete__(this);
      38           6 :     return IPC_OK();
      39             :   }
      40             : 
      41             :   typedef ipc::IProtocol::ActorDestroyReason Why;
      42             : 
      43           6 :   virtual void ActorDestroy(Why) override {
      44           6 :     DestroyIfNeeded();
      45           6 :   }
      46             : 
      47             : protected:
      48          12 :   void DestroyIfNeeded() {
      49          12 :     if (!mDestroyed) {
      50           6 :       Destroy();
      51           6 :       mDestroyed = true;
      52             :     }
      53          12 :   }
      54             : 
      55             : private:
      56             :   bool mDestroyed;
      57             : };
      58             : 
      59             : } // namespace
      60             : } // namespace
      61             : 
      62             : #endif

Generated by: LCOV version 1.13