Bug 1578329 - Use profiler_can_accept_markers() where appropriate - r=gregtatum

In places where profiler_is_active() was used around a profiler_add_marker() (or
similar) call, replace it with profiler_can_accept_markers().

Differential Revision: https://phabricator.services.mozilla.com/D44435

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2019-09-18 01:22:12 +00:00
parent 738f482766
commit dc8ac83ba6
15 changed files with 30 additions and 31 deletions

View File

@ -142,7 +142,7 @@ void TimeoutManager::MoveIdleToActive() {
timeout->remove();
mTimeouts.InsertFront(timeout);
#if MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
if (num == 0) {
now = TimeStamp::Now();
}
@ -891,7 +891,7 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow,
// This timeout is good to run.
bool timeout_was_cleared = window->RunTimeoutHandler(timeout, scx);
#if MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
TimeDuration elapsed = now - timeout->SubmitTime();
TimeDuration target = timeout->When() - timeout->SubmitTime();
TimeDuration delta = now - timeout->When();

View File

@ -153,7 +153,7 @@ void nsDOMNavigationTiming::NotifyLoadEventEnd() {
if (IsTopLevelContentDocumentInContentProcess()) {
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active() || PAGELOAD_LOG_ENABLED()) {
if (profiler_can_accept_markers() || PAGELOAD_LOG_ENABLED()) {
TimeDuration elapsed = mLoadEventEnd - mNavigationStart;
TimeDuration duration = mLoadEventEnd - mLoadEventStart;
nsAutoCString spec;
@ -345,7 +345,7 @@ void nsDOMNavigationTiming::TTITimeout(nsITimer* aTimer) {
mTTITimer = nullptr;
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active() || PAGELOAD_LOG_ENABLED()) {
if (profiler_can_accept_markers() || PAGELOAD_LOG_ENABLED()) {
TimeDuration elapsed = mTTFI - mNavigationStart;
MOZ_ASSERT(elapsed.ToMilliseconds() > 0);
TimeDuration elapsedLongTask =
@ -428,7 +428,7 @@ void nsDOMNavigationTiming::NotifyContentfulPaintForRootContentDocument(
mContentfulPaint = aCompositeEndTime;
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active() || PAGELOAD_LOG_ENABLED()) {
if (profiler_can_accept_markers() || PAGELOAD_LOG_ENABLED()) {
TimeDuration elapsed = mContentfulPaint - mNavigationStart;
nsAutoCString spec;
if (mLoadedURI) {

View File

@ -5865,9 +5865,9 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
const char* reason = GetTimeoutReasonString(timeout);
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
nsCString str;
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
nsCString str;
TimeDuration originalInterval = timeout->When() - timeout->SubmitTime();
str.Append(reason);
str.Append(" with interval ");
@ -5876,10 +5876,10 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
nsCString handlerDescription;
timeout->mScriptHandler->GetDescription(handlerDescription);
str.Append(handlerDescription);
AUTO_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE("setTimeout callback", str, JS,
docShell,
timeout->TakeProfilerBacktrace());
}
AUTO_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE("setTimeout callback", str, JS,
docShell,
timeout->TakeProfilerBacktrace());
#endif
bool abortIntervalHandler;

View File

@ -221,7 +221,7 @@ void Performance::Mark(const nsAString& aName, ErrorResult& aRv) {
InsertUserEntry(performanceMark);
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
nsCOMPtr<nsIDocShell> docShell =
nsContentUtils::GetDocShellForEventTarget(et);
@ -305,7 +305,7 @@ void Performance::Measure(const nsAString& aName,
InsertUserEntry(performanceMeasure);
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
TimeStamp startTimeStamp =
CreationTimeStamp() + TimeDuration::FromMilliseconds(startTime);
TimeStamp endTimeStamp =

View File

@ -2310,7 +2310,7 @@ void RecordCompositionPayloadsPresented(
TimeStamp presented = TimeStamp::Now();
for (const CompositionPayload& payload : aPayloads) {
#if MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
nsPrintfCString marker(
"Payload Presented, type: %d latency: %dms\n",
int32_t(payload.mType),

View File

@ -94,7 +94,7 @@ void ProfilerScreenshots::SubmitScreenshot(
originalSize, scaledSize, timeStamp]() {
// Create a new surface that wraps backingSurface's data but has the
// correct size.
{
if (profiler_can_accept_markers()) {
DataSourceSurface::ScopedMap scopedMap(backingSurface,
DataSourceSurface::READ);
RefPtr<DataSourceSurface> surf =

View File

@ -2530,7 +2530,7 @@ int32_t RecordContentFrameTime(
int32_t fracLatencyNorm = lround(latencyNorm * 100.0);
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
class ContentFramePayload : public ProfilerMarkerPayload {
public:
ContentFramePayload(const mozilla::TimeStamp& aStartTime,

View File

@ -361,7 +361,7 @@ void ContentCompositorBridgeParent::ShadowLayersUpdated(
auto endTime = TimeStamp::Now();
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
class ContentBuildPayload : public ProfilerMarkerPayload {
public:
ContentBuildPayload(const mozilla::TimeStamp& aStartTime,

View File

@ -205,7 +205,7 @@ class SceneBuiltNotification : public wr::NotificationHandler {
"SceneBuiltNotificationRunnable", [parent, epoch, startTime]() {
auto endTime = TimeStamp::Now();
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
class ContentFullPaintPayload : public ProfilerMarkerPayload {
public:
ContentFullPaintPayload(const mozilla::TimeStamp& aStartTime,

View File

@ -1605,13 +1605,12 @@ void gfxFontFamily::FindFontForChar(GlobalFontMatch* aMatchData) {
}
#ifdef MOZ_GECKO_PROFILER
nsCString charAndName;
if (profiler_is_active()) {
charAndName = nsPrintfCString("\\u%x %s", aMatchData->mCh, mName.get());
if (profiler_can_accept_markers()) {
nsCString charAndName =
nsPrintfCString("\\u%x %s", aMatchData->mCh, mName.get());
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("gfxFontFamily::FindFontForChar",
LAYOUT, charAndName);
}
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("gfxFontFamily::FindFontForChar",
LAYOUT, charAndName);
#endif
AutoTArray<gfxFontEntry*, 4> entries;

View File

@ -20,7 +20,7 @@ class MOZ_RAII AutoProfilerStyleMarker {
explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
: mActive(profiler_is_active()),
: mActive(profiler_can_accept_markers()),
mStartTime(TimeStamp::Now()),
mCause(std::move(aCause)),
mDocShellId(aDocShellId),

View File

@ -1114,7 +1114,7 @@ void HttpChannelChild::OnStopRequest(
mCacheReadEnd = timing.cacheReadEnd;
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
int32_t priority = PRIORITY_NORMAL;
GetPriority(&priority);
profiler_add_network_marker(

View File

@ -5916,7 +5916,7 @@ nsresult nsHttpChannel::ContinueProcessRedirectionAfterFallback(nsresult rv) {
}
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
int32_t priority = PRIORITY_NORMAL;
GetPriority(&priority);
@ -6354,7 +6354,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener* aListener) {
#ifdef MOZ_GECKO_PROFILER
mLastStatusReported =
TimeStamp::Now(); // in case we enable the profiler after AsyncOpen()
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
profiler_add_network_marker(mURI, mPriority, mChannelId,
NetworkLoadType::LOAD_START,
mChannelCreationTimestamp, mLastStatusReported,
@ -8230,7 +8230,7 @@ nsresult nsHttpChannel::ContinueOnStopRequest(nsresult aStatus, bool aIsFromNet,
MaybeReportTimingData();
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active() && !mRedirectURI) {
if (profiler_can_accept_markers() && !mRedirectURI) {
// Don't include this if we already redirected
// These do allocations/frees/etc; avoid if not active
nsCOMPtr<nsIURI> uri;

View File

@ -494,7 +494,7 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime) {
// If the profiler is enabled, add a marker.
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
if (profiler_can_accept_markers()) {
TimeStamp endTime = TimeStamp::Now();
TimeStamp startTime = endTime - aHangTime;
AUTO_PROFILER_STATS(add_marker_with_HangMarkerPayload);

View File

@ -406,7 +406,7 @@ class LogModuleManager {
}
#ifdef MOZ_GECKO_PROFILER
if (mAddProfilerMarker && profiler_is_active()) {
if (mAddProfilerMarker && profiler_can_accept_markers()) {
PROFILER_ADD_MARKER_WITH_PAYLOAD("LogMessages", OTHER, LogMarkerPayload,
(aName, buffToWrite, TimeStamp::Now()));
}