gecko-dev/tools/profiler/gecko/ThreadResponsiveness.h
Byron Campen [:bwc] 8d9cde7d0d Bug 1431755 - Part 2: Teach GeckoProfiler to profile responsiveness on nsIThreads. r=mstange
MozReview-Commit-ID: AqpNf9pDzrg

--HG--
extra : rebase_source : d7c67ec8564345f6b851691f4e3dee666dd025b1
2018-01-19 09:42:47 -06:00

44 lines
1.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef ThreadResponsiveness_h
#define ThreadResponsiveness_h
#include "nsISupports.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
class CheckResponsivenessTask;
class nsIEventTarget;
// This class should only be used for the main thread.
class ThreadResponsiveness {
public:
explicit ThreadResponsiveness(nsIEventTarget* aThread, bool aIsMainThread);
~ThreadResponsiveness();
void Update();
// The number of milliseconds that elapsed since the last
// CheckResponsivenessTask was processed.
double GetUnresponsiveDuration(double aStartToNow_ms) const {
return aStartToNow_ms - *mStartToPrevTracer_ms;
}
bool HasData() const {
return mStartToPrevTracer_ms.isSome();
}
private:
RefPtr<CheckResponsivenessTask> mActiveTracerEvent;
// The time at which the last CheckResponsivenessTask was processed, in
// milliseconds since process start (i.e. what you get from profiler_time()).
mozilla::Maybe<double> mStartToPrevTracer_ms;
};
#endif