本文整理汇总了C++中SpliceableJSONWriter::StartObjectElement方法的典型用法代码示例。如果您正苦于以下问题:C++ SpliceableJSONWriter::StartObjectElement方法的具体用法?C++ SpliceableJSONWriter::StartObjectElement怎么用?C++ SpliceableJSONWriter::StartObjectElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpliceableJSONWriter
的用法示例。
在下文中一共展示了SpliceableJSONWriter::StartObjectElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildJavaThreadJSObject
static
void BuildJavaThreadJSObject(SpliceableJSONWriter& aWriter)
{
aWriter.Start(SpliceableJSONWriter::SingleLineStyle);
aWriter.StringProperty("name", "Java Main Thread");
aWriter.StartArrayProperty("samples");
// for each sample
for (int sampleId = 0; true; sampleId++) {
bool firstRun = true;
// for each frame
for (int frameId = 0; true; frameId++) {
nsCString result;
bool hasFrame = AndroidBridge::Bridge()->GetFrameNameJavaProfiling(0, sampleId, frameId, result);
// when we run out of frames, we stop looping
if (!hasFrame) {
// if we found at least one frame, we have objects to close
if (!firstRun) {
aWriter.EndArray();
aWriter.EndObject();
}
break;
}
// the first time around, open the sample object and frames array
if (firstRun) {
firstRun = false;
double sampleTime =
mozilla::widget::GeckoJavaSampler::GetSampleTimeJavaProfiling(0, sampleId);
aWriter.StartObjectElement();
aWriter.DoubleProperty("time", sampleTime);
aWriter.StartArrayProperty("frames");
}
// add a frame to the sample
aWriter.StartObjectElement();
aWriter.StringProperty("location", result.BeginReading());
aWriter.EndObject();
}
// if we found no frames for this sample, we are done
if (firstRun) {
break;
}
}
aWriter.EndArray();
aWriter.End();
}
示例2: BuildJavaThreadJSObject
static
void BuildJavaThreadJSObject(SpliceableJSONWriter& aWriter)
{
aWriter.StringProperty("name", "Java Main Thread");
aWriter.StartArrayProperty("samples");
// for each sample
for (int sampleId = 0; true; sampleId++) {
bool firstRun = true;
// for each frame
for (int frameId = 0; true; frameId++) {
jni::String::LocalRef frameName =
java::GeckoJavaSampler::GetFrameName(0, sampleId, frameId);
// when we run out of frames, we stop looping
if (!frameName) {
// if we found at least one frame, we have objects to close
if (!firstRun) {
aWriter.EndArray();
aWriter.EndObject();
}
break;
}
// the first time around, open the sample object and frames array
if (firstRun) {
firstRun = false;
double sampleTime =
java::GeckoJavaSampler::GetSampleTime(0, sampleId);
aWriter.StartObjectElement();
aWriter.DoubleProperty("time", sampleTime);
aWriter.StartArrayProperty("frames");
}
// add a frame to the sample
aWriter.StartObjectElement();
aWriter.StringProperty("location",
frameName->ToCString().BeginReading());
aWriter.EndObject();
}
// if we found no frames for this sample, we are done
if (firstRun) {
break;
}
}
aWriter.EndArray();
}
示例3: StreamTaskTracer
void GeckoSampler::StreamTaskTracer(SpliceableJSONWriter& aWriter)
{
#ifdef MOZ_TASK_TRACER
aWriter.StartArrayProperty("data");
nsAutoPtr<nsTArray<nsCString>> data(mozilla::tasktracer::GetLoggedData(sStartTime));
for (uint32_t i = 0; i < data->Length(); ++i) {
aWriter.StringElement((data->ElementAt(i)).get());
}
aWriter.EndArray();
aWriter.StartArrayProperty("threads");
::MutexAutoLock lock(*sRegisteredThreadsMutex);
for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
// Thread meta data
ThreadInfo* info = sRegisteredThreads->at(i);
aWriter.StartObjectElement();
if (XRE_GetProcessType() == GeckoProcessType_Plugin) {
// TODO Add the proper plugin name
aWriter.StringProperty("name", "Plugin");
} else {
aWriter.StringProperty("name", info->Name());
}
aWriter.IntProperty("tid", static_cast<int>(info->ThreadId()));
aWriter.EndObject();
}
aWriter.EndArray();
aWriter.DoubleProperty("start", static_cast<double>(mozilla::tasktracer::GetStartTime()));
#endif
}
示例4: StreamJSON
void ProfilerMarker::StreamJSON(SpliceableJSONWriter& aWriter,
UniqueStacks& aUniqueStacks) const
{
// Schema:
// [name, time, data]
aWriter.StartArrayElement();
{
aUniqueStacks.mUniqueStrings.WriteElement(aWriter, GetMarkerName());
aWriter.DoubleElement(mTime);
// TODO: Store the callsite for this marker if available:
// if have location data
// b.NameValue(marker, "location", ...);
if (mPayload) {
aWriter.StartObjectElement();
{
mPayload->StreamPayload(aWriter, aUniqueStacks);
}
aWriter.EndObject();
}
}
aWriter.EndArray();
}