LCOV - code coverage report
Current view: top level - toolkit/components/telemetry - HangReports.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 6 16.7 %
Date: 2017-07-14 16:53:18 Functions: 1 4 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*-  Mode: C++; tab-width: 2; 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 HangReports_h__
       7             : #define HangReports_h__
       8             : 
       9             : #include <vector>
      10             : #include "mozilla/HangAnnotations.h"
      11             : #include "ProcessedStack.h"
      12             : #include "nsTArray.h"
      13             : #include "nsString.h"
      14             : #include "nsClassHashtable.h"
      15             : #include "CombinedStacks.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace Telemetry {
      19             : 
      20             : nsresult
      21             : ComputeAnnotationsKey(const HangMonitor::HangAnnotationsPtr& aAnnotations, nsAString& aKeyOut);
      22             : 
      23           3 : class HangReports {
      24             : public:
      25             :   /**
      26             :    * This struct encapsulates information for an individual ChromeHang annotation.
      27             :    * mHangIndex is the index of the corresponding ChromeHang.
      28             :    */
      29             :   struct AnnotationInfo {
      30           0 :     AnnotationInfo(uint32_t aHangIndex,
      31             :                    HangMonitor::HangAnnotationsPtr aAnnotations)
      32           0 :       : mAnnotations(Move(aAnnotations))
      33             :     {
      34           0 :       mHangIndices.AppendElement(aHangIndex);
      35           0 :     }
      36             :     AnnotationInfo(AnnotationInfo&& aOther)
      37             :       : mHangIndices(aOther.mHangIndices)
      38             :       , mAnnotations(Move(aOther.mAnnotations))
      39             :     {}
      40           0 :     ~AnnotationInfo() = default;
      41             :     AnnotationInfo& operator=(AnnotationInfo&& aOther)
      42             :     {
      43             :       mHangIndices = aOther.mHangIndices;
      44             :       mAnnotations = Move(aOther.mAnnotations);
      45             :       return *this;
      46             :     }
      47             :     // To save memory, a single AnnotationInfo can be associated to multiple chrome
      48             :     // hangs. The following array holds the index of each related chrome hang.
      49             :     nsTArray<uint32_t> mHangIndices;
      50             :     HangMonitor::HangAnnotationsPtr mAnnotations;
      51             : 
      52             :   private:
      53             :     // Force move constructor
      54             :     AnnotationInfo(const AnnotationInfo& aOther) = delete;
      55             :     void operator=(const AnnotationInfo& aOther) = delete;
      56             :   };
      57             :   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
      58             : #if defined(MOZ_GECKO_PROFILER)
      59             :   void AddHang(const Telemetry::ProcessedStack& aStack, uint32_t aDuration,
      60             :                int32_t aSystemUptime, int32_t aFirefoxUptime,
      61             :                HangMonitor::HangAnnotationsPtr aAnnotations);
      62             :   void PruneStackReferences(const size_t aRemovedStackIndex);
      63             : #endif
      64             :   uint32_t GetDuration(unsigned aIndex) const;
      65             :   int32_t GetSystemUptime(unsigned aIndex) const;
      66             :   int32_t GetFirefoxUptime(unsigned aIndex) const;
      67             :   const nsClassHashtable<nsStringHashKey, AnnotationInfo>& GetAnnotationInfo() const;
      68             :   const CombinedStacks& GetStacks() const;
      69             : private:
      70             :   /**
      71             :    * This struct encapsulates the data for an individual ChromeHang, excluding
      72             :    * annotations.
      73             :    */
      74             :   struct HangInfo {
      75             :     // Hang duration (in seconds)
      76             :     uint32_t mDuration;
      77             :     // System uptime (in minutes) at the time of the hang
      78             :     int32_t mSystemUptime;
      79             :     // Firefox uptime (in minutes) at the time of the hang
      80             :     int32_t mFirefoxUptime;
      81             :   };
      82             :   std::vector<HangInfo> mHangInfo;
      83             :   nsClassHashtable<nsStringHashKey, AnnotationInfo> mAnnotationInfo;
      84             :   CombinedStacks mStacks;
      85             : };
      86             : 
      87             : } // namespace Telemetry
      88             : } // namespace mozilla
      89             : 
      90             : #endif // CombinedStacks_h__

Generated by: LCOV version 1.13