LCOV - code coverage report
Current view: top level - dom/geolocation - nsGeoPosition.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 109 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 52 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "nsGeoPosition.h"
       8             : 
       9             : #include "mozilla/dom/PositionBinding.h"
      10             : #include "mozilla/dom/CoordinatesBinding.h"
      11             : 
      12             : ////////////////////////////////////////////////////
      13             : // nsGeoPositionCoords
      14             : ////////////////////////////////////////////////////
      15           0 : nsGeoPositionCoords::nsGeoPositionCoords(double aLat, double aLong,
      16             :                                          double aAlt, double aHError,
      17             :                                          double aVError, double aHeading,
      18           0 :                                          double aSpeed)
      19             :   : mLat(aLat)
      20             :   , mLong(aLong)
      21             :   , mAlt(aAlt)
      22             :   , mHError(aHError)
      23             :   , mVError(aVError)
      24             :   , mHeading(aHeading)
      25           0 :   , mSpeed(aSpeed)
      26             : {
      27           0 : }
      28             : 
      29           0 : nsGeoPositionCoords::~nsGeoPositionCoords()
      30             : {
      31           0 : }
      32             : 
      33           0 : NS_INTERFACE_MAP_BEGIN(nsGeoPositionCoords)
      34           0 : NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionCoords)
      35           0 : NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionCoords)
      36           0 : NS_INTERFACE_MAP_END
      37             : 
      38           0 : NS_IMPL_ADDREF(nsGeoPositionCoords)
      39           0 : NS_IMPL_RELEASE(nsGeoPositionCoords)
      40             : 
      41             : NS_IMETHODIMP
      42           0 : nsGeoPositionCoords::GetLatitude(double *aLatitude)
      43             : {
      44           0 :   *aLatitude = mLat;
      45           0 :   return NS_OK;
      46             : }
      47             : 
      48             : NS_IMETHODIMP
      49           0 : nsGeoPositionCoords::GetLongitude(double *aLongitude)
      50             : {
      51           0 :   *aLongitude = mLong;
      52           0 :   return NS_OK;
      53             : }
      54             : 
      55             : NS_IMETHODIMP
      56           0 : nsGeoPositionCoords::GetAltitude(double *aAltitude)
      57             : {
      58           0 :   *aAltitude = mAlt;
      59           0 :   return NS_OK;
      60             : }
      61             : 
      62             : NS_IMETHODIMP
      63           0 : nsGeoPositionCoords::GetAccuracy(double *aAccuracy)
      64             : {
      65           0 :   *aAccuracy = mHError;
      66           0 :   return NS_OK;
      67             : }
      68             : 
      69             : NS_IMETHODIMP
      70           0 : nsGeoPositionCoords::GetAltitudeAccuracy(double *aAltitudeAccuracy)
      71             : {
      72           0 :   *aAltitudeAccuracy = mVError;
      73           0 :   return NS_OK;
      74             : }
      75             : 
      76             : NS_IMETHODIMP
      77           0 : nsGeoPositionCoords::GetHeading(double *aHeading)
      78             : {
      79           0 :   *aHeading = mHeading;
      80           0 :   return NS_OK;
      81             : }
      82             : 
      83             : NS_IMETHODIMP
      84           0 : nsGeoPositionCoords::GetSpeed(double *aSpeed)
      85             : {
      86           0 :   *aSpeed = mSpeed;
      87           0 :   return NS_OK;
      88             : }
      89             : 
      90             : ////////////////////////////////////////////////////
      91             : // nsGeoPosition
      92             : ////////////////////////////////////////////////////
      93             : 
      94           0 : nsGeoPosition::nsGeoPosition(double aLat, double aLong,
      95             :                              double aAlt, double aHError,
      96             :                              double aVError, double aHeading,
      97           0 :                              double aSpeed, long long aTimestamp) :
      98           0 :     mTimestamp(aTimestamp)
      99             : {
     100             :     mCoords = new nsGeoPositionCoords(aLat, aLong,
     101             :                                       aAlt, aHError,
     102             :                                       aVError, aHeading,
     103           0 :                                       aSpeed);
     104           0 : }
     105             : 
     106           0 : nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
     107           0 :                              long long aTimestamp) :
     108             :     mTimestamp(aTimestamp),
     109           0 :     mCoords(aCoords)
     110             : {
     111           0 : }
     112             : 
     113           0 : nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
     114           0 :                              DOMTimeStamp aTimestamp) :
     115             :   mTimestamp(aTimestamp),
     116           0 :   mCoords(aCoords)
     117             : {
     118           0 : }
     119             : 
     120           0 : nsGeoPosition::~nsGeoPosition()
     121             : {
     122           0 : }
     123             : 
     124           0 : NS_INTERFACE_MAP_BEGIN(nsGeoPosition)
     125           0 : NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPosition)
     126           0 : NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPosition)
     127           0 : NS_INTERFACE_MAP_END
     128             : 
     129           0 : NS_IMPL_ADDREF(nsGeoPosition)
     130           0 : NS_IMPL_RELEASE(nsGeoPosition)
     131             : 
     132             : NS_IMETHODIMP
     133           0 : nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
     134             : {
     135           0 :   *aTimestamp = mTimestamp;
     136           0 :   return NS_OK;
     137             : }
     138             : 
     139             : NS_IMETHODIMP
     140           0 : nsGeoPosition::GetCoords(nsIDOMGeoPositionCoords * *aCoords)
     141             : {
     142           0 :   NS_IF_ADDREF(*aCoords = mCoords);
     143           0 :   return NS_OK;
     144             : }
     145             : 
     146             : namespace mozilla {
     147             : namespace dom {
     148             : 
     149             : 
     150           0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Position, mParent, mCoordinates)
     151           0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(Position)
     152           0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(Position)
     153           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Position)
     154           0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     155           0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
     156           0 : NS_INTERFACE_MAP_END
     157             : 
     158           0 : Position::Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition)
     159             :   : mParent(aParent)
     160           0 :   , mGeoPosition(aGeoPosition)
     161             : {
     162           0 : }
     163             : 
     164           0 : Position::~Position()
     165             : {
     166           0 : }
     167             : 
     168             : nsISupports*
     169           0 : Position::GetParentObject() const
     170             : {
     171           0 :   return mParent;
     172             : }
     173             : 
     174             : JSObject*
     175           0 : Position::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
     176             : {
     177           0 :   return PositionBinding::Wrap(aCx, this, aGivenProto);
     178             : }
     179             : 
     180             : Coordinates*
     181           0 : Position::Coords()
     182             : {
     183           0 :   if (!mCoordinates) {
     184           0 :     nsCOMPtr<nsIDOMGeoPositionCoords> coords;
     185           0 :     mGeoPosition->GetCoords(getter_AddRefs(coords));
     186           0 :     MOZ_ASSERT(coords, "coords should not be null");
     187             : 
     188           0 :     mCoordinates = new Coordinates(this, coords);
     189             :   }
     190             : 
     191           0 :   return mCoordinates;
     192             : }
     193             : 
     194             : uint64_t
     195           0 : Position::Timestamp() const
     196             : {
     197             :   uint64_t rv;
     198             : 
     199           0 :   mGeoPosition->GetTimestamp(&rv);
     200           0 :   return rv;
     201             : }
     202             : 
     203           0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Coordinates, mPosition)
     204           0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(Coordinates)
     205           0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(Coordinates)
     206           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Coordinates)
     207           0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     208           0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
     209           0 : NS_INTERFACE_MAP_END
     210             : 
     211           0 : Coordinates::Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords)
     212             :   : mPosition(aPosition)
     213           0 :   , mCoords(aCoords)
     214             : {
     215           0 : }
     216             : 
     217           0 : Coordinates::~Coordinates()
     218             : {
     219           0 : }
     220             : 
     221             : Position*
     222           0 : Coordinates::GetParentObject() const
     223             : {
     224           0 :   return mPosition;
     225             : }
     226             : 
     227             : JSObject*
     228           0 : Coordinates::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
     229             : {
     230           0 :   return CoordinatesBinding::Wrap(aCx, this, aGivenProto);
     231             : }
     232             : 
     233             : #define GENERATE_COORDS_WRAPPED_GETTER(name) \
     234             : double                                       \
     235             : Coordinates::name() const                    \
     236             : {                                            \
     237             :   double rv;                                 \
     238             :   mCoords->Get##name(&rv);                   \
     239             :   return rv;                                 \
     240             : }
     241             : 
     242             : #define GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(name) \
     243             : Nullable<double>                                      \
     244             : Coordinates::Get##name() const                        \
     245             : {                                                     \
     246             :   double rv;                                          \
     247             :   mCoords->Get##name(&rv);                            \
     248             :   return Nullable<double>(rv);                        \
     249             : }
     250             : 
     251           0 : GENERATE_COORDS_WRAPPED_GETTER(Latitude)
     252           0 : GENERATE_COORDS_WRAPPED_GETTER(Longitude)
     253           0 : GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(Altitude)
     254           0 : GENERATE_COORDS_WRAPPED_GETTER(Accuracy)
     255           0 : GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(AltitudeAccuracy)
     256           0 : GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(Heading)
     257           0 : GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(Speed)
     258             : 
     259             : #undef GENERATE_COORDS_WRAPPED_GETTER
     260             : #undef GENERATE_COORDS_WRAPPED_GETTER_NULLABLE
     261             : 
     262             : } // namespace dom
     263             : } // namespace mozilla

Generated by: LCOV version 1.13