Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsGeoPosition.h
Line
Count
Source (jump to first uncovered line)
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 nsGeoPosition_h
8
#define nsGeoPosition_h
9
10
#include "nsIDOMGeoPositionCoords.h"
11
#include "nsIDOMGeoPosition.h"
12
#include "nsString.h"
13
#include "mozilla/Attributes.h"
14
#include "nsCycleCollectionParticipant.h"
15
#include "nsWrapperCache.h"
16
#include "mozilla/dom/Nullable.h"
17
#include "js/TypeDecls.h"
18
19
////////////////////////////////////////////////////
20
// nsGeoPositionCoords
21
////////////////////////////////////////////////////
22
23
/**
24
 * Simple object that holds a single point in space.
25
 */
26
class nsGeoPositionCoords final : public nsIDOMGeoPositionCoords
27
{
28
public:
29
  NS_DECL_THREADSAFE_ISUPPORTS
30
  NS_DECL_NSIDOMGEOPOSITIONCOORDS
31
32
  nsGeoPositionCoords(double aLat, double aLong,
33
                      double aAlt, double aHError,
34
                      double aVError, double aHeading,
35
                      double aSpeed);
36
private:
37
  ~nsGeoPositionCoords();
38
  const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
39
};
40
41
42
////////////////////////////////////////////////////
43
// nsGeoPosition
44
////////////////////////////////////////////////////
45
46
class nsGeoPosition final : public nsIDOMGeoPosition
47
{
48
public:
49
  NS_DECL_THREADSAFE_ISUPPORTS
50
  NS_DECL_NSIDOMGEOPOSITION
51
52
  nsGeoPosition(double aLat, double aLong,
53
                double aAlt, double aHError,
54
                double aVError, double aHeading,
55
                double aSpeed, DOMTimeStamp aTimestamp);
56
57
  nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
58
                DOMTimeStamp aTimestamp);
59
60
private:
61
  ~nsGeoPosition();
62
  DOMTimeStamp mTimestamp;
63
  RefPtr<nsIDOMGeoPositionCoords> mCoords;
64
};
65
66
////////////////////////////////////////////////////
67
// WebIDL wrappers for the classes above
68
////////////////////////////////////////////////////
69
70
namespace mozilla {
71
namespace dom {
72
73
class Coordinates;
74
75
class Position final : public nsISupports,
76
                       public nsWrapperCache
77
{
78
  ~Position();
79
80
public:
81
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
82
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Position)
83
84
public:
85
  Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition);
86
87
  nsISupports* GetParentObject() const;
88
89
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
90
91
  Coordinates* Coords();
92
93
  uint64_t Timestamp() const;
94
95
0
  nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
96
97
private:
98
  RefPtr<Coordinates> mCoordinates;
99
  nsCOMPtr<nsISupports> mParent;
100
  nsCOMPtr<nsIDOMGeoPosition> mGeoPosition;
101
};
102
103
class Coordinates final : public nsISupports,
104
                          public nsWrapperCache
105
{
106
  ~Coordinates();
107
108
public:
109
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
110
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Coordinates)
111
112
public:
113
  Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords);
114
115
  Position* GetParentObject() const;
116
117
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
118
119
  double Latitude() const;
120
121
  double Longitude() const;
122
123
  Nullable<double> GetAltitude() const;
124
125
  double Accuracy() const;
126
127
  Nullable<double> GetAltitudeAccuracy() const;
128
129
  Nullable<double> GetHeading() const;
130
131
  Nullable<double> GetSpeed() const;
132
private:
133
  RefPtr<Position> mPosition;
134
  nsCOMPtr<nsIDOMGeoPositionCoords> mCoords;
135
};
136
137
} // namespace dom
138
} // namespace mozilla
139
140
#endif /* nsGeoPosition_h */
141