Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; 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 "mozilla/AutoProfilerLabel.h"
8 :
9 : namespace mozilla {
10 :
11 : static ProfilerLabelEnter sEnter = nullptr;
12 : static ProfilerLabelExit sExit = nullptr;
13 :
14 : void
15 3 : RegisterProfilerLabelEnterExit(ProfilerLabelEnter aEnter,
16 : ProfilerLabelExit aExit)
17 : {
18 3 : sEnter = aEnter;
19 3 : sExit = aExit;
20 3 : }
21 :
22 0 : AutoProfilerLabel::AutoProfilerLabel(const char* aLabel,
23 : const char* aDynamicString,
24 : uint32_t aLine
25 0 : MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
26 : {
27 0 : MOZ_GUARD_OBJECT_NOTIFIER_INIT;
28 :
29 0 : mPseudoStack = sEnter ? sEnter(aLabel, aDynamicString, this, aLine) : nullptr;
30 0 : }
31 :
32 0 : AutoProfilerLabel::~AutoProfilerLabel()
33 : {
34 0 : if (sExit && mPseudoStack) {
35 0 : sExit(mPseudoStack);
36 : }
37 0 : }
38 :
39 : } // namespace mozilla
40 :
|