Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/tools/profiler/gecko/nsProfiler.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef nsProfiler_h
8
#define nsProfiler_h
9
10
#include "nsIProfiler.h"
11
#include "nsIObserver.h"
12
#include "mozilla/Attributes.h"
13
#include "mozilla/Maybe.h"
14
#include "mozilla/MozPromise.h"
15
#include "mozilla/TimeStamp.h"
16
#include "nsServiceManagerUtils.h"
17
#include "ProfileJSONWriter.h"
18
19
class nsProfiler final : public nsIProfiler, public nsIObserver
20
{
21
public:
22
  nsProfiler();
23
24
  NS_DECL_ISUPPORTS
25
  NS_DECL_NSIOBSERVER
26
  NS_DECL_NSIPROFILER
27
28
  nsresult Init();
29
30
  static nsProfiler* GetOrCreate()
31
0
  {
32
0
    nsCOMPtr<nsIProfiler> iprofiler =
33
0
      do_GetService("@mozilla.org/tools/profiler;1");
34
0
    return static_cast<nsProfiler*>(iprofiler.get());
35
0
  }
36
37
  void GatheredOOPProfile(const nsACString& aProfile);
38
39
private:
40
  ~nsProfiler();
41
42
  typedef mozilla::MozPromise<nsCString, nsresult, false> GatheringPromise;
43
44
  RefPtr<GatheringPromise> StartGathering(double aSinceTime);
45
  void FinishGathering();
46
  void ResetGathering();
47
48
  void ClearExpiredExitProfiles();
49
50
  bool mLockedForPrivateBrowsing;
51
52
  struct ExitProfile {
53
    nsCString mJSON;
54
    uint64_t mBufferPositionAtGatherTime;
55
  };
56
57
  // These fields are all related to profile gathering.
58
  nsTArray<ExitProfile> mExitProfiles;
59
  mozilla::Maybe<mozilla::MozPromiseHolder<GatheringPromise>> mPromiseHolder;
60
  mozilla::Maybe<SpliceableChunkedJSONWriter> mWriter;
61
  uint32_t mPendingProfiles;
62
  bool mGathering;
63
};
64
65
#endif // nsProfiler_h
66