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