bug 1218576 - Ensure remaining batched telemetry is flushed on content process shutdown r=gfritzsche

On content process shutdown we send a content process ping to ensure we have
up-to-date data from the content process before it goes away. Now we need to
also flush the batched telemetry accumulations to the parent so that it can be
present in the ping.

No attempt is made to synchronize access to IPCTimerFired. It is safe to
re-enter.

No attempt is made to cancel the timer as its firing is benign.

MozReview-Commit-ID: 1gjNH9IPhKf
This commit is contained in:
Chris H-C 2016-08-16 12:41:00 +07:00
parent bbc40e0f54
commit 7b27816209
4 changed files with 19 additions and 3 deletions

View File

@ -2369,6 +2369,13 @@ TelemetryImpl::ClearScalars()
return NS_OK;
}
NS_IMETHODIMP
TelemetryImpl::FlushBatchedChildTelemetry()
{
TelemetryHistogram::IPCTimerFired(nullptr, nullptr);
return NS_OK;
}
size_t
TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
{

View File

@ -2625,8 +2625,11 @@ TelemetryHistogram::GetHistogramSizesofIncludingThis(mozilla::MallocSizeOf
// It releases the lock before calling out to IPC code which can (and does)
// Accumulate (which would deadlock)
//
// To ensure non-reentrancy, the timer is not released until the method
// completes
// To ensure we don't loop IPCTimerFired->AccumulateChild->arm timer, we don't
// unset gIPCTimerArmed until the IPC completes
//
// This function may be re-entered. The shared datastructures gAccumulations and
// gKeyedAccumulations are guarded by the lock.
void
TelemetryHistogram::IPCTimerFired(nsITimer* aTimer, void* aClosure)
{

View File

@ -1838,7 +1838,7 @@ var Impl = {
// content-child-shutdown is only registered for content processes.
Services.obs.removeObserver(this, "content-child-shutdown");
this.uninstall();
Telemetry.flushBatchedChildTelemetry();
this.sendContentProcessPing(REASON_SAVED_SESSION);
break;
case TOPIC_CYCLE_COLLECTOR_BEGIN:

View File

@ -431,4 +431,10 @@ interface nsITelemetry : nsISupports
* Resets all the stored scalars. This is intended to be only used in tests.
*/
void clearScalars();
/**
* Immediately sends any Telemetry batched on this process to the parent
* process. This is intended only to be used on process shutdown.
*/
void flushBatchedChildTelemetry();
};