From fd0de3fdada4746155bb3d03eaa6cce3151cdcc0 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Tue, 30 Aug 2016 15:51:49 +0200 Subject: [PATCH] Backed out changeset cd8049475224 (bug 1218576) --- .../components/telemetry/TelemetrySession.jsm | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/toolkit/components/telemetry/TelemetrySession.jsm b/toolkit/components/telemetry/TelemetrySession.jsm index 2640118c360c..68d7f0e8c981 100644 --- a/toolkit/components/telemetry/TelemetrySession.jsm +++ b/toolkit/components/telemetry/TelemetrySession.jsm @@ -57,6 +57,7 @@ const PREF_UNIFIED = PREF_BRANCH + "unified"; const MESSAGE_TELEMETRY_PAYLOAD = "Telemetry:Payload"; +const MESSAGE_TELEMETRY_GET_CHILD_PAYLOAD = "Telemetry:GetChildPayload"; const MESSAGE_TELEMETRY_THREAD_HANGS = "Telemetry:ChildThreadHangs"; const MESSAGE_TELEMETRY_GET_CHILD_THREAD_HANGS = "Telemetry:GetChildThreadHangs"; const MESSAGE_TELEMETRY_USS = "Telemetry:USS"; @@ -539,6 +540,13 @@ this.TelemetrySession = Object.freeze({ getPayload: function(reason, clearSubsession = false) { return Impl.getPayload(reason, clearSubsession); }, + /** + * Asks the content processes to send their payloads. + * @returns Object + */ + requestChildPayloads: function() { + return Impl.requestChildPayloads(); + }, /** * Returns a promise that resolves to an array of thread hang stats from content processes, one entry per process. * The structure of each entry is identical to that of "threadHangStats" in nsITelemetry. @@ -1513,6 +1521,7 @@ var Impl = { } Services.obs.addObserver(this, "content-child-shutdown", false); + cpml.addMessageListener(MESSAGE_TELEMETRY_GET_CHILD_PAYLOAD, this); cpml.addMessageListener(MESSAGE_TELEMETRY_GET_CHILD_THREAD_HANGS, this); cpml.addMessageListener(MESSAGE_TELEMETRY_GET_CHILD_USS, this); @@ -1550,6 +1559,14 @@ var Impl = { let source = message.data.childUUID; delete message.data.childUUID; + for (let child of this._childTelemetry) { + if (child.source === source) { + // Update existing telemetry data. + child.payload = message.data; + return; + } + } + // Did not find existing child in this._childTelemetry. this._childTelemetry.push({ source: source, payload: message.data, @@ -1562,6 +1579,12 @@ var Impl = { break; } + case MESSAGE_TELEMETRY_GET_CHILD_PAYLOAD: + { + // In child process, send the requested Telemetry payload + this.sendContentProcessPing("saved-session"); + break; + } case MESSAGE_TELEMETRY_THREAD_HANGS: { // Accumulate child thread hang stats from this child @@ -1741,6 +1764,11 @@ var Impl = { return this.getSessionPayload(reason, clearSubsession); }, + requestChildPayloads: function() { + this._log.trace("requestChildPayloads"); + ppmm.broadcastAsyncMessage(MESSAGE_TELEMETRY_GET_CHILD_PAYLOAD, {}); + }, + getChildThreadHangs: function getChildThreadHangs() { return new Promise((resolve) => { // Return immediately if there are no child processes to get stats from