summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 20:48:35 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 20:48:35 +0000
commit9fc4dabfb2dd3f2f7e9da2af8ae9f41b469e68f9 (patch)
tree3fd3f6a5d05d6c8755b8658a22de2b2a8acbfdd4 /content/common
parentbfde7449259ccf84393fd6751fca30ea36eb0368 (diff)
downloadchromium_src-9fc4dabfb2dd3f2f7e9da2af8ae9f41b469e68f9.zip
chromium_src-9fc4dabfb2dd3f2f7e9da2af8ae9f41b469e68f9.tar.gz
chromium_src-9fc4dabfb2dd3f2f7e9da2af8ae9f41b469e68f9.tar.bz2
Make the Geoposition helper struct public
This CL moves the Geoposition struct from content/common to public/content/common.h so that it can be shared by content and browser. The struct is placed in the |content| namespace and as required by the style guide, all methods except the constructor and Validate() are removed. This paves the way for a follow-up CL in which the content will provide geolocation information to the browser. BUG=chromium-os:22036 TEST=Chrome and tests build, run Review URL: http://codereview.chromium.org/10316007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/geolocation_messages.h10
-rw-r--r--content/common/geoposition.cc66
-rw-r--r--content/common/geoposition.h66
3 files changed, 5 insertions, 137 deletions
diff --git a/content/common/geolocation_messages.h b/content/common/geolocation_messages.h
index b945de5..eac9200 100644
--- a/content/common/geolocation_messages.h
+++ b/content/common/geolocation_messages.h
@@ -1,19 +1,19 @@
-// 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.
// IPC messages for geolocation.
// Multiply-included message file, hence no include guard.
-#include "content/common/geoposition.h"
+#include "content/public/common/geoposition.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START GeolocationMsgStart
-IPC_ENUM_TRAITS(Geoposition::ErrorCode)
+IPC_ENUM_TRAITS(content::Geoposition::ErrorCode)
-IPC_STRUCT_TRAITS_BEGIN(Geoposition)
+IPC_STRUCT_TRAITS_BEGIN(content::Geoposition)
IPC_STRUCT_TRAITS_MEMBER(latitude)
IPC_STRUCT_TRAITS_MEMBER(longitude)
IPC_STRUCT_TRAITS_MEMBER(altitude)
@@ -37,7 +37,7 @@ IPC_MESSAGE_ROUTED2(GeolocationMsg_PermissionSet,
// permission and we have a position available or an error occurs (such as
// permission denied, position unavailable, etc.)
IPC_MESSAGE_ROUTED1(GeolocationMsg_PositionUpdated,
- Geoposition /* geoposition */)
+ content::Geoposition /* geoposition */)
// Messages sent from the renderer to the browser.
diff --git a/content/common/geoposition.cc b/content/common/geoposition.cc
deleted file mode 100644
index 4beac74..0000000
--- a/content/common/geoposition.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2010 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.
-
-#include "content/common/geoposition.h"
-
-namespace {
-// Sentinel values to mark invalid data. (WebKit carries companion is_valid
-// bools for this purpose; we may eventually follow that approach, but
-// sentinels worked OK in the Gears code this is based on.)
-const double kBadLatitudeLongitude = 200;
-// Lowest point on land is at approximately -400 meters.
-const int kBadAltitude = -10000;
-const int kBadAccuracy = -1; // Accuracy must be non-negative.
-const int64 kBadTimestamp = kint64min;
-const int kBadHeading = -1; // Heading must be non-negative.
-const int kBadSpeed = -1;
-}
-
-Geoposition::Geoposition()
- : latitude(kBadLatitudeLongitude),
- longitude(kBadLatitudeLongitude),
- altitude(kBadAltitude),
- accuracy(kBadAccuracy),
- altitude_accuracy(kBadAccuracy),
- heading(kBadHeading),
- speed(kBadSpeed),
- error_code(ERROR_CODE_NONE) {
-}
-
-bool Geoposition::is_valid_latlong() const {
- return latitude >= -90.0 && latitude <= 90.0 &&
- longitude >= -180.0 && longitude <= 180.0;
-}
-
-bool Geoposition::is_valid_altitude() const {
- return altitude > kBadAltitude;
-}
-
-bool Geoposition::is_valid_accuracy() const {
- return accuracy >= 0.0;
-}
-
-bool Geoposition::is_valid_altitude_accuracy() const {
- return altitude_accuracy >= 0.0;
-}
-
-bool Geoposition::is_valid_heading() const {
- return heading >= 0 && heading <= 360;
-}
-
-bool Geoposition::is_valid_speed() const {
- return speed >= 0;
-}
-
-bool Geoposition::is_valid_timestamp() const {
- return !timestamp.is_null();
-}
-
-bool Geoposition::IsValidFix() const {
- return is_valid_latlong() && is_valid_accuracy() && is_valid_timestamp();
-}
-
-bool Geoposition::IsInitialized() const {
- return error_code != ERROR_CODE_NONE || IsValidFix();
-}
diff --git a/content/common/geoposition.h b/content/common/geoposition.h
deleted file mode 100644
index cff59ae..0000000
--- a/content/common/geoposition.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2011 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
-// http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h
-
-#ifndef CONTENT_COMMON_GEOPOSITION_H_
-#define CONTENT_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.
-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.
- enum ErrorCode {
- ERROR_CODE_NONE = 0, // Chrome addition
- ERROR_CODE_PERMISSION_DENIED = 1,
- ERROR_CODE_POSITION_UNAVAILABLE = 2,
- ERROR_CODE_TIMEOUT = 3,
- };
-
- 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;
-
- // 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).
- base::Time timestamp;
-
- // These properties are returned to JavaScript as a PositionError object.
- ErrorCode error_code;
- std::string error_message; // Human-readable error message
-};
-
-#endif // CONTENT_COMMON_GEOPOSITION_H_