Bug 1330184 - Allow StreamMetaObject to be called on a background thread, but only include startTime and version for those calls. r=njn

MozReview-Commit-ID: 3AuX0a2Brrd

--HG--
extra : rebase_source : 8c5d2b4ccacbbec92711a9561d4166e1e7c376c7
extra : intermediate-source : e13b9e798e16185e54435a0b926970e8de134804
extra : source : edfdb14bd020233fa29771bb0f78bcfc55f6cbb3
This commit is contained in:
Markus Stange 2017-05-29 13:44:28 -04:00
Родитель b728005923
Коммит 5d85a692ae
1 изменённых файлов: 19 добавлений и 9 удалений

Просмотреть файл

@ -1403,10 +1403,28 @@ StreamTaskTracer(PSLockRef aLock, SpliceableJSONWriter& aWriter)
static void
StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
aWriter.IntProperty("version", 6);
// The "startTime" field holds the number of milliseconds since midnight
// January 1, 1970 GMT. This grotty code computes (Now - (Now -
// ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
mozilla::TimeDuration delta =
mozilla::TimeStamp::Now() - CorePS::ProcessStartTime(aLock);
aWriter.DoubleProperty(
"startTime", static_cast<double>(PR_Now()/1000.0 - delta.ToMilliseconds()));
if (!NS_IsMainThread()) {
// Leave the rest of the properties out if we're not on the main thread.
// At the moment, the only case in which this function is called on a
// background thread is if we're in a content process and are going to
// send this profile to the parent process. In that case, the parent
// process profile's "meta" object already has the rest of the properties,
// and the parent process profile is dumped on that process's main thread.
return;
}
aWriter.DoubleProperty("interval", ActivePS::Interval(aLock));
aWriter.IntProperty("stackwalk", ActivePS::FeatureStackWalk(aLock));
@ -1421,14 +1439,6 @@ StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter)
bool asyncStacks = Preferences::GetBool("javascript.options.asyncstack");
aWriter.IntProperty("asyncstack", asyncStacks);
// The "startTime" field holds the number of milliseconds since midnight
// January 1, 1970 GMT. This grotty code computes (Now - (Now -
// ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
mozilla::TimeDuration delta =
mozilla::TimeStamp::Now() - CorePS::ProcessStartTime(aLock);
aWriter.DoubleProperty(
"startTime", static_cast<double>(PR_Now()/1000.0 - delta.ToMilliseconds()));
aWriter.IntProperty("processType", XRE_GetProcessType());
nsresult res;