LCOV - code coverage report
Current view: top level - gfx/layers/ipc - LayerTreeOwnerTracker.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 18 31 58.1 %
Date: 2017-07-14 16:53:18 Functions: 5 8 62.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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=99: */
       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 "LayerTreeOwnerTracker.h"
       8             : 
       9             : #include "mozilla/StaticPtr.h"              // for StaticAutoPtr
      10             : #include "mozilla/dom/ContentParent.h"      // for ContentParent
      11             : #include "mozilla/gfx/GPUChild.h"           // for GPUChild
      12             : #include "mozilla/gfx/GPUProcessManager.h"  // for GPUProcessManager
      13             : 
      14             : #include <functional>
      15             : #include <utility> // for std::make_pair
      16             : 
      17             : namespace mozilla {
      18             : namespace layers {
      19             : 
      20           3 : static StaticAutoPtr<LayerTreeOwnerTracker> sSingleton;
      21             : 
      22           1 : LayerTreeOwnerTracker::LayerTreeOwnerTracker() :
      23           1 :   mLayerIdsLock("LayerTreeOwnerTrackerLock")
      24             : {
      25           1 : }
      26             : 
      27             : void
      28           1 : LayerTreeOwnerTracker::Initialize()
      29             : {
      30           1 :   MOZ_ASSERT(!sSingleton);
      31           1 :   sSingleton = new LayerTreeOwnerTracker();
      32           1 : }
      33             : 
      34             : void
      35           0 : LayerTreeOwnerTracker::Shutdown()
      36             : {
      37           0 :   sSingleton = nullptr;
      38           0 : }
      39             : 
      40             : LayerTreeOwnerTracker*
      41           4 : LayerTreeOwnerTracker::Get()
      42             : {
      43           4 :   return sSingleton;
      44             : }
      45             : 
      46             : void
      47           1 : LayerTreeOwnerTracker::Map(uint64_t aLayersId, base::ProcessId aProcessId)
      48             : {
      49           2 :   MutexAutoLock lock(mLayerIdsLock);
      50             : 
      51             :   // Add the mapping to the list
      52           1 :   mLayerIds[aLayersId] = aProcessId;
      53           1 : }
      54             : 
      55             : void
      56           0 : LayerTreeOwnerTracker::Unmap(uint64_t aLayersId, base::ProcessId aProcessId)
      57             : {
      58           0 :   MutexAutoLock lock(mLayerIdsLock);
      59             : 
      60           0 :   MOZ_ASSERT(mLayerIds[aLayersId] == aProcessId);
      61           0 :   mLayerIds.erase(aLayersId);
      62           0 : }
      63             : 
      64             : bool
      65           3 : LayerTreeOwnerTracker::IsMapped(uint64_t aLayersId, base::ProcessId aProcessId)
      66             : {
      67           6 :   MutexAutoLock lock(mLayerIdsLock);
      68             : 
      69           3 :   auto iter = mLayerIds.find(aLayersId);
      70           6 :   return iter != mLayerIds.end() && iter->second == aProcessId;
      71             : }
      72             : 
      73             : void
      74           0 : LayerTreeOwnerTracker::Iterate(const std::function<void(uint64_t aLayersId, base::ProcessId aProcessId)>& aCallback)
      75             : {
      76           0 :   MutexAutoLock lock(mLayerIdsLock);
      77             : 
      78           0 :   for (const auto& iter : mLayerIds) {
      79           0 :     aCallback(iter.first, iter.second);
      80             :   }
      81           0 : }
      82             : 
      83             : } // namespace layers
      84             : } // namespace mozilla

Generated by: LCOV version 1.13