mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1391359 - Cleanup timestamp computation in nsAppStartup.cpp. r=gsvelto
This commit is contained in:
parent
e73ea68a99
commit
fecbd1f9b8
@ -127,7 +127,8 @@ public:
|
||||
* @param stamp The timestamp to be converted
|
||||
* @returns The converted timestamp
|
||||
*/
|
||||
uint64_t ComputeAbsoluteTimestamp(PRTime prnow, TimeStamp now, TimeStamp stamp)
|
||||
static uint64_t
|
||||
ComputeAbsoluteTimestamp(TimeStamp stamp)
|
||||
{
|
||||
static PRTime sAbsoluteNow = PR_Now();
|
||||
static TimeStamp sMonotonicNow = TimeStamp::Now();
|
||||
@ -756,8 +757,6 @@ nsAppStartup::GetStartupInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aRetva
|
||||
aRetval.setObject(*obj);
|
||||
|
||||
TimeStamp procTime = StartupTimeline::Get(StartupTimeline::PROCESS_CREATION);
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
PRTime absNow = PR_Now();
|
||||
|
||||
if (procTime.IsNull()) {
|
||||
bool error = false;
|
||||
@ -789,7 +788,7 @@ nsAppStartup::GetStartupInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aRetva
|
||||
|
||||
if (!stamp.IsNull()) {
|
||||
if (stamp >= procTime) {
|
||||
PRTime prStamp = ComputeAbsoluteTimestamp(absNow, now, stamp)
|
||||
PRTime prStamp = ComputeAbsoluteTimestamp(stamp)
|
||||
/ PR_USEC_PER_MSEC;
|
||||
JS::Rooted<JSObject*> date(aCx, JS::NewDateObject(aCx, JS::TimeClip(prStamp)));
|
||||
JS_DefineProperty(aCx, obj, StartupTimeline::Describe(ev), date, JSPROP_ENUMERATE);
|
||||
@ -943,14 +942,12 @@ nsAppStartup::TrackStartupCrashEnd()
|
||||
// Use the timestamp of XRE_main as an approximation for the lock file timestamp.
|
||||
// See MAX_STARTUP_BUFFER for the buffer time period.
|
||||
TimeStamp mainTime = StartupTimeline::Get(StartupTimeline::MAIN);
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
PRTime prNow = PR_Now();
|
||||
nsresult rv;
|
||||
|
||||
if (mainTime.IsNull()) {
|
||||
NS_WARNING("Could not get StartupTimeline::MAIN time.");
|
||||
} else {
|
||||
uint64_t lockFileTime = ComputeAbsoluteTimestamp(prNow, now, mainTime);
|
||||
uint64_t lockFileTime = ComputeAbsoluteTimestamp(mainTime);
|
||||
|
||||
rv = Preferences::SetInt(kPrefLastSuccess,
|
||||
(int32_t)(lockFileTime / PR_USEC_PER_SEC));
|
||||
|
Loading…
Reference in New Issue
Block a user