OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file declares the Geoposition structure, used to represent a position | 5 // This file declares the Geoposition structure, used to represent a position |
6 // fix. It was originally derived from: | 6 // fix. It was originally derived from: |
7 // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h | 7 // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h |
| 8 // TODO(blundell): Investigate killing content::Geoposition in favor of using |
| 9 // this struct everywhere (and renaming it to Geoposition). |
8 | 10 |
9 #ifndef CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ | 11 module content { |
10 #define CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ | |
11 | 12 |
12 #include <string> | 13 struct MojoGeoposition { |
13 | |
14 #include "base/time/time.h" | |
15 #include "content/common/content_export.h" | |
16 | |
17 namespace content { | |
18 | |
19 struct CONTENT_EXPORT Geoposition { | |
20 public: | |
21 // These values follow the W3C geolocation specification and can be returned | 14 // These values follow the W3C geolocation specification and can be returned |
22 // to JavaScript without the need for a conversion. | 15 // to JavaScript without the need for a conversion. |
23 enum ErrorCode { | 16 enum ErrorCode { |
24 ERROR_CODE_NONE = 0, // Chrome addition. | 17 ERROR_CODE_NONE = 0, // Chrome addition. |
25 ERROR_CODE_PERMISSION_DENIED = 1, | 18 ERROR_CODE_PERMISSION_DENIED = 1, |
26 ERROR_CODE_POSITION_UNAVAILABLE = 2, | 19 ERROR_CODE_POSITION_UNAVAILABLE = 2, |
27 ERROR_CODE_TIMEOUT = 3, | 20 ERROR_CODE_TIMEOUT = 3, |
28 ERROR_CODE_LAST = ERROR_CODE_TIMEOUT | 21 ERROR_CODE_LAST = ERROR_CODE_TIMEOUT |
29 }; | 22 }; |
30 | 23 |
31 // All fields are initialized to sentinel values marking them as invalid. The | 24 // Whether this geoposition is valid. |
32 // error code is set to ERROR_CODE_NONE. | 25 bool valid; |
33 Geoposition(); | |
34 | |
35 // A valid fix has a valid latitude, longitude, accuracy and timestamp. | |
36 bool Validate() const; | |
37 | 26 |
38 // These properties correspond to those of the JavaScript Position object | 27 // These properties correspond to those of the JavaScript Position object |
39 // although their types may differ. | 28 // although their types may differ. |
40 // Latitude in decimal degrees north (WGS84 coordinate frame). | 29 // Latitude in decimal degrees north (WGS84 coordinate frame). |
41 double latitude; | 30 double latitude; |
42 // Longitude in decimal degrees west (WGS84 coordinate frame). | 31 // Longitude in decimal degrees west (WGS84 coordinate frame). |
43 double longitude; | 32 double longitude; |
44 // Altitude in meters (above WGS84 datum). | 33 // Altitude in meters (above WGS84 datum). |
45 double altitude; | 34 double altitude; |
46 // Accuracy of horizontal position in meters. | 35 // Accuracy of horizontal position in meters. |
47 double accuracy; | 36 double accuracy; |
48 // Accuracy of altitude in meters. | 37 // Accuracy of altitude in meters. |
49 double altitude_accuracy; | 38 double altitude_accuracy; |
50 // Heading in decimal degrees clockwise from true north. | 39 // Heading in decimal degrees clockwise from true north. |
51 double heading; | 40 double heading; |
52 // Horizontal component of device velocity in meters per second. | 41 // Horizontal component of device velocity in meters per second. |
53 double speed; | 42 double speed; |
54 // Time of position measurement in milisecons since Epoch in UTC time. This is | 43 // TODO(blundell): If I need to represent this differently to use this |
| 44 // struct to replace content::Geolocation, I'll need to convert |
| 45 // correctly into seconds-since-epoch when using this in |
| 46 // GeolocationDispatcher::OnLocationUpdate(). |
| 47 // Time of position measurement in seconds since Epoch in UTC time. This is |
55 // taken from the host computer's system clock (i.e. from Time::Now(), not the | 48 // taken from the host computer's system clock (i.e. from Time::Now(), not the |
56 // source device's clock). | 49 // source device's clock). |
57 base::Time timestamp; | 50 double timestamp; |
58 | 51 |
59 // Error code, see enum above. | 52 // Error code, see enum above. |
60 ErrorCode error_code; | 53 ErrorCode error_code; |
61 // Human-readable error message. | 54 // Human-readable error message. |
62 std::string error_message; | 55 string error_message; |
63 }; | 56 }; |
64 | 57 |
65 } // namespace content | 58 } |
66 | |
67 #endif // CONTENT_COMMON_GEOPOSITION_H_ | |
OLD | NEW |