/src/mozilla-central/docshell/base/timeline/AutoTimelineMarker.cpp
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 | | #include "AutoTimelineMarker.h" |
8 | | |
9 | | #include "TimelineConsumers.h" |
10 | | #include "MainThreadUtils.h" |
11 | | |
12 | | namespace mozilla { |
13 | | |
14 | | AutoTimelineMarker::AutoTimelineMarker(nsIDocShell* aDocShell, const char* aName |
15 | | MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) |
16 | | : mName(aName) |
17 | | , mDocShell(nullptr) |
18 | 0 | { |
19 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
20 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
21 | 0 |
|
22 | 0 | if (!aDocShell) { |
23 | 0 | return; |
24 | 0 | } |
25 | 0 | |
26 | 0 | RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get(); |
27 | 0 | if (!timelines || !timelines->HasConsumer(aDocShell)) { |
28 | 0 | return; |
29 | 0 | } |
30 | 0 | |
31 | 0 | mDocShell = aDocShell; |
32 | 0 | timelines->AddMarkerForDocShell(mDocShell, mName, MarkerTracingType::START); |
33 | 0 | } |
34 | | |
35 | | AutoTimelineMarker::~AutoTimelineMarker() |
36 | 0 | { |
37 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
38 | 0 |
|
39 | 0 | if (!mDocShell) { |
40 | 0 | return; |
41 | 0 | } |
42 | 0 | |
43 | 0 | RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get(); |
44 | 0 | if (!timelines || !timelines->HasConsumer(mDocShell)) { |
45 | 0 | return; |
46 | 0 | } |
47 | 0 | |
48 | 0 | timelines->AddMarkerForDocShell(mDocShell, mName, MarkerTracingType::END); |
49 | 0 | } |
50 | | |
51 | | } // namespace mozilla |