Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: content/public/common/geoposition.h

Issue 10316007: Make the Geoposition helper class public (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix forward-declaration of struct as class. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/geolocation.h ('k') | content/public/common/geoposition.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/geoposition.h
diff --git a/content/common/geoposition.h b/content/public/common/geoposition.h
similarity index 26%
rename from content/common/geoposition.h
rename to content/public/common/geoposition.h
index cff59aeff472afb54a7e08cb9271e12b9bb2f0d2..22e7030e9fa0b56a6be88630286d370061fa7123 100644
--- a/content/common/geoposition.h
+++ b/content/public/common/geoposition.h
@@ -1,66 +1,67 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This file declares the Position structure, which is used to represent a
-// position fix. Originally derived from
+// This file declares the Geoposition structure, used to represent a position
+// fix. It was originally derived from:
// http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h
-#ifndef CONTENT_COMMON_GEOPOSITION_H_
-#define CONTENT_COMMON_GEOPOSITION_H_
+#ifndef CONTENT_PUBLIC_COMMON_GEOPOSITION_H_
+#define CONTENT_PUBLIC_COMMON_GEOPOSITION_H_
#pragma once
#include <string>
+
#include "base/time.h"
#include "content/common/content_export.h"
-// The internal representation of a geo position. Some properties use different
-// types when passed to JavaScript.
+namespace content {
+
struct CONTENT_EXPORT Geoposition {
public:
- // Error codes for returning to JavaScript. These values are defined by the
- // W3C spec. Note that Gears does not use all of these codes, but we need
- // values for all of them to allow us to provide the constants on the error
- // object.
+ // These values follow the W3C geolocation specification and can be returned
+ // to JavaScript without the need for a conversion.
enum ErrorCode {
- ERROR_CODE_NONE = 0, // Chrome addition
+ ERROR_CODE_NONE = 0, // Chrome addition.
ERROR_CODE_PERMISSION_DENIED = 1,
ERROR_CODE_POSITION_UNAVAILABLE = 2,
ERROR_CODE_TIMEOUT = 3,
};
+ // All fields are initialized to sentinel values marking them as invalid. The
+ // error code is set to ERROR_CODE_NONE.
Geoposition();
- bool is_valid_latlong() const;
- bool is_valid_altitude() const;
- bool is_valid_accuracy() const;
- bool is_valid_altitude_accuracy() const;
- bool is_valid_heading() const;
- bool is_valid_speed() const;
- bool is_valid_timestamp() const;
-
// A valid fix has a valid latitude, longitude, accuracy and timestamp.
- bool IsValidFix() const;
+ bool Validate() const;
- // A position is considered initialized if it has either a valid fix or
- // an error code other than NONE.
- bool IsInitialized() const;
-
- // These properties correspond to the JavaScript Position object.
- double latitude; // In degrees
- double longitude; // In degrees
- double altitude; // In metres
- double accuracy; // In metres
- double altitude_accuracy; // In metres
- double heading; // In degrees clockwise relative to the true north
- double speed; // In meters per second
- // Timestamp for this position fix object taken from the host computer's
- // system clock (i.e. from Time::Now(), not the source device's clock).
+ // These properties correspond to those of the JavaScript Position object
+ // although their types may differ.
+ // Latitude in decimal degrees north (WGS84 coordinate frame).
+ double latitude;
+ // Longitude in decimal degrees west (WGS84 coordinate frame).
+ double longitude;
+ // Altitude in meters (above WGS84 datum).
+ double altitude;
+ // Accuracy of horizontal position in meters.
+ double accuracy;
+ // Accuracy of altitude in meters.
+ double altitude_accuracy;
+ // Heading in decimal degrees clockwise from true north.
+ double heading;
+ // Horizontal component of device velocity in meters per second.
+ double speed;
+ // Time of position measurement in milisecons since Epoch in UTC time. This is
+ // taken from the host computer's system clock (i.e. from Time::Now(), not the
+ // source device's clock).
base::Time timestamp;
- // These properties are returned to JavaScript as a PositionError object.
+ // Error code, see enum above.
ErrorCode error_code;
- std::string error_message; // Human-readable error message
+ // Human-readable error message.
+ std::string error_message;
};
+} // namespace content
+
#endif // CONTENT_COMMON_GEOPOSITION_H_
« no previous file with comments | « content/public/browser/geolocation.h ('k') | content/public/common/geoposition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698