Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/wifi/nsWifiMonitor.h
Line
Count
Source (jump to first uncovered line)
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
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef __nsWifiMonitor__
6
#define __nsWifiMonitor__
7
8
#include "nsIWifiMonitor.h"
9
#include "nsCOMPtr.h"
10
#include "nsAutoPtr.h"
11
#include "nsProxyRelease.h"
12
#include "nsIThread.h"
13
#include "nsIRunnable.h"
14
#include "nsCOMArray.h"
15
#include "nsIWifiListener.h"
16
#include "mozilla/Atomics.h"
17
#include "mozilla/ReentrantMonitor.h"
18
#include "mozilla/Logging.h"
19
#include "nsIObserver.h"
20
#include "nsTArray.h"
21
#include "nsITimer.h"
22
#include "mozilla/Attributes.h"
23
#include "nsIInterfaceRequestor.h"
24
25
#ifdef XP_WIN
26
#include "win_wifiScanner.h"
27
#endif
28
29
extern mozilla::LazyLogModule gWifiMonitorLog;
30
#define LOG(args)     MOZ_LOG(gWifiMonitorLog, mozilla::LogLevel::Debug, args)
31
32
class nsWifiAccessPoint;
33
34
0
#define kDefaultWifiScanInterval 5 /* seconds */
35
36
class nsWifiListener
37
{
38
 public:
39
40
  explicit nsWifiListener(nsMainThreadPtrHolder<nsIWifiListener>* aListener)
41
0
  {
42
0
    mListener = aListener;
43
0
    mHasSentData = false;
44
0
  }
45
0
  ~nsWifiListener() = default;
46
47
  nsMainThreadPtrHandle<nsIWifiListener> mListener;
48
  bool mHasSentData;
49
};
50
51
class nsWifiMonitor final : nsIRunnable, nsIWifiMonitor, nsIObserver
52
{
53
 public:
54
  NS_DECL_THREADSAFE_ISUPPORTS
55
  NS_DECL_NSIWIFIMONITOR
56
  NS_DECL_NSIRUNNABLE
57
  NS_DECL_NSIOBSERVER
58
59
  nsWifiMonitor();
60
61
 private:
62
0
  ~nsWifiMonitor() = default;
63
64
  nsresult DoScan();
65
66
  nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
67
                             bool aAccessPointsChanged);
68
69
  mozilla::Atomic<bool> mKeepGoing;
70
  mozilla::Atomic<bool> mThreadComplete;
71
  nsCOMPtr<nsIThread> mThread;
72
73
  nsTArray<nsWifiListener> mListeners;
74
75
  mozilla::ReentrantMonitor mReentrantMonitor;
76
77
#ifdef XP_WIN
78
  nsAutoPtr<WinWifiScanner> mWinWifiScanner;
79
#endif
80
};
81
82
#endif