2015-07-17 22:51:39 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-10-22 00:10:05 +03:00
|
|
|
#include "AutoGlobalTimelineMarker.h"
|
2015-07-17 22:51:39 +03:00
|
|
|
|
2015-08-25 08:51:58 +03:00
|
|
|
#include "TimelineConsumers.h"
|
2015-07-17 22:51:39 +03:00
|
|
|
#include "MainThreadUtils.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-11-23 18:50:56 +03:00
|
|
|
AutoGlobalTimelineMarker::AutoGlobalTimelineMarker(
|
|
|
|
const char* aName, MarkerStackRequest aStackRequest /* = STACK */
|
2020-07-30 17:22:38 +03:00
|
|
|
)
|
2015-11-23 18:50:56 +03:00
|
|
|
: mName(aName), mStackRequest(aStackRequest) {
|
2015-07-17 22:51:39 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2015-10-22 00:10:05 +03:00
|
|
|
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
|
|
|
if (!timelines || timelines->IsEmpty()) {
|
2015-07-17 22:51:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-23 18:50:56 +03:00
|
|
|
timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::START,
|
|
|
|
mStackRequest);
|
2015-07-17 22:51:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
AutoGlobalTimelineMarker::~AutoGlobalTimelineMarker() {
|
2015-10-22 00:10:05 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
|
|
|
if (!timelines || timelines->IsEmpty()) {
|
2015-07-17 22:51:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-23 18:50:56 +03:00
|
|
|
timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::END,
|
|
|
|
mStackRequest);
|
2015-07-17 22:51:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|