|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef NetworkActivityMonitor_h___ |
|
8 #define NetworkActivityMonitor_h___ |
|
9 |
|
10 #include <stdint.h> |
|
11 #include "nscore.h" |
|
12 #include "prio.h" |
|
13 #include "prinrval.h" |
|
14 |
|
15 namespace mozilla { namespace net { |
|
16 |
|
17 class NetworkActivityMonitor |
|
18 { |
|
19 public: |
|
20 enum Direction { |
|
21 kUpload = 0, |
|
22 kDownload = 1 |
|
23 }; |
|
24 |
|
25 NetworkActivityMonitor(); |
|
26 ~NetworkActivityMonitor(); |
|
27 |
|
28 static nsresult Init(int32_t blipInterval); |
|
29 static nsresult Shutdown(); |
|
30 |
|
31 static nsresult AttachIOLayer(PRFileDesc *fd); |
|
32 static nsresult DataInOut(Direction direction); |
|
33 |
|
34 private: |
|
35 nsresult Init_Internal(int32_t blipInterval); |
|
36 void PostNotification(Direction direction); |
|
37 |
|
38 static NetworkActivityMonitor * gInstance; |
|
39 PRDescIdentity mLayerIdentity; |
|
40 PRIOMethods mLayerMethods; |
|
41 PRIntervalTime mBlipInterval; |
|
42 PRIntervalTime mLastNotificationTime[2]; |
|
43 }; |
|
44 |
|
45 }} // namespace mozilla::net |
|
46 |
|
47 #endif /* NetworkActivityMonitor_h___ */ |