alemate@chromium.org | 9e844cf | 2014-04-19 02:36:01 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
satorux | de6a5dc | 2014-12-12 22:30:37 | [diff] [blame] | 5 | #ifndef CHROMEOS_GEOLOCATION_GEOPOSITION_H_ |
| 6 | #define CHROMEOS_GEOLOCATION_GEOPOSITION_H_ |
alemate@chromium.org | 9e844cf | 2014-04-19 02:36:01 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/time/time.h" |
satorux | de6a5dc | 2014-12-12 22:30:37 | [diff] [blame] | 11 | #include "chromeos/chromeos_export.h" |
alemate@chromium.org | 9e844cf | 2014-04-19 02:36:01 | [diff] [blame] | 12 | |
| 13 | namespace chromeos { |
| 14 | |
| 15 | // This structure represents Google Maps Geolocation response. |
mcasas | 4e216e7 | 2016-07-28 21:28:38 | [diff] [blame] | 16 | // Based on device/geolocation/geoposition.h . |
satorux | de6a5dc | 2014-12-12 22:30:37 | [diff] [blame] | 17 | struct CHROMEOS_EXPORT Geoposition { |
alemate@chromium.org | 9e844cf | 2014-04-19 02:36:01 | [diff] [blame] | 18 | // Geolocation API client status. |
| 19 | // (Server status is reported in "error_code" field.) |
| 20 | enum Status { |
| 21 | STATUS_NONE, |
| 22 | STATUS_OK, // Response successful. |
| 23 | STATUS_SERVER_ERROR, // Received error object. |
| 24 | STATUS_NETWORK_ERROR, // Received bad or no response. |
| 25 | STATUS_TIMEOUT, // Request stopped because of timeout. |
| 26 | STATUS_LAST = STATUS_TIMEOUT |
| 27 | }; |
| 28 | |
| 29 | // All fields are initialized to sentinel values marking them as invalid. The |
| 30 | // status is set to STATUS_NONE. |
| 31 | Geoposition(); |
| 32 | |
| 33 | // A valid fix has a valid latitude, longitude, accuracy and timestamp. |
| 34 | bool Valid() const; |
| 35 | |
| 36 | // Serialize to string. |
| 37 | std::string ToString() const; |
| 38 | |
| 39 | // Latitude in decimal degrees north. |
| 40 | double latitude; |
| 41 | |
| 42 | // Longitude in decimal degrees west. |
| 43 | double longitude; |
| 44 | |
| 45 | // Accuracy of horizontal position in meters. |
| 46 | double accuracy; |
| 47 | |
| 48 | // Error object data: |
| 49 | // Value of "error.code". |
| 50 | int error_code; |
| 51 | |
| 52 | // Human-readable error message. |
| 53 | std::string error_message; |
| 54 | |
| 55 | // Absolute time, when this position was acquired. This is |
| 56 | // taken from the host computer's system clock (i.e. from Time::Now(), not the |
| 57 | // source device's clock). |
| 58 | base::Time timestamp; |
| 59 | |
| 60 | // See enum above. |
| 61 | Status status; |
| 62 | }; |
| 63 | |
| 64 | } // namespace chromeos |
| 65 | |
satorux | de6a5dc | 2014-12-12 22:30:37 | [diff] [blame] | 66 | #endif // CHROMEOS_GEOLOCATION_GEOPOSITION_H_ |