NOTE: Gecko is a fast evolving project. Please check dom/network/interfaces/nsIDOMNetworkStatsManager.idl to make sure this data is accurate.
nsISupports
Last changed in Gecko 18.0 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15)Implemented by: @mozilla.org/networkStatsManager;1
. To create an instance, use:
var networkStatsManager = Components.classes["@mozilla.org/networkStatsManager;1"] .createInstance(Components.interfaces.nsIDOMNetworkStatsManager);
Furthermore, the NetworkStatsManager is published through a mozNetworkStats
child object within the navigator
object. If the object exists, you can use the Network Statistics service. You can test for the presence of the service as follows, for example:
if ("mozNetworkStats" in navigator) { /* NetworkStats is available */ } else { alert("I'm sorry, but NetworkStats services are not supported."); }
nsIDOMDOMRequest getSamples(in nsISupports network, |
nsIDOMDOMRequest addAlarm(in nsISupports network, |
nsIDOMDOMRequest getAllAlarms([optional] in nsISupports network); |
nsIDOMDOMRequest removeAlarms([optional] in long alarmId); |
nsIDOMDOMRequest clearStats(in nsISupports network); |
nsIDOMDOMRequest clearAllStats(); |
nsIDOMDOMRequest getAvailableNetworks(); |
nsIDOMDOMRequest getAvailableServiceTypes(); |
Attribute | Type | Description |
sampleRate |
long |
Minimum time in milliseconds between samples stored in the database. Read only. |
maxStorageAge |
long long |
Time in milliseconds recorded by the API until present time. All samples older than maxStorageAge from now are deleted. Read only. |
Constant | Type | Description |
---|---|---|
WIFI | long | Constant for WIFI, set to 0 |
MOBILE | long | Constant for MOBILE, set to 1 |
Asynchronously queries network interface statistics. The query may be filtered by connection type and date.
nsIDOMDOMRequest getSamples(in nsISupports network,
in jsval start,
in jsval end,
[optional] in jsval options /* NetworkStatsGetOptions */);
network
start
end
options
OptionalNetworkStatsGetOptions
is a dictionary object providing filtering options.An nsIDOMDOMRequest
object. If successful, the request result is an nsIDOMMozNetworkStats
object describing the network statistics. If network stats are not available for some dates, then rxBytes
and txBytes
are undefined for those dates. If the filtering start date is greater than the end date, an exception is thrown.
NS_ERROR_INVALID_ARG
start
date is greater than the end
date.NS_ERROR_NOT_IMPLMENTED
InvalidNetwork
Install an alarm on a network. When total data usage reaches threshold
bytes, a "networkstats-alarm" system message is sent to the application, where the optional parameter data
must be a cloneable object.
nsIDOMDOMRequest addAlarm(in nsISupports network, in long threshold, [optional] in jsval options /* NetworkStatsAlarmOptions */);
network
threshold
options
OptionalAn nsIDOMDOMRequest
object. If successful, the result
field of the DOMRequest keeps the alarm Id.
network
must be in the return of getAvailableNetworks.Obtain all alarms for those networks returned by getAvailableNetworks. If a network is provided, only retrieves the alarms for that network.
nsIDOMDOMRequest getAllAlarms([optional] in nsISupports network);
network
OptionalAn Alarm object with the same fields as that in the system message; alarmId, network, threshold, and data.
Remove all network alarms. If an alarmId
is provided, then only that alarm is removed.
nsIDOMDOMRequest removeAlarms([optional] in long alarmId);
alarmID
An nsIDOMDOMRequest
object.
Remove all stats related with the provided network from DB.
nsIDOMDOMRequest clearStats(in nsISupports network);
network
An nsIDOMDOMRequest
object.
Clears all statistics from the statistics database.
void clearAllStats();
None.
An nsIDOMDOMRequest
object.
Returns available networks that used to be saved in the database.
nsIDOMDOMRequest getAvailableNetworks();
None.
An nsIDOMDOMRequest
object. If successful, the result field of the DOMRequest holds an array of the currently available network interfaces.
Returns available service types that used to be saved in the database.
nsIDOMDOMRequest getAvailableServiceTypes();
None.
An nsIDOMDOMRequest
object. If successful, the result field of the DOMRequest holds an array of the currently available service types.
NetworkStatsAlarmOptions
is a dictionary object used to filter an alarm request made when calling addAlarm()
. It contains the following fields:
startTime
data
NetworkStatsGetOptions
is a dictionary object used to filter a network statistics request made when calling getSamples()
. It contains the following fields:
appManifestURL
serviceType
browsingTrafficOnly
For example, this object might be { appManifestURL : manifestURL }
.