WebAPI/ResourceStats: Difference between revisions
< WebAPI
Jump to navigation
Jump to search
(Created page with "== Goals == ResourceStats API provides a generic interface to access resource statistics of Firefox OS devices.") |
No edit summary |
||
| Line 1: | Line 1: | ||
== | == Objective == | ||
ResourceStats API provides a generic interface to access resource statistics of Firefox OS devices. | ResourceStats API provides a generic interface to access resource statistics of Firefox OS devices. It also provides an interface for resource control. | ||
== Implementation == | |||
=== WebIDl Definition === | |||
==== ResourceStats.webidl ==== | |||
[JSImplementation="@mozilla.org/networkStatsData;1", Pref="dom.resourceStats.enabled", AvailableIn="CertifiedApps"] | |||
interface NetworkStatsData | |||
{ | |||
readonly attribute unsigned long long receivedBytes; | |||
readonly attribute unsigned long long sentBytes; | |||
readonly attribute DOMTimeStamp timestamp; // timestamp of the record | |||
}; | |||
[JSImplementation="@mozilla.org/powerStatsData;1", Pref="dom.resourceStats.enabled", AvailableIn="CertifiedApps"] | |||
interface PowerStatsData | |||
{ | |||
readonly attribute unsigned long long consumedPower; // unit: mW | |||
readonly attribute DOMTimeStamp timestamp; // timestamp of the record | |||
}; | |||
[JSImplementation="@mozilla.org/resourceStats;1", Pref="dom.resourceStats.enabled", AvailableIn="CertifiedApps"] | |||
interface ResourceStats | |||
{ | |||
/** | |||
* Type of statistics/ | |||
*/ | |||
readonly attribute ResourceType type; | |||
/** | |||
* The component that statistics belongs to. | |||
* If null, sum of all components' statistics are returned. | |||
*/ | |||
readonly attribute DOMString? component; | |||
/** | |||
* |serviceType| specifies the system service. | |||
* |manifestURL| specifies the manifestURL of an application. | |||
* | |||
* If both |systemService| and |manifestURL| are null, then getStats() | |||
* returns a system-wide resource statistics. | |||
* | |||
* If |manifestURL| is not null, then getStats() returns statistics of | |||
* that application. | |||
* | |||
* If |serviceType| is not null, then getStats returns statistics of | |||
* that system service. | |||
* | |||
* If both |systemService| and |manifestURL| are specified, then the returned | |||
* statistics indicates the resources that the system service consumed for | |||
* the application. | |||
*/ | |||
readonly attribute SystemService? serviceType; | |||
readonly attribute DOMString? manifestURL; | |||
/** | |||
* Statistics, one element per day | |||
*/ | |||
sequence<(NetworkStatsData or PowerStatsData)> getStats(); | |||
/** | |||
* Date range | |||
*/ | |||
readonly attribute DOMTimeStamp start; // start timestamp | |||
readonly attribute DOMTimeStamp end; // end timestamp | |||
}; | |||
==== ResourceStatsManager.webidl ==== | |||
Revision as of 06:36, 10 February 2014
Objective
ResourceStats API provides a generic interface to access resource statistics of Firefox OS devices. It also provides an interface for resource control.
Implementation
WebIDl Definition
ResourceStats.webidl
[JSImplementation="@mozilla.org/networkStatsData;1", Pref="dom.resourceStats.enabled", AvailableIn="CertifiedApps"]
interface NetworkStatsData
{
readonly attribute unsigned long long receivedBytes;
readonly attribute unsigned long long sentBytes;
readonly attribute DOMTimeStamp timestamp; // timestamp of the record
};
[JSImplementation="@mozilla.org/powerStatsData;1", Pref="dom.resourceStats.enabled", AvailableIn="CertifiedApps"]
interface PowerStatsData
{
readonly attribute unsigned long long consumedPower; // unit: mW
readonly attribute DOMTimeStamp timestamp; // timestamp of the record
};
[JSImplementation="@mozilla.org/resourceStats;1", Pref="dom.resourceStats.enabled", AvailableIn="CertifiedApps"]
interface ResourceStats
{
/**
* Type of statistics/
*/
readonly attribute ResourceType type;
/**
* The component that statistics belongs to.
* If null, sum of all components' statistics are returned.
*/
readonly attribute DOMString? component;
/**
* |serviceType| specifies the system service.
* |manifestURL| specifies the manifestURL of an application.
*
* If both |systemService| and |manifestURL| are null, then getStats()
* returns a system-wide resource statistics.
*
* If |manifestURL| is not null, then getStats() returns statistics of
* that application.
*
* If |serviceType| is not null, then getStats returns statistics of
* that system service.
*
* If both |systemService| and |manifestURL| are specified, then the returned
* statistics indicates the resources that the system service consumed for
* the application.
*/
readonly attribute SystemService? serviceType;
readonly attribute DOMString? manifestURL;
/**
* Statistics, one element per day
*/
sequence<(NetworkStatsData or PowerStatsData)> getStats();
/**
* Date range
*/
readonly attribute DOMTimeStamp start; // start timestamp
readonly attribute DOMTimeStamp end; // end timestamp
};