Bug 1100259 - Add TaskTracer labels in EventDispatcher and console.log of message with special prefix. r=sinker.

This commit is contained in:
Shelly Lin 2014-11-20 10:57:27 +08:00
parent f21146d6ea
commit e06561560c
4 changed files with 52 additions and 0 deletions

View File

@ -32,6 +32,12 @@
#include "mozilla/TouchEvents.h"
#include "mozilla/unused.h"
#ifdef MOZ_TASK_TRACER
#include "GeckoTaskTracer.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::tasktracer;
#endif
namespace mozilla {
using namespace dom;
@ -407,6 +413,27 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
NS_ENSURE_TRUE(aEvent->message || !aDOMEvent || aTargets,
NS_ERROR_DOM_INVALID_STATE_ERR);
#ifdef MOZ_TASK_TRACER
{
if (aDOMEvent) {
nsAutoString eventType;
aDOMEvent->GetType(eventType);
nsCOMPtr<Element> element = do_QueryInterface(aTarget);
nsAutoString elementId;
nsAutoString elementTagName;
if (element) {
element->GetId(elementId);
element->GetTagName(elementTagName);
}
AddLabel("Event [%s] dispatched at target [id:%s tag:%s]",
NS_ConvertUTF16toUTF8(eventType).get(),
NS_ConvertUTF16toUTF8(elementId).get(),
NS_ConvertUTF16toUTF8(elementTagName).get());
}
}
#endif
nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
bool retargeted = false;

View File

@ -37,6 +37,7 @@ static nsTArray<nsAutoPtr<TraceInfo>>* sTraceInfos = nullptr;
static bool sIsLoggingStarted = false;
static TimeStamp sStartTime;
static const char sJSLabelPrefix[] = "#tt#";
namespace {
@ -402,5 +403,11 @@ GetLoggedData(TimeStamp aStartTime)
return result;
}
const char*
GetJSLabelPrefix()
{
return sJSLabelPrefix;
}
} // namespace tasktracer
} // namespace mozilla

View File

@ -83,6 +83,8 @@ already_AddRefed<FakeTracedTask> CreateFakeTracedTask(int* aVptr);
// where nsThread and base::thread release themselves.
void FreeTraceInfo();
const char* GetJSLabelPrefix();
} // namespace tasktracer
} // namespace mozilla.

View File

@ -31,6 +31,11 @@
#include <windows.h>
#endif
#ifdef MOZ_TASK_TRACER
#include "GeckoTaskTracer.h"
using namespace mozilla::tasktracer;
#endif
using namespace mozilla;
NS_IMPL_ADDREF(nsConsoleService)
@ -246,6 +251,17 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage* aMessage,
OutputDebugStringW(msg.get());
}
#endif
#ifdef MOZ_TASK_TRACER
{
nsCString msg;
aMessage->ToString(msg);
int prefixPos = msg.Find(GetJSLabelPrefix());
if (prefixPos >= 0) {
nsDependentCSubstring submsg(msg, prefixPos);
AddLabel("%s", submsg.BeginReading());
}
}
#endif
/*
* If there's already a message in the slot we're about to replace,