• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. B2G OS APIs
  5. MozNetworkStatsManager
  6. MozNetworkStatsManager.getSamples()

MozNetworkStatsManager.getSamples()

In This Article
  1. Summary
  2. Syntax
  3. Parameters
  4. Return
  5. Exceptions
  6. Specifications
  7. See also

This API is available on Firefox OS for internal applications only.

Summary

The getSamples method asynchronously queries network interface statistics. The query may be filtered by connection type and date.

A data usage chunk is a MozNetworkStatsData object representing the total number of bits received and sent during the amount of time defined by the sampleRate property.

Syntax

var samples = getSamples(network, start, end, options);
samples.onsuccess = function() {
  // do something with samples.result
}

Parameters

network
The origin of the data; it can be specified as wifi or mobile. If null, data measurement from both origins are merged. To know in advance which kind of origin is available, the MozNetworkStatsManager.getAvailableNetworks method returns an Array of interfaces.
start
A Date object representing the beginning of data measurement.
end
A Date object representing the end of data measurement.
options Optional
Filtering options.
NetworkStatsGetOptions is a dictionary object providing filtering options.

Return

A DOMRequest object. If successful, the request result is a MozNetworkStats 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.

Exceptions

NS_ERROR_INVALID_ARG
The filtering start date is greater than the end date.
NS_ERROR_NOT_IMPLMENTED
Both appManifestURL and serviceType are specified at the same time in the NetworkStatsGetOptions dictionary.
InvalidNetwork
The network must be in the return of MozNetworkStatsManager.getAvailableNetworks.

Specifications

Not part of any specification.

See also

  • MozNetworkStatsManager
  • Network Stats API

Document Tags and Contributors

Tags: 
  • API
  • B2G
  • Firefox OS
  • Method
  • Non-standard
  • Reference
  • Référence
 Contributors to this page: kmag, chrisdavidmills, kscarfone, zeller
 Last updated by: kmag, Apr 27, 2017, 5:56:22 AM
See also
  1. Network Stats API
  2. Archive
  3. Related pages for Network Stats API
    1. MozNetworkStats
    2. MozNetworkStatsData
    3. MozNetworkStatsManager