2013-07-11 08:27:04 +04:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2013-09-25 19:28:34 +04:00
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
#include "ProfilerBacktrace.h"
|
2013-07-11 08:27:04 +04:00
|
|
|
#include "ProfilerMarkers.h"
|
|
|
|
#include "gfxASurface.h"
|
2013-09-25 19:28:34 +04:00
|
|
|
#include "SyncProfile.h"
|
|
|
|
|
|
|
|
ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack)
|
|
|
|
: mStack(aStack)
|
|
|
|
{}
|
|
|
|
|
|
|
|
ProfilerMarkerPayload::ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
ProfilerBacktrace* aStack)
|
2013-09-27 20:08:45 +04:00
|
|
|
: mStartTime(aStartTime)
|
|
|
|
, mEndTime(aEndTime)
|
|
|
|
, mStack(aStack)
|
2013-09-25 19:28:34 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
ProfilerMarkerPayload::~ProfilerMarkerPayload()
|
|
|
|
{
|
|
|
|
profiler_free_backtrace(mStack);
|
|
|
|
}
|
|
|
|
|
2014-04-22 00:48:47 +04:00
|
|
|
void
|
|
|
|
ProfilerMarkerPayload::streamCommonProps(const char* aMarkerType,
|
|
|
|
JSStreamWriter& b)
|
2013-09-25 19:28:34 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aMarkerType);
|
2014-04-22 00:48:47 +04:00
|
|
|
b.NameValue("type", aMarkerType);
|
2013-09-25 19:28:34 +04:00
|
|
|
if (!mStartTime.IsNull()) {
|
2014-04-22 00:48:47 +04:00
|
|
|
b.NameValue("startTime", profiler_time(mStartTime));
|
2013-09-25 19:28:34 +04:00
|
|
|
}
|
|
|
|
if (!mEndTime.IsNull()) {
|
2014-04-22 00:48:47 +04:00
|
|
|
b.NameValue("endTime", profiler_time(mEndTime));
|
2013-09-25 19:28:34 +04:00
|
|
|
}
|
|
|
|
if (mStack) {
|
2014-04-22 00:48:47 +04:00
|
|
|
b.Name("stack");
|
|
|
|
mStack->StreamJSObject(b);
|
2013-09-25 19:28:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-27 20:08:45 +04:00
|
|
|
ProfilerMarkerTracing::ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData)
|
|
|
|
: mCategory(aCategory)
|
|
|
|
, mMetaData(aMetaData)
|
2014-04-22 22:13:00 +04:00
|
|
|
{
|
|
|
|
if (aMetaData == TRACING_EVENT_BACKTRACE) {
|
|
|
|
SetStack(profiler_get_backtrace());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfilerMarkerTracing::ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData,
|
|
|
|
ProfilerBacktrace* aCause)
|
|
|
|
: mCategory(aCategory)
|
|
|
|
, mMetaData(aMetaData)
|
|
|
|
{
|
|
|
|
if (aCause) {
|
|
|
|
SetStack(aCause);
|
|
|
|
}
|
|
|
|
}
|
2013-09-27 20:08:45 +04:00
|
|
|
|
2014-04-22 00:48:47 +04:00
|
|
|
void
|
|
|
|
ProfilerMarkerTracing::streamPayloadImp(JSStreamWriter& b)
|
2013-09-27 20:08:45 +04:00
|
|
|
{
|
2014-04-22 00:48:47 +04:00
|
|
|
b.BeginObject();
|
|
|
|
streamCommonProps("tracing", b);
|
2013-09-27 20:08:45 +04:00
|
|
|
|
2014-04-22 00:48:47 +04:00
|
|
|
if (GetCategory()) {
|
|
|
|
b.NameValue("category", GetCategory());
|
2013-09-27 20:08:45 +04:00
|
|
|
}
|
2014-04-22 00:48:47 +04:00
|
|
|
if (GetMetaData() != TRACING_DEFAULT) {
|
|
|
|
if (GetMetaData() == TRACING_INTERVAL_START) {
|
|
|
|
b.NameValue("interval", "start");
|
|
|
|
} else if (GetMetaData() == TRACING_INTERVAL_END) {
|
|
|
|
b.NameValue("interval", "end");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b.EndObject();
|
2013-09-27 20:08:45 +04:00
|
|
|
}
|
|
|
|
|
2013-07-11 08:27:04 +04:00
|
|
|
ProfilerMarkerImagePayload::ProfilerMarkerImagePayload(gfxASurface *aImg)
|
|
|
|
: mImg(aImg)
|
|
|
|
{}
|
|
|
|
|
2014-04-22 00:48:47 +04:00
|
|
|
void
|
|
|
|
ProfilerMarkerImagePayload::streamPayloadImp(JSStreamWriter& b)
|
2013-07-11 08:27:04 +04:00
|
|
|
{
|
2014-04-22 00:48:47 +04:00
|
|
|
b.BeginObject();
|
|
|
|
streamCommonProps("innerHTML", b);
|
|
|
|
// TODO: Finish me
|
|
|
|
//b.NameValue("innerHTML", "<img src=''/>");
|
|
|
|
b.EndObject();
|
2013-07-11 08:27:04 +04:00
|
|
|
}
|
|
|
|
|
2013-09-25 19:28:34 +04:00
|
|
|
IOMarkerPayload::IOMarkerPayload(const char* aSource,
|
2014-02-13 22:32:38 +04:00
|
|
|
const char* aFilename,
|
2013-09-25 19:28:34 +04:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
ProfilerBacktrace* aStack)
|
|
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime, aStack),
|
2014-02-20 17:43:55 +04:00
|
|
|
mSource(aSource)
|
2013-09-25 19:28:34 +04:00
|
|
|
{
|
2014-02-20 17:43:55 +04:00
|
|
|
mFilename = aFilename ? strdup(aFilename) : nullptr;
|
2013-09-25 19:28:34 +04:00
|
|
|
MOZ_ASSERT(aSource);
|
|
|
|
}
|
|
|
|
|
2014-02-13 22:32:38 +04:00
|
|
|
IOMarkerPayload::~IOMarkerPayload(){
|
|
|
|
free(mFilename);
|
|
|
|
}
|
|
|
|
|
2014-04-22 00:48:47 +04:00
|
|
|
void
|
|
|
|
IOMarkerPayload::streamPayloadImp(JSStreamWriter& b)
|
2013-09-25 19:28:34 +04:00
|
|
|
{
|
2014-04-22 00:48:47 +04:00
|
|
|
b.BeginObject();
|
|
|
|
streamCommonProps("io", b);
|
|
|
|
b.NameValue("source", mSource);
|
|
|
|
if (mFilename != nullptr) {
|
|
|
|
b.NameValue("filename", mFilename);
|
|
|
|
}
|
|
|
|
b.EndObject();
|
2013-09-25 19:28:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-03 23:36:08 +04:00
|
|
|
void
|
|
|
|
ProfilerJSEventMarker(const char *event)
|
|
|
|
{
|
|
|
|
PROFILER_MARKER(event);
|
|
|
|
}
|