mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 22:05:40 +00:00
Bug 969490. Add a Components.utils.now() that provides access in system JS to a monotonic timer, returning a fractional number milliseconds since process creation. r=bholley
This commit is contained in:
parent
76b35cb721
commit
dfeaa19d76
@ -122,7 +122,7 @@ interface ScheduledGCCallback : nsISupports
|
||||
/**
|
||||
* interface of Components.utils
|
||||
*/
|
||||
[scriptable, uuid(10bcc595-ccca-4ead-aae3-d12b47cd9fff)]
|
||||
[scriptable, uuid(60b1ddd1-7567-41da-85f6-638096acd564)]
|
||||
interface nsIXPCComponents_Utils : nsISupports
|
||||
{
|
||||
|
||||
@ -642,6 +642,12 @@ interface nsIXPCComponents_Utils : nsISupports
|
||||
|
||||
[implicit_jscontext]
|
||||
void setAddonInterposition(in ACString addonId, in nsIAddonInterposition interposition);
|
||||
|
||||
/*
|
||||
* Return a fractional number of milliseconds from process
|
||||
* startup, measured with a monotonic clock.
|
||||
*/
|
||||
double now();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "mozilla/StartupTimeline.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/DOMExceptionBinding.h"
|
||||
@ -3552,6 +3554,14 @@ nsXPCComponents_Utils::SetAddonInterposition(const nsACString &addonIdStr,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::Now(double *aRetval)
|
||||
{
|
||||
TimeStamp start = StartupTimeline::Get(StartupTimeline::PROCESS_CREATION);
|
||||
*aRetval = (TimeStamp::Now() - start).ToMilliseconds();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user