michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsGeoPosition_h michael@0: #define nsGeoPosition_h michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsIDOMGeoPositionCoords.h" michael@0: #include "nsIDOMGeoPosition.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "mozilla/dom/Nullable.h" michael@0: #include "js/TypeDecls.h" michael@0: michael@0: //////////////////////////////////////////////////// michael@0: // nsGeoPositionCoords michael@0: //////////////////////////////////////////////////// michael@0: michael@0: /** michael@0: * Simple object that holds a single point in space. michael@0: */ michael@0: class nsGeoPositionCoords MOZ_FINAL : public nsIDOMGeoPositionCoords michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIDOMGEOPOSITIONCOORDS michael@0: michael@0: nsGeoPositionCoords(double aLat, double aLong, michael@0: double aAlt, double aHError, michael@0: double aVError, double aHeading, michael@0: double aSpeed); michael@0: ~nsGeoPositionCoords(); michael@0: private: michael@0: const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed; michael@0: }; michael@0: michael@0: michael@0: //////////////////////////////////////////////////// michael@0: // nsGeoPosition michael@0: //////////////////////////////////////////////////// michael@0: michael@0: class nsGeoPosition MOZ_FINAL : public nsIDOMGeoPosition michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIDOMGEOPOSITION michael@0: michael@0: nsGeoPosition(double aLat, double aLong, michael@0: double aAlt, double aHError, michael@0: double aVError, double aHeading, michael@0: double aSpeed, long long aTimestamp); michael@0: michael@0: michael@0: nsGeoPosition(nsIDOMGeoPositionCoords *aCoords, michael@0: long long aTimestamp); michael@0: michael@0: nsGeoPosition(nsIDOMGeoPositionCoords *aCoords, michael@0: DOMTimeStamp aTimestamp); michael@0: michael@0: private: michael@0: ~nsGeoPosition(); michael@0: long long mTimestamp; michael@0: nsRefPtr mCoords; michael@0: }; michael@0: michael@0: //////////////////////////////////////////////////// michael@0: // WebIDL wrappers for the classes above michael@0: //////////////////////////////////////////////////// michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class Coordinates; michael@0: michael@0: class Position MOZ_FINAL : public nsISupports, michael@0: public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Position) michael@0: michael@0: public: michael@0: Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition); michael@0: michael@0: ~Position(); michael@0: michael@0: nsISupports* GetParentObject() const; michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: Coordinates* Coords(); michael@0: michael@0: uint64_t Timestamp() const; michael@0: michael@0: nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; } michael@0: michael@0: private: michael@0: nsRefPtr mCoordinates; michael@0: nsCOMPtr mParent; michael@0: nsCOMPtr mGeoPosition; michael@0: }; michael@0: michael@0: class Coordinates MOZ_FINAL : public nsISupports, michael@0: public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Coordinates) michael@0: michael@0: public: michael@0: Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords); michael@0: michael@0: ~Coordinates(); michael@0: michael@0: Position* GetParentObject() const; michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: double Latitude() const; michael@0: michael@0: double Longitude() const; michael@0: michael@0: Nullable GetAltitude() const; michael@0: michael@0: double Accuracy() const; michael@0: michael@0: Nullable GetAltitudeAccuracy() const; michael@0: michael@0: Nullable GetHeading() const; michael@0: michael@0: Nullable GetSpeed() const; michael@0: private: michael@0: nsRefPtr mPosition; michael@0: nsCOMPtr mCoords; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* nsGeoPosition_h */ michael@0: