зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575448 - ProfilerMarkerPayload::CommonProps - r=gregtatum
The common data members stored in the ProfilerMarkerPayload base class can be gathered into a struct, which will make it easier to pass around, especially when a derived object is constructed with these common properties. Differential Revision: https://phabricator.services.mozilla.com/D43427 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a14e2c944d
Коммит
64f0dcdf95
|
@ -40,17 +40,21 @@ void ProfilerMarkerPayload::StreamCommonProps(
|
|||
const char* aMarkerType, SpliceableJSONWriter& aWriter,
|
||||
const TimeStamp& aProcessStartTime, UniqueStacks& aUniqueStacks) {
|
||||
StreamType(aMarkerType, aWriter);
|
||||
WriteTime(aWriter, aProcessStartTime, mStartTime, "startTime");
|
||||
WriteTime(aWriter, aProcessStartTime, mEndTime, "endTime");
|
||||
if (mDocShellId) {
|
||||
aWriter.StringProperty("docShellId", mDocShellId->c_str());
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mStartTime, "startTime");
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mEndTime, "endTime");
|
||||
if (mCommonProps.mDocShellId) {
|
||||
aWriter.StringProperty("docShellId", mCommonProps.mDocShellId->c_str());
|
||||
}
|
||||
if (mDocShellHistoryId) {
|
||||
aWriter.DoubleProperty("docshellHistoryId", mDocShellHistoryId.ref());
|
||||
if (mCommonProps.mDocShellHistoryId) {
|
||||
aWriter.DoubleProperty("docshellHistoryId",
|
||||
mCommonProps.mDocShellHistoryId.ref());
|
||||
}
|
||||
if (mStack) {
|
||||
if (mCommonProps.mStack) {
|
||||
aWriter.StartObjectProperty("stack");
|
||||
{ mStack->StreamJSON(aWriter, aProcessStartTime, aUniqueStacks); }
|
||||
{
|
||||
mCommonProps.mStack->StreamJSON(aWriter, aProcessStartTime,
|
||||
aUniqueStacks);
|
||||
}
|
||||
aWriter.EndObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,19 +37,15 @@ class ProfilerMarkerPayload {
|
|||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mStack(std::move(aStack)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {}
|
||||
: mCommonProps{TimeStamp{}, TimeStamp{}, std::move(aStack),
|
||||
std::move(aDocShellId), std::move(aDocShellHistoryId)} {}
|
||||
|
||||
ProfilerMarkerPayload(const TimeStamp& aStartTime, const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mStartTime(aStartTime),
|
||||
mEndTime(aEndTime),
|
||||
mStack(std::move(aStack)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {}
|
||||
: mCommonProps{aStartTime, aEndTime, std::move(aStack),
|
||||
std::move(aDocShellId), std::move(aDocShellHistoryId)} {}
|
||||
|
||||
virtual ~ProfilerMarkerPayload() {}
|
||||
|
||||
|
@ -57,9 +53,20 @@ class ProfilerMarkerPayload {
|
|||
const TimeStamp& aProcessStartTime,
|
||||
UniqueStacks& aUniqueStacks) = 0;
|
||||
|
||||
TimeStamp GetStartTime() const { return mStartTime; }
|
||||
TimeStamp GetStartTime() const { return mCommonProps.mStartTime; }
|
||||
|
||||
protected:
|
||||
struct CommonProps {
|
||||
TimeStamp mStartTime;
|
||||
TimeStamp mEndTime;
|
||||
UniqueProfilerBacktrace mStack;
|
||||
Maybe<std::string> mDocShellId;
|
||||
Maybe<uint32_t> mDocShellHistoryId;
|
||||
};
|
||||
|
||||
explicit ProfilerMarkerPayload(CommonProps&& aCommonProps)
|
||||
: mCommonProps(std::move(aCommonProps)) {}
|
||||
|
||||
MFBT_API void StreamType(const char* aMarkerType,
|
||||
SpliceableJSONWriter& aWriter);
|
||||
MFBT_API void StreamCommonProps(const char* aMarkerType,
|
||||
|
@ -68,11 +75,7 @@ class ProfilerMarkerPayload {
|
|||
UniqueStacks& aUniqueStacks);
|
||||
|
||||
private:
|
||||
TimeStamp mStartTime;
|
||||
TimeStamp mEndTime;
|
||||
UniqueProfilerBacktrace mStack;
|
||||
Maybe<std::string> mDocShellId;
|
||||
Maybe<uint32_t> mDocShellHistoryId;
|
||||
CommonProps mCommonProps;
|
||||
};
|
||||
|
||||
#define DECL_BASE_STREAM_PAYLOAD \
|
||||
|
|
|
@ -40,17 +40,22 @@ void ProfilerMarkerPayload::StreamCommonProps(
|
|||
const char* aMarkerType, SpliceableJSONWriter& aWriter,
|
||||
const TimeStamp& aProcessStartTime, UniqueStacks& aUniqueStacks) {
|
||||
StreamType(aMarkerType, aWriter);
|
||||
WriteTime(aWriter, aProcessStartTime, mStartTime, "startTime");
|
||||
WriteTime(aWriter, aProcessStartTime, mEndTime, "endTime");
|
||||
if (mDocShellId) {
|
||||
aWriter.StringProperty("docShellId", nsIDToCString(*mDocShellId).get());
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mStartTime, "startTime");
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mEndTime, "endTime");
|
||||
if (mCommonProps.mDocShellId) {
|
||||
aWriter.StringProperty("docShellId",
|
||||
nsIDToCString(*mCommonProps.mDocShellId).get());
|
||||
}
|
||||
if (mDocShellHistoryId) {
|
||||
aWriter.DoubleProperty("docshellHistoryId", mDocShellHistoryId.ref());
|
||||
if (mCommonProps.mDocShellHistoryId) {
|
||||
aWriter.DoubleProperty("docshellHistoryId",
|
||||
mCommonProps.mDocShellHistoryId.ref());
|
||||
}
|
||||
if (mStack) {
|
||||
if (mCommonProps.mStack) {
|
||||
aWriter.StartObjectProperty("stack");
|
||||
{ mStack->StreamJSON(aWriter, aProcessStartTime, aUniqueStacks); }
|
||||
{
|
||||
mCommonProps.mStack->StreamJSON(aWriter, aProcessStartTime,
|
||||
aUniqueStacks);
|
||||
}
|
||||
aWriter.EndObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define ProfilerMarkerPayload_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/BlocksRingBuffer.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
@ -46,20 +47,17 @@ class ProfilerMarkerPayload {
|
|||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mStack(std::move(aStack)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {}
|
||||
: mCommonProps{mozilla::TimeStamp{}, mozilla::TimeStamp{},
|
||||
std::move(aStack), std::move(aDocShellId),
|
||||
std::move(aDocShellHistoryId)} {}
|
||||
|
||||
ProfilerMarkerPayload(
|
||||
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mStartTime(aStartTime),
|
||||
mEndTime(aEndTime),
|
||||
mStack(std::move(aStack)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {}
|
||||
: mCommonProps{aStartTime, aEndTime, std::move(aStack),
|
||||
std::move(aDocShellId), std::move(aDocShellHistoryId)} {}
|
||||
|
||||
virtual ~ProfilerMarkerPayload() {}
|
||||
|
||||
|
@ -67,20 +65,27 @@ class ProfilerMarkerPayload {
|
|||
const mozilla::TimeStamp& aProcessStartTime,
|
||||
UniqueStacks& aUniqueStacks) = 0;
|
||||
|
||||
mozilla::TimeStamp GetStartTime() const { return mStartTime; }
|
||||
mozilla::TimeStamp GetStartTime() const { return mCommonProps.mStartTime; }
|
||||
|
||||
protected:
|
||||
struct CommonProps {
|
||||
mozilla::TimeStamp mStartTime;
|
||||
mozilla::TimeStamp mEndTime;
|
||||
UniqueProfilerBacktrace mStack;
|
||||
mozilla::Maybe<nsID> mDocShellId;
|
||||
mozilla::Maybe<uint32_t> mDocShellHistoryId;
|
||||
};
|
||||
|
||||
explicit ProfilerMarkerPayload(CommonProps&& aCommonProps)
|
||||
: mCommonProps(std::move(aCommonProps)) {}
|
||||
|
||||
void StreamType(const char* aMarkerType, SpliceableJSONWriter& aWriter);
|
||||
void StreamCommonProps(const char* aMarkerType, SpliceableJSONWriter& aWriter,
|
||||
const mozilla::TimeStamp& aProcessStartTime,
|
||||
UniqueStacks& aUniqueStacks);
|
||||
|
||||
private:
|
||||
mozilla::TimeStamp mStartTime;
|
||||
mozilla::TimeStamp mEndTime;
|
||||
UniqueProfilerBacktrace mStack;
|
||||
mozilla::Maybe<nsID> mDocShellId;
|
||||
mozilla::Maybe<uint32_t> mDocShellHistoryId;
|
||||
CommonProps mCommonProps;
|
||||
};
|
||||
|
||||
#define DECL_STREAM_PAYLOAD \
|
||||
|
|
Загрузка…
Ссылка в новой задаче