зеркало из https://github.com/mozilla/gecko-dev.git
about:startup - open the correct file, error check the fopen, use try/catch to check for failure in the js
This commit is contained in:
Родитель
da263b215f
Коммит
981448b1b0
|
@ -4,7 +4,11 @@ var Ci = Components.interfaces;
|
|||
let launched, startup, restored;
|
||||
|
||||
let runtime = Cc["@mozilla.org/xre/runtime;1"].getService(Ci.nsIXULRuntime);
|
||||
|
||||
try {
|
||||
displayTimestamp("launched", launched = runtime.launchTimestamp);
|
||||
} catch(x) { }
|
||||
|
||||
displayTimestamp("started", startup = runtime.startupTimestamp);
|
||||
if (launched)
|
||||
displayDuration("started", startup - launched);
|
||||
|
|
|
@ -810,6 +810,7 @@ NS_IMETHODIMP nsXULAppInfo::GetLaunchTimestamp(PRUint64 *aTimestamp)
|
|||
{
|
||||
#ifdef XP_UNIX
|
||||
FILE *uptime;
|
||||
long tickspersecond = sysconf(_SC_CLK_TCK);
|
||||
unsigned long long sec, ssec;
|
||||
|
||||
uptime = fopen("/proc/uptime", "r");
|
||||
|
@ -819,9 +820,10 @@ NS_IMETHODIMP nsXULAppInfo::GetLaunchTimestamp(PRUint64 *aTimestamp)
|
|||
|
||||
FILE *pidstat;
|
||||
pid_t pid = getpid();
|
||||
char *statpath = PR_smprintf("/proc/%d/uptime", pid);
|
||||
char *statpath = PR_smprintf("/proc/%d/stat", pid);
|
||||
pidstat = fopen(statpath, "r");
|
||||
PR_smprintf_free(statpath);
|
||||
if (!pidstat)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
char stat[512];
|
||||
memset(&stat, 0, 512);
|
||||
|
@ -829,6 +831,7 @@ NS_IMETHODIMP nsXULAppInfo::GetLaunchTimestamp(PRUint64 *aTimestamp)
|
|||
if (n <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
fclose(pidstat);
|
||||
PR_smprintf_free(statpath);
|
||||
|
||||
PRTime starttime = 0;
|
||||
sscanf(strrchr(stat, ')') + 2,
|
||||
|
@ -836,8 +839,7 @@ NS_IMETHODIMP nsXULAppInfo::GetLaunchTimestamp(PRUint64 *aTimestamp)
|
|||
"%*u %*u %*u %*u %*u %*d %*d %*d %*d %llu",
|
||||
&starttime);
|
||||
|
||||
printf("%llu, %llu\n", boottime, starttime * PR_USEC_PER_SEC);
|
||||
*aTimestamp = boottime + (starttime * PR_USEC_PER_SEC);
|
||||
*aTimestamp = boottime + ((starttime / tickspersecond) * PR_USEC_PER_SEC);
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
Загрузка…
Ссылка в новой задаче