Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsISupports.idl"
7 interface nsIDOMDOMRequest;
9 /**
10 * Represents a data interface for which the manager is recording statistics.
11 */
12 [scriptable, uuid(f540615b-d803-43ff-8200-2a9d145a5645)]
13 interface nsIDOMMozNetworkStatsInterface : nsISupports
14 {
15 readonly attribute long type;
17 /**
18 * Id value is '0' for wifi or the iccid for mobile (SIM).
19 */
20 readonly attribute DOMString id;
21 };
23 [scriptable, builtinclass, uuid(063ebeb2-5c6e-47ae-bdcd-5e6ebdc7a68c)]
24 interface nsIDOMMozNetworkStatsAlarm : nsISupports
25 {
26 readonly attribute unsigned long alarmId;
27 readonly attribute nsIDOMMozNetworkStatsInterface network;
28 readonly attribute long threshold;
29 readonly attribute jsval data;
30 };
32 [scriptable, uuid(8a66f4c1-0c25-4a66-9fc5-0106947b91f9)]
33 interface nsIDOMMozNetworkStatsManager : nsISupports
34 {
35 /**
36 * Constants for known interface types.
37 */
38 const long WIFI = 0;
39 const long MOBILE = 1;
41 /**
42 * Find samples between two dates start and end, both included.
43 *
44 * If options is provided, per-app or per-system service usage will be
45 * retrieved; otherwise the target will be overall system usage.
46 *
47 * If success, the request result will be an nsIDOMMozNetworkStats object.
48 */
49 nsIDOMDOMRequest getSamples(in nsIDOMMozNetworkStatsInterface network,
50 in jsval start,
51 in jsval end,
52 [optional] in jsval options /* NetworkStatsGetOptions */);
54 /**
55 * Install an alarm on a network. The network must be in the return of
56 * getAvailableNetworks() otherwise an "InvalidNetwork" exception will
57 * be raised.
58 *
59 * When total data usage reaches threshold bytes, a "networkstats-alarm"
60 * system message is sent to the application, where the optional parameter
61 * |data| must be a cloneable object.
62 *
63 * If success, the |result| field of the DOMRequest keeps the alarm Id.
64 */
65 nsIDOMDOMRequest addAlarm(in nsIDOMMozNetworkStatsInterface network,
66 in long threshold,
67 [optional] in jsval options /* NetworkStatsAlarmOptions */);
69 /**
70 * Obtain all alarms for those networks returned by getAvailableNetworks().
71 * If a network is provided, only retrieves the alarms for that network.
72 * The network must be one of those returned by getAvailebleNetworks() or an
73 * "InvalidNetwork" exception will be raised.
74 *
75 * Each alarm object has the same fields as that in the system message:
76 * - alarmId
77 * - network
78 * - threshold
79 * - data
80 */
81 nsIDOMDOMRequest getAllAlarms([optional] in nsIDOMMozNetworkStatsInterface network);
83 /**
84 * Remove all network alarms. If an |alarmId| is provided, then only that
85 * alarm is removed.
86 */
87 nsIDOMDOMRequest removeAlarms([optional] in long alarmId);
89 /**
90 * Remove all stats related with the provided network from DB.
91 */
92 nsIDOMDOMRequest clearStats(in nsIDOMMozNetworkStatsInterface network);
94 /**
95 * Remove all stats in the database.
96 */
97 nsIDOMDOMRequest clearAllStats();
99 /**
100 * Return available networks that used to be saved in the database.
101 */
102 nsIDOMDOMRequest getAvailableNetworks(); // array of nsIDOMMozNetworkStatsInterface.
104 /**
105 * Return available service types that used to be saved in the database.
106 */
107 nsIDOMDOMRequest getAvailableServiceTypes(); // array of string.
109 /**
110 * Minimum time in milliseconds between samples stored in the database.
111 */
112 readonly attribute long sampleRate;
114 /**
115 * Time in milliseconds recorded by the API until present time. All samples
116 * older than maxStorageAge from now are deleted.
117 */
118 readonly attribute long long maxStorageAge;
119 };