netwerk/wifi/nsWifiMonitor.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     5 #ifndef __nsWifiMonitor__
     6 #define __nsWifiMonitor__
     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/ReentrantMonitor.h"
    17 #include "prlog.h"
    18 #include "nsIObserver.h"
    19 #include "nsTArray.h"
    20 #include "nsITimer.h"
    21 #include "mozilla/Attributes.h"
    22 #include "nsIInterfaceRequestor.h"
    24 #if defined(PR_LOGGING)
    25 extern PRLogModuleInfo *gWifiMonitorLog;
    26 #endif
    27 #define LOG(args)     PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
    29 class nsWifiAccessPoint;
    31 class nsWifiListener
    32 {
    33  public:
    35   nsWifiListener(nsMainThreadPtrHolder<nsIWifiListener>* aListener)
    36   {
    37     mListener = aListener;
    38     mHasSentData = false;
    39   }
    40   ~nsWifiListener() {}
    42   nsMainThreadPtrHandle<nsIWifiListener> mListener;
    43   bool mHasSentData;
    44 };
    46 #ifndef MOZ_WIDGET_GONK
    47 class nsWifiMonitor MOZ_FINAL : nsIRunnable, nsIWifiMonitor, nsIObserver
    48 {
    49  public:
    50   NS_DECL_THREADSAFE_ISUPPORTS
    51   NS_DECL_NSIWIFIMONITOR
    52   NS_DECL_NSIRUNNABLE
    53   NS_DECL_NSIOBSERVER
    55   nsWifiMonitor();
    57  private:
    58   ~nsWifiMonitor();
    60   nsresult DoScan();
    62   nsresult CallWifiListeners(const nsCOMArray<nsWifiAccessPoint> &aAccessPoints,
    63                              bool aAccessPointsChanged);
    65   bool mKeepGoing;
    66   nsCOMPtr<nsIThread> mThread;
    68   nsTArray<nsWifiListener> mListeners;
    70   mozilla::ReentrantMonitor mReentrantMonitor;
    72 };
    73 #else
    74 #include "nsIWifi.h"
    75 class nsWifiMonitor MOZ_FINAL : nsIWifiMonitor, nsIWifiScanResultsReady, nsIObserver
    76 {
    77  public:
    78   NS_DECL_ISUPPORTS
    79   NS_DECL_NSIWIFIMONITOR
    80   NS_DECL_NSIOBSERVER
    81   NS_DECL_NSIWIFISCANRESULTSREADY
    83   nsWifiMonitor();
    85  private:
    86   ~nsWifiMonitor();
    88   void ClearTimer() {
    89     if (mTimer) {
    90       mTimer->Cancel();
    91       mTimer = nullptr;
    92     }
    93   }
    94   nsCOMArray<nsWifiAccessPoint> mLastAccessPoints;
    95   nsTArray<nsWifiListener> mListeners;
    96   nsCOMPtr<nsITimer> mTimer;
    97 };
    98 #endif
   100 #endif

mercurial