dom/network/interfaces/nsIDOMNetworkStatsManager.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/network/interfaces/nsIDOMNetworkStatsManager.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,119 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsISupports.idl"
     1.9 +
    1.10 +interface nsIDOMDOMRequest;
    1.11 +
    1.12 +/**
    1.13 + * Represents a data interface for which the manager is recording statistics.
    1.14 + */
    1.15 +[scriptable, uuid(f540615b-d803-43ff-8200-2a9d145a5645)]
    1.16 +interface nsIDOMMozNetworkStatsInterface : nsISupports
    1.17 +{
    1.18 +  readonly attribute long type;
    1.19 +
    1.20 +  /**
    1.21 +   * Id value is '0' for wifi or the iccid for mobile (SIM).
    1.22 +   */
    1.23 +  readonly attribute DOMString id;
    1.24 +};
    1.25 +
    1.26 +[scriptable, builtinclass, uuid(063ebeb2-5c6e-47ae-bdcd-5e6ebdc7a68c)]
    1.27 +interface nsIDOMMozNetworkStatsAlarm : nsISupports
    1.28 +{
    1.29 +  readonly attribute unsigned long alarmId;
    1.30 +  readonly attribute nsIDOMMozNetworkStatsInterface network;
    1.31 +  readonly attribute long threshold;
    1.32 +  readonly attribute jsval data;
    1.33 +};
    1.34 +
    1.35 +[scriptable,  uuid(8a66f4c1-0c25-4a66-9fc5-0106947b91f9)]
    1.36 +interface nsIDOMMozNetworkStatsManager : nsISupports
    1.37 +{
    1.38 +  /**
    1.39 +   * Constants for known interface types.
    1.40 +   */
    1.41 +  const long WIFI = 0;
    1.42 +  const long MOBILE = 1;
    1.43 +
    1.44 +  /**
    1.45 +   * Find samples between two dates start and end, both included.
    1.46 +   *
    1.47 +   * If options is provided, per-app or per-system service usage will be
    1.48 +   * retrieved; otherwise the target will be overall system usage.
    1.49 +   *
    1.50 +   * If success, the request result will be an nsIDOMMozNetworkStats object.
    1.51 +   */
    1.52 +  nsIDOMDOMRequest getSamples(in nsIDOMMozNetworkStatsInterface network,
    1.53 +                              in jsval start,
    1.54 +                              in jsval end,
    1.55 +                   [optional] in jsval options /* NetworkStatsGetOptions */);
    1.56 +
    1.57 +  /**
    1.58 +   * Install an alarm on a network. The network must be in the return of
    1.59 +   * getAvailableNetworks() otherwise an "InvalidNetwork" exception will
    1.60 +   * be raised.
    1.61 +   *
    1.62 +   * When total data usage reaches threshold bytes, a "networkstats-alarm"
    1.63 +   * system message is sent to the application, where the optional parameter
    1.64 +   * |data| must be a cloneable object.
    1.65 +   *
    1.66 +   * If success, the |result| field of the DOMRequest keeps the alarm Id.
    1.67 +   */
    1.68 +  nsIDOMDOMRequest addAlarm(in nsIDOMMozNetworkStatsInterface network,
    1.69 +                            in long threshold,
    1.70 +                            [optional] in jsval options /* NetworkStatsAlarmOptions */);
    1.71 +
    1.72 +  /**
    1.73 +   * Obtain all alarms for those networks returned by getAvailableNetworks().
    1.74 +   * If a network is provided, only retrieves the alarms for that network.
    1.75 +   * The network must be one of those returned by getAvailebleNetworks() or an
    1.76 +   * "InvalidNetwork" exception will be raised.
    1.77 +   *
    1.78 +   * Each alarm object has the same fields as that in the system message:
    1.79 +   *  - alarmId
    1.80 +   *  - network
    1.81 +   *  - threshold
    1.82 +   *  - data
    1.83 +   */
    1.84 +  nsIDOMDOMRequest getAllAlarms([optional] in nsIDOMMozNetworkStatsInterface network);
    1.85 +
    1.86 +  /**
    1.87 +   * Remove all network alarms. If an |alarmId| is provided, then only that
    1.88 +   * alarm is removed.
    1.89 +   */
    1.90 +  nsIDOMDOMRequest removeAlarms([optional] in long alarmId);
    1.91 +
    1.92 +  /**
    1.93 +   * Remove all stats related with the provided network from DB.
    1.94 +   */
    1.95 +  nsIDOMDOMRequest clearStats(in nsIDOMMozNetworkStatsInterface network);
    1.96 +
    1.97 +  /**
    1.98 +   * Remove all stats in the database.
    1.99 +   */
   1.100 +  nsIDOMDOMRequest clearAllStats();
   1.101 +
   1.102 +  /**
   1.103 +   * Return available networks that used to be saved in the database.
   1.104 +   */
   1.105 +  nsIDOMDOMRequest getAvailableNetworks(); // array of nsIDOMMozNetworkStatsInterface.
   1.106 +
   1.107 +  /**
   1.108 +   * Return available service types that used to be saved in the database.
   1.109 +   */
   1.110 +  nsIDOMDOMRequest getAvailableServiceTypes(); // array of string.
   1.111 +
   1.112 +  /**
   1.113 +   * Minimum time in milliseconds between samples stored in the database.
   1.114 +   */
   1.115 +  readonly attribute long sampleRate;
   1.116 +
   1.117 +  /**
   1.118 +   * Time in milliseconds recorded by the API until present time. All samples
   1.119 +   * older than maxStorageAge from now are deleted.
   1.120 +   */
   1.121 +  readonly attribute long long maxStorageAge;
   1.122 +};

mercurial