Bug 858005 - Part 1: IDL definition. r=jonas
authorAlbert Crespell <acperez@tid.es>
Fri, 24 May 2013 11:27:02 +0200
changeset 173907 2052ba4c936cdf1fe892894810468db216271164
parent 173906 e58eacde9b4bb18aea91c0c09a70a500e42e0ed8
child 173908 97b690fd7806dfdb0c0ac9e8c0469d1b77e7018a
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonas
bugs858005
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 858005 - Part 1: IDL definition. r=jonas
dom/network/interfaces/nsIDOMNetworkStatsManager.idl
--- a/dom/network/interfaces/nsIDOMNetworkStatsManager.idl
+++ b/dom/network/interfaces/nsIDOMNetworkStatsManager.idl
@@ -15,17 +15,32 @@ interface nsIDOMMozNetworkStatsInterface
   readonly attribute long type;
 
   /**
    * Id value is '0' for wifi or the iccid for mobile (SIM).
    */
   readonly attribute DOMString id;
 };
 
-[scriptable, uuid(5f033d31-c9a2-4e2d-83aa-6a807f1e0c11)]
+dictionary NetworkStatsAlarmOptions
+{
+  jsval startTime; // Date object
+  jsval data;
+};
+
+[scriptable, builtinclass, uuid(063ebeb2-5c6e-47ae-bdcd-5e6ebdc7a68c)]
+interface nsIDOMMozNetworkStatsAlarm : nsISupports
+{
+  readonly attribute unsigned long alarmId;
+  readonly attribute nsIDOMMozNetworkStatsInterface network;
+  readonly attribute long threshold;
+  readonly attribute jsval data;
+};
+
+[scriptable,  uuid(50d109b8-0d7f-4208-81fe-5f07a759f159)]
 interface nsIDOMMozNetworkStatsManager : nsISupports
 {
   /**
    * Constants for known interface types.
    */
   const long WIFI = 0;
   const long MOBILE = 1;
 
@@ -38,16 +53,51 @@ interface nsIDOMMozNetworkStatsManager :
    * If success, the request result will be an nsIDOMMozNetworkStats object.
    */
   nsIDOMDOMRequest getSamples(in nsIDOMMozNetworkStatsInterface network,
                               in jsval start,
                               in jsval end,
                               [optional] in DOMString manifestURL);
 
   /**
+   * Install an alarm on a network. The network must be in the return of
+   * getAvailableNetworks() otherwise an "InvalidNetwork" exception will
+   * be raised.
+   *
+   * 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.
+   *
+   * If success, the |result| field of the DOMRequest keeps the alarm Id.
+   */
+  nsIDOMDOMRequest addAlarm(in nsIDOMMozNetworkStatsInterface network,
+                            in long threshold,
+                            [optional] in jsval options /* NetworkStatsAlarmOptions */);
+
+  /**
+   * Obtain all alarms for those networks returned by getAvailableNetworks().
+   * If a network is provided, only retrieves the alarms for that network.
+   * The network must be one of those returned by getAvailebleNetworks() or an
+   * "InvalidNetwork" exception will be raised.
+   *
+   * Each alarm object has the same fields as that in the system message:
+   *  - alarmId
+   *  - network
+   *  - threshold
+   *  - data
+   */
+  nsIDOMDOMRequest getAllAlarms([optional] in nsIDOMMozNetworkStatsInterface network);
+
+  /**
+   * Remove all network alarms. If an |alarmId| is provided, then only that
+   * alarm is removed.
+   */
+  nsIDOMDOMRequest removeAlarms([optional] in long alarmId);
+
+  /**
    * Remove all stats related with the provided network from DB.
    */
   nsIDOMDOMRequest clearStats(in nsIDOMMozNetworkStatsInterface network);
 
   /**
    * Remove all stats in the database.
    */
   nsIDOMDOMRequest clearAllStats();