tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GeolocationPosition.h (2837B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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 mozilla_dom_GeolocationPosition_h
      8 #define mozilla_dom_GeolocationPosition_h
      9 
     10 #include "js/TypeDecls.h"
     11 #include "nsCOMPtr.h"
     12 #include "nsCycleCollectionParticipant.h"
     13 #include "nsIDOMGeoPosition.h"
     14 #include "nsIDOMGeoPositionCoords.h"
     15 #include "nsWrapperCache.h"
     16 
     17 ////////////////////////////////////////////////////
     18 // nsGeoPositionCoords
     19 ////////////////////////////////////////////////////
     20 
     21 /**
     22 * Simple object that holds a single point in space.
     23 */
     24 class nsGeoPositionCoords final : public nsIDOMGeoPositionCoords {
     25 public:
     26  NS_DECL_THREADSAFE_ISUPPORTS
     27  NS_DECL_NSIDOMGEOPOSITIONCOORDS
     28 
     29  nsGeoPositionCoords(double aLat, double aLong, double aAlt, double aHError,
     30                      double aVError, double aHeading, double aSpeed);
     31 
     32 private:
     33  ~nsGeoPositionCoords();
     34  const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
     35 };
     36 
     37 ////////////////////////////////////////////////////
     38 // nsGeoPosition
     39 ////////////////////////////////////////////////////
     40 
     41 class nsGeoPosition final : public nsIDOMGeoPosition {
     42 public:
     43  NS_DECL_THREADSAFE_ISUPPORTS
     44  NS_DECL_NSIDOMGEOPOSITION
     45 
     46  nsGeoPosition(double aLat, double aLong, double aAlt, double aHError,
     47                double aVError, double aHeading, double aSpeed,
     48                EpochTimeStamp aTimestamp);
     49 
     50  nsGeoPosition(nsIDOMGeoPositionCoords* aCoords, EpochTimeStamp aTimestamp);
     51 
     52 private:
     53  ~nsGeoPosition();
     54  EpochTimeStamp mTimestamp;
     55  RefPtr<nsIDOMGeoPositionCoords> mCoords;
     56 };
     57 
     58 ////////////////////////////////////////////////////
     59 // WebIDL wrappers for the classes above
     60 ////////////////////////////////////////////////////
     61 
     62 namespace mozilla::dom {
     63 
     64 class GeolocationCoordinates;
     65 
     66 class GeolocationPosition final : public nsISupports, public nsWrapperCache {
     67  ~GeolocationPosition();
     68 
     69 public:
     70  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     71  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(GeolocationPosition)
     72 
     73 public:
     74  GeolocationPosition(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition);
     75 
     76  nsISupports* GetParentObject() const;
     77 
     78  virtual JSObject* WrapObject(JSContext* aCx,
     79                               JS::Handle<JSObject*> aGivenProto) override;
     80 
     81  GeolocationCoordinates* Coords();
     82 
     83  uint64_t Timestamp() const;
     84 
     85  nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
     86 
     87 private:
     88  RefPtr<GeolocationCoordinates> mCoordinates;
     89  nsCOMPtr<nsISupports> mParent;
     90  nsCOMPtr<nsIDOMGeoPosition> mGeoPosition;
     91 };
     92 
     93 }  // namespace mozilla::dom
     94 
     95 #endif /* mozilla_dom_GeolocationPosition_h */