LCOV - code coverage report
Current view: top level - tools/profiler/gecko - ProfilerChild.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 4 43 9.3 %
Date: 2017-07-14 16:53:18 Functions: 1 12 8.3 %
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=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 "GeckoProfiler.h"
       8             : #include "ProfilerChild.h"
       9             : #include "nsThreadUtils.h"
      10             : 
      11             : namespace mozilla {
      12             : 
      13           2 : ProfilerChild::ProfilerChild()
      14             :   : mThread(NS_GetCurrentThread())
      15           2 :   , mDestroyed(false)
      16             : {
      17           2 :   MOZ_COUNT_CTOR(ProfilerChild);
      18           2 : }
      19             : 
      20           0 : ProfilerChild::~ProfilerChild()
      21             : {
      22           0 :   MOZ_COUNT_DTOR(ProfilerChild);
      23           0 : }
      24             : 
      25             : mozilla::ipc::IPCResult
      26           0 : ProfilerChild::RecvStart(const ProfilerInitParams& params)
      27             : {
      28           0 :   nsTArray<const char*> filterArray;
      29           0 :   for (size_t i = 0; i < params.filters().Length(); ++i) {
      30           0 :     filterArray.AppendElement(params.filters()[i].get());
      31             :   }
      32             : 
      33           0 :   profiler_start(params.entries(), params.interval(),
      34           0 :                  params.features(),
      35             :                  filterArray.Elements(),
      36           0 :                  filterArray.Length());
      37             : 
      38           0 :   return IPC_OK();
      39             : }
      40             : 
      41             : mozilla::ipc::IPCResult
      42           0 : ProfilerChild::RecvStop()
      43             : {
      44           0 :   profiler_stop();
      45           0 :   return IPC_OK();
      46             : }
      47             : 
      48             : mozilla::ipc::IPCResult
      49           0 : ProfilerChild::RecvPause()
      50             : {
      51           0 :   profiler_pause();
      52           0 :   return IPC_OK();
      53             : }
      54             : 
      55             : mozilla::ipc::IPCResult
      56           0 : ProfilerChild::RecvResume()
      57             : {
      58           0 :   profiler_resume();
      59           0 :   return IPC_OK();
      60             : }
      61             : 
      62             : static nsCString
      63           0 : CollectProfileOrEmptyString()
      64             : {
      65           0 :   nsCString profileCString;
      66           0 :   UniquePtr<char[]> profile = profiler_get_profile();
      67           0 :   if (profile) {
      68           0 :     profileCString = nsCString(profile.get(), strlen(profile.get()));
      69             :   } else {
      70           0 :     profileCString = EmptyCString();
      71             :   }
      72           0 :   return profileCString;
      73             : }
      74             : 
      75             : mozilla::ipc::IPCResult
      76           0 : ProfilerChild::RecvGatherProfile(GatherProfileResolver&& aResolve)
      77             : {
      78           0 :   aResolve(CollectProfileOrEmptyString());
      79           0 :   return IPC_OK();
      80             : }
      81             : 
      82             : void
      83           0 : ProfilerChild::ActorDestroy(ActorDestroyReason aActorDestroyReason)
      84             : {
      85           0 :   mDestroyed = true;
      86           0 : }
      87             : 
      88             : void
      89           0 : ProfilerChild::Destroy()
      90             : {
      91           0 :   if (!mDestroyed) {
      92           0 :     Close();
      93             :   }
      94           0 : }
      95             : 
      96             : nsCString
      97           0 : ProfilerChild::GrabShutdownProfile()
      98             : {
      99           0 :   return CollectProfileOrEmptyString();
     100             : }
     101             : 
     102             : } // namespace mozilla

Generated by: LCOV version 1.13