dom/network/src/Connection.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/network/src/Connection.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_dom_network_Connection_h
    1.10 +#define mozilla_dom_network_Connection_h
    1.11 +
    1.12 +#include "Types.h"
    1.13 +#include "mozilla/DOMEventTargetHelper.h"
    1.14 +#include "mozilla/Observer.h"
    1.15 +#include "mozilla/dom/NetworkInformationBinding.h"
    1.16 +#include "nsCycleCollectionParticipant.h"
    1.17 +#include "nsINetworkProperties.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +
    1.21 +namespace hal {
    1.22 +class NetworkInformation;
    1.23 +} // namespace hal
    1.24 +
    1.25 +namespace dom {
    1.26 +namespace network {
    1.27 +
    1.28 +class Connection MOZ_FINAL : public DOMEventTargetHelper
    1.29 +                           , public NetworkObserver
    1.30 +                           , public nsINetworkProperties
    1.31 +{
    1.32 +public:
    1.33 +  NS_DECL_ISUPPORTS_INHERITED
    1.34 +  NS_DECL_NSINETWORKPROPERTIES
    1.35 +
    1.36 +  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    1.37 +
    1.38 +  Connection();
    1.39 +
    1.40 +  void Init(nsPIDOMWindow *aWindow);
    1.41 +  void Shutdown();
    1.42 +
    1.43 +  // For IObserver
    1.44 +  void Notify(const hal::NetworkInformation& aNetworkInfo);
    1.45 +
    1.46 +  // WebIDL
    1.47 +
    1.48 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.49 +
    1.50 +  ConnectionType Type() const { return mType; }
    1.51 +
    1.52 +  IMPL_EVENT_HANDLER(typechange)
    1.53 +
    1.54 +private:
    1.55 +  /**
    1.56 +   * Update the connection information stored in the object using a
    1.57 +   * NetworkInformation object.
    1.58 +   */
    1.59 +  void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo);
    1.60 +
    1.61 +  /**
    1.62 +   * The type of current connection.
    1.63 +   */
    1.64 +  ConnectionType mType;
    1.65 +
    1.66 +  /**
    1.67 +   * If the connection is WIFI
    1.68 +   */
    1.69 +  bool mIsWifi;
    1.70 +
    1.71 +  /**
    1.72 +   * DHCP Gateway information for IPV4, in network byte order. 0 if unassigned.
    1.73 +   */
    1.74 +  uint32_t mDHCPGateway;
    1.75 +};
    1.76 +
    1.77 +} // namespace network
    1.78 +} // namespace dom
    1.79 +} // namespace mozilla
    1.80 +
    1.81 +#endif // mozilla_dom_network_Connection_h

mercurial