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 "AutoGlobalTimelineMarker.h"
8 :
9 : #include "TimelineConsumers.h"
10 : #include "MainThreadUtils.h"
11 :
12 : namespace mozilla {
13 :
14 0 : AutoGlobalTimelineMarker::AutoGlobalTimelineMarker(const char* aName,
15 : MarkerStackRequest aStackRequest /* = STACK */
16 0 : MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
17 : : mName(aName)
18 0 : , mStackRequest(aStackRequest)
19 : {
20 0 : MOZ_GUARD_OBJECT_NOTIFIER_INIT;
21 0 : MOZ_ASSERT(NS_IsMainThread());
22 :
23 0 : RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
24 0 : if (!timelines || timelines->IsEmpty()) {
25 0 : return;
26 : }
27 :
28 0 : timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::START, mStackRequest);
29 : }
30 :
31 0 : AutoGlobalTimelineMarker::~AutoGlobalTimelineMarker()
32 : {
33 0 : MOZ_ASSERT(NS_IsMainThread());
34 :
35 0 : RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
36 0 : if (!timelines || timelines->IsEmpty()) {
37 0 : return;
38 : }
39 :
40 0 : timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::END, mStackRequest);
41 0 : }
42 :
43 : } // namespace mozilla
|