netwerk/system/win32/nsNotifyAddrListener.h
author Francois Marier <francois@mozilla.com>
Tue, 18 Nov 2014 01:12:00 +0100
changeset 242695 199fcbb1b0187dc5ea98a4b701553bce14bd2b8e
parent 231799 b6cc542d38ffe8e2225c678739b8df9151d27935
child 302131 5cf375bf524d54dab84c9d4ada093cf08d6bb7b1
permissions -rw-r--r--
Bug 529697 - (CSP 1.1) Implement form-action directive [1/4], r=geekboy Teach CSP about the form-action directive from CSP Level 2.

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set et sw=4 ts=4: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NSNOTIFYADDRLISTENER_H_
#define NSNOTIFYADDRLISTENER_H_

#include <windows.h>
#include <winsock2.h>
#include <iptypes.h>
#include "nsINetworkLinkService.h"
#include "nsIRunnable.h"
#include "nsIObserver.h"
#include "nsThreadUtils.h"
#include "nsCOMPtr.h"
#include "mozilla/TimeStamp.h"

class nsNotifyAddrListener : public nsINetworkLinkService,
                             public nsIRunnable,
                             public nsIObserver
{
    virtual ~nsNotifyAddrListener();

public:
    NS_DECL_THREADSAFE_ISUPPORTS
    NS_DECL_NSINETWORKLINKSERVICE
    NS_DECL_NSIRUNNABLE
    NS_DECL_NSIOBSERVER

    nsNotifyAddrListener();

    nsresult Init(void);
    void CheckLinkStatus(void);

protected:
    class ChangeEvent : public nsRunnable {
    public:
        NS_DECL_NSIRUNNABLE
        ChangeEvent(nsINetworkLinkService *aService, const char *aEventID)
            : mService(aService), mEventID(aEventID) {
        }
    private:
        nsCOMPtr<nsINetworkLinkService> mService;
        const char *mEventID;
    };

    bool mLinkUp;
    bool mStatusKnown;
    bool mCheckAttempted;

    nsresult Shutdown(void);
    nsresult SendEvent(const char *aEventID);

    DWORD CheckAdaptersAddresses(void);

    // Checks for an Internet Connection Sharing (ICS) gateway.
    bool  CheckICSGateway(PIP_ADAPTER_ADDRESSES aAdapter);
    bool  CheckICSStatus(PWCHAR aAdapterName);

    nsCOMPtr<nsIThread> mThread;

    HANDLE        mShutdownEvent;

private:
    // This is a checksum of various meta data for all network interfaces
    // considered UP at last check.
    ULONG mIPInterfaceChecksum;

    // time of the last sent changed event
    mozilla::TimeStamp mChangedTime;

    // Network changed events are enabled
    bool mAllowChangedEvent;
};

#endif /* NSNOTIFYADDRLISTENER_H_ */