/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
void AppendJSONStringAsProperty(nsCString& aDest, constchar* aPropertyName, const nsACString& aJSON) { // We need to manually append into the string here, since JSONWriter has no // way to allow us to write an existing JSON object into a property.
aDest.Append(",\n\"");
aDest.Append(aPropertyName);
aDest.Append("\": ");
aDest.Append(aJSON);
}
aWriter.StartArrayProperty("urls"); for (constauto& key : browsers) { // This only reports -current- URLs, not ones that may have been here in // the past, this is unfortunate especially for processes which are dying // and that have no more active URLs.
RefPtr<BrowserParent> parent = BrowserParent::GetFrom(key);
CanonicalBrowsingContext* ctx = parent->GetBrowsingContext(); if (!ctx) { continue;
}
WindowGlobalParent* windowGlobal = ctx->GetCurrentWindowGlobal(); if (!windowGlobal) { continue;
}
RefPtr<nsIURI> uri = windowGlobal->GetDocumentURI(); if (!uri) { continue;
}
// To generate correct JSON here we don't call start and end. That causes // this to use Single Line mode, sadly.
WriteContentParent(jsonString, w, aPerfStats, aParent);
mStoredPerfStats.AppendElement(jsonString);
}
auto PerfStats::CollectPerfStatsJSONInternal() -> RefPtr<PerfStatsPromise> { if (!PerfStats::sCollectionMask) { return PerfStatsPromise::CreateAndReject(false, __func__);
}
if (!XRE_IsParentProcess()) { return PerfStatsPromise::CreateAndResolve(
CollectLocalPerfStatsJSONInternal(), __func__);
}
// Append any processes that closed earlier. for (nsCString& string : mStoredPerfStats) {
w.StartObjectElement(); // This trick makes indentation even more messed up than it already // was. However it produces technically correct JSON.
collector->string.Append(string);
w.EndObject();
} // We do not clear this, we only clear stored perfstats when the mask is // reset.
if (gpuManager) {
gpuChild = gpuManager->GetGPUChild();
}
nsTArray<ContentParent*> contentParents;
ContentParent::GetAll(contentParents);
if (gpuChild) {
gpuChild->SendCollectPerfStatsJSON(
[collector, gpuChild = RefPtr{gpuChild}](const nsCString& aString) {
collector->AppendPerfStats(aString, gpuChild);
}, // The only feasible errors here are if something goes wrong in the // the bridge, we choose to ignore those.
[](mozilla::ipc::ResponseRejectReason) {});
} for (ContentParent* parent : contentParents) {
RefPtr<ContentParent> parentRef = parent;
parent->SendCollectPerfStatsJSON(
[collector, parentRef](const nsCString& aString) {
collector->AppendPerfStats(aString, parentRef.get());
}, // The only feasible errors here are if something goes wrong in the // the bridge, we choose to ignore those.
[](mozilla::ipc::ResponseRejectReason) {});
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.