geoposition.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef ASH_COMPONENTS_GEOLOCATION_GEOPOSITION_H_
  5. #define ASH_COMPONENTS_GEOLOCATION_GEOPOSITION_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. #include "base/time/time.h"
  9. namespace ash {
  10. // This structure represents Google Maps Geolocation response.
  11. // Based on device/geolocation/geoposition.h .
  12. struct COMPONENT_EXPORT(ASH_GEOLOCATION) Geoposition {
  13. // Geolocation API client status.
  14. // (Server status is reported in "error_code" field.)
  15. enum Status {
  16. STATUS_NONE,
  17. STATUS_OK, // Response successful.
  18. STATUS_SERVER_ERROR, // Received error object.
  19. STATUS_NETWORK_ERROR, // Received bad or no response.
  20. STATUS_TIMEOUT, // Request stopped because of timeout.
  21. STATUS_LAST = STATUS_TIMEOUT
  22. };
  23. // All fields are initialized to sentinel values marking them as invalid. The
  24. // status is set to STATUS_NONE.
  25. Geoposition();
  26. // A valid fix has a valid latitude, longitude, accuracy and timestamp.
  27. bool Valid() const;
  28. // Serialize to string.
  29. std::string ToString() const;
  30. // Latitude in decimal degrees north.
  31. double latitude;
  32. // Longitude in decimal degrees west.
  33. double longitude;
  34. // Accuracy of horizontal position in meters.
  35. double accuracy;
  36. // Error object data:
  37. // Value of "error.code".
  38. int error_code;
  39. // Human-readable error message.
  40. std::string error_message;
  41. // Absolute time, when this position was acquired. This is
  42. // taken from the host computer's system clock (i.e. from Time::Now(), not the
  43. // source device's clock).
  44. base::Time timestamp;
  45. // See enum above.
  46. Status status;
  47. };
  48. } // namespace ash
  49. #endif // ASH_COMPONENTS_GEOLOCATION_GEOPOSITION_H_