Bug 799638 - Export profiler markers when saving profiler profiles. r=ehsan

This commit is contained in:
Benoit Girard 2012-10-15 10:33:20 -04:00
parent a0793a7600
commit 828e28e911
2 changed files with 34 additions and 0 deletions

View File

@ -85,6 +85,26 @@ class JSObjectBuilder
mOk = JS_SetElement(mCx, aArray, length, &objval);
}
void ArrayPush(JSObject *aArray, const char *value)
{
if (!mOk)
return;
JSString *string = JS_NewStringCopyN(mCx, value, strlen(value));
if (!string) {
mOk = JS_FALSE;
return;
}
jsval objval = STRING_TO_JSVAL(string);
uint32_t length;
mOk = JS_GetArrayLength(mCx, aArray, &length);
if (!mOk)
return;
mOk = JS_SetElement(mCx, aArray, length, &objval);
}
void ArrayPush(JSObject *aArray, JSObject *aObject)
{

View File

@ -290,6 +290,7 @@ public:
JSObject *sample = NULL;
JSObject *frames = NULL;
JSObject *marker = NULL;
int readPos = mReadPos;
while (readPos != mLastFlushPos) {
@ -315,6 +316,19 @@ public:
frames = b.CreateArray();
b.DefineProperty(sample, "frames", frames);
b.ArrayPush(samples, sample);
// Created lazily
marker = NULL;
break;
case 'm':
{
if (sample) {
if (!marker) {
marker = b.CreateArray();
b.DefineProperty(sample, "marker", marker);
}
b.ArrayPush(marker, tagStringData);
}
}
break;
case 'r':
{