summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 15:21:46 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 15:21:46 +0000
commit98e60fa21e8e34bc66e80107f1881a74541662ca (patch)
tree02b58a90f8534da2893ec21c2affb459e0773096 /content
parent5e8ad9b8fc35000c6a6f9a5f1bad6eb4bc11c6b8 (diff)
downloadchromium_src-98e60fa21e8e34bc66e80107f1881a74541662ca.zip
chromium_src-98e60fa21e8e34bc66e80107f1881a74541662ca.tar.gz
chromium_src-98e60fa21e8e34bc66e80107f1881a74541662ca.tar.bz2
Fix gps.h license issue, by deleting it
BUG=98132,99326 TEST=used gpsfake (from lucid package 2.92) and opened maps.google.com/maps/m Review URL: http://codereview.chromium.org/8171006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/geolocation/libgps_2_38_wrapper_linux.cc68
-rw-r--r--content/browser/geolocation/libgps_2_94_wrapper_linux.cc5
-rw-r--r--content/browser/geolocation/libgps_wrapper_linux.cc47
-rw-r--r--content/browser/geolocation/libgps_wrapper_linux.h6
-rw-r--r--content/content_browser.gypi1
5 files changed, 19 insertions, 108 deletions
diff --git a/content/browser/geolocation/libgps_2_38_wrapper_linux.cc b/content/browser/geolocation/libgps_2_38_wrapper_linux.cc
deleted file mode 100644
index 7cfdb52..0000000
--- a/content/browser/geolocation/libgps_2_38_wrapper_linux.cc
+++ /dev/null
@@ -1,68 +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.
-
-// Defines a variant of libgps wrapper for use with the 2.38 release of the API.
-
-#include "content/browser/geolocation/libgps_wrapper_linux.h"
-
-// This lot needed for DataWaiting()
-#include <sys/socket.h>
-#include <sys/time.h>
-
-#include "base/logging.h"
-#include "content/common/geoposition.h"
-#include "third_party/gpsd/release-2.38/gps.h"
-
-class LibGpsV238 : public LibGps {
- public:
- explicit LibGpsV238(LibGpsLibraryWrapper* dl_wrapper) : LibGps(dl_wrapper) {}
-
- // LibGps
- virtual bool StartStreaming() {
- return library().query("w+x\n") == 0;
- }
- virtual bool DataWaiting() {
- // Unfortunately the 2.38 API has no public method for non-blocking test
- // for new data arrived, so we must contrive our own by doing a select() on
- // the underlying struct's socket fd.
- fd_set fds;
- struct timeval timeout = {0};
- int fd = library().data().gps_fd;
-
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
-
- int ret = select(fd + 1, &fds, NULL, NULL, &timeout);
- if (ret == -1) {
- LOG(WARNING) << "libgps socket select failed: " << ret;
- return false;
- }
- DCHECK_EQ(!!ret, !!FD_ISSET(fd, &fds));
- return ret;
- }
- virtual bool GetPositionIfFixed(Geoposition* position) {
- // This function is duplicated between the library versions, however it
- // cannot be shared as each one must be strictly compiled against the
- // corresponding version of gps.h.
- DCHECK(position);
- const gps_data_t& gps_data = library().data();
- if (gps_data.status == STATUS_NO_FIX)
- return false;
- position->latitude = gps_data.fix.latitude;
- position->longitude = gps_data.fix.longitude;
- position->accuracy = gps_data.fix.eph;
- position->altitude = gps_data.fix.altitude;
- position->altitude_accuracy = gps_data.fix.epv;
- position->heading = gps_data.fix.track;
- position->speed = gps_data.fix.speed;
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LibGpsV238);
-};
-
-LibGps* LibGps::NewV238(LibGpsLibraryWrapper* dl_wrapper) {
- return new LibGpsV238(dl_wrapper);
-}
diff --git a/content/browser/geolocation/libgps_2_94_wrapper_linux.cc b/content/browser/geolocation/libgps_2_94_wrapper_linux.cc
index c9fb1bd..9d213b8 100644
--- a/content/browser/geolocation/libgps_2_94_wrapper_linux.cc
+++ b/content/browser/geolocation/libgps_2_94_wrapper_linux.cc
@@ -32,6 +32,11 @@ class LibGpsV294 : public LibGps {
position->latitude = gps_data.fix.latitude;
position->longitude = gps_data.fix.longitude;
position->accuracy = std::max(gps_data.fix.epx, gps_data.fix.epy);
+ if (position->accuracy != position->accuracy) {
+ // TODO(joth): Fixme. This is a workaround for http://crbug.com/99326
+ LOG(WARNING) << "libgps reported accuracy NaN, forcing to zero";
+ position->accuracy = 0;
+ }
position->altitude = gps_data.fix.altitude;
position->altitude_accuracy = gps_data.fix.epv;
position->heading = gps_data.fix.track;
diff --git a/content/browser/geolocation/libgps_wrapper_linux.cc b/content/browser/geolocation/libgps_wrapper_linux.cc
index e1d47880..c95d898 100644
--- a/content/browser/geolocation/libgps_wrapper_linux.cc
+++ b/content/browser/geolocation/libgps_wrapper_linux.cc
@@ -12,18 +12,14 @@
#include "content/common/geoposition.h"
namespace {
-// Pass to TryToOpen() to indicate which functions should be wired up.
-// This could be turned into a bit mask if required, but for now the
-// two options are mutually exclusive.
-enum InitMode {
- INITMODE_QUERY,
- INITMODE_STREAM,
-};
-
// Attempts to load dynamic library named |lib| and initialize the required
// function pointers according to |mode|. Returns ownership a new instance
// of the library loader class, or NULL on failure.
-LibGpsLibraryWrapper* TryToOpen(const char* lib, InitMode mode) {
+// TODO(joth): This is a hang-over from when we dynamically two different
+// versions of libgps and chose between them. Now we could remove at least one
+// layer of wrapper class and directly #include gps.h in this cc file.
+// See http://crbug.com/98132 and http://crbug.com/99177
+LibGpsLibraryWrapper* TryToOpen(const char* lib) {
void* dl_handle = dlopen(lib, RTLD_LAZY);
if (!dl_handle) {
VLOG(1) << "Could not open " << lib << ": " << dlerror();
@@ -31,28 +27,26 @@ LibGpsLibraryWrapper* TryToOpen(const char* lib, InitMode mode) {
}
VLOG(1) << "Loaded " << lib;
- #define DECLARE_FN_POINTER(function, required) \
+ #define DECLARE_FN_POINTER(function) \
LibGpsLibraryWrapper::function##_fn function; \
function = reinterpret_cast<LibGpsLibraryWrapper::function##_fn>( \
dlsym(dl_handle, #function)); \
- if ((required) && !function) { \
+ if (!function) { \
LOG(WARNING) << "libgps " << #function << " error: " << dlerror(); \
dlclose(dl_handle); \
return NULL; \
}
- DECLARE_FN_POINTER(gps_open, true);
- DECLARE_FN_POINTER(gps_close, true);
- DECLARE_FN_POINTER(gps_poll, true);
- DECLARE_FN_POINTER(gps_query, mode == INITMODE_QUERY);
- DECLARE_FN_POINTER(gps_stream, mode == INITMODE_STREAM);
- DECLARE_FN_POINTER(gps_waiting, mode == INITMODE_STREAM);
+ DECLARE_FN_POINTER(gps_open);
+ DECLARE_FN_POINTER(gps_close);
+ DECLARE_FN_POINTER(gps_poll);
+ DECLARE_FN_POINTER(gps_stream);
+ DECLARE_FN_POINTER(gps_waiting);
#undef DECLARE_FN_POINTER
return new LibGpsLibraryWrapper(dl_handle,
gps_open,
gps_close,
gps_poll,
- gps_query,
gps_stream,
gps_waiting);
}
@@ -68,13 +62,10 @@ LibGps::~LibGps() {
LibGps* LibGps::New() {
LibGpsLibraryWrapper* wrapper;
- wrapper = TryToOpen("libgps.so.19", INITMODE_STREAM);
+ wrapper = TryToOpen("libgps.so.19");
if (wrapper)
return NewV294(wrapper);
- wrapper = TryToOpen("libgps.so.17", INITMODE_QUERY);
- if (wrapper)
- return NewV238(wrapper);
- wrapper = TryToOpen("libgps.so", INITMODE_STREAM);
+ wrapper = TryToOpen("libgps.so");
if (wrapper)
return NewV294(wrapper);
return NULL;
@@ -148,14 +139,12 @@ LibGpsLibraryWrapper::LibGpsLibraryWrapper(void* dl_handle,
gps_open_fn gps_open,
gps_close_fn gps_close,
gps_poll_fn gps_poll,
- gps_query_fn gps_query,
gps_stream_fn gps_stream,
gps_waiting_fn gps_waiting)
: dl_handle_(dl_handle),
gps_open_(gps_open),
gps_close_(gps_close),
gps_poll_(gps_poll),
- gps_query_(gps_query),
gps_stream_(gps_stream),
gps_waiting_(gps_waiting),
gps_data_(NULL) {
@@ -190,14 +179,6 @@ int LibGpsLibraryWrapper::poll() {
return gps_poll_(gps_data_);
}
-// This is intentionally ignoring the va_arg extension to query(): the caller
-// can use base::StringPrintf to achieve the same effect.
-int LibGpsLibraryWrapper::query(const char* fmt) {
- DCHECK(is_open());
- DCHECK(gps_query_);
- return gps_query_(gps_data_, fmt);
-}
-
int LibGpsLibraryWrapper::stream(int flags) {
DCHECK(is_open());
DCHECK(gps_stream_);
diff --git a/content/browser/geolocation/libgps_wrapper_linux.h b/content/browser/geolocation/libgps_wrapper_linux.h
index 6ed6c40..4ef8151 100644
--- a/content/browser/geolocation/libgps_wrapper_linux.h
+++ b/content/browser/geolocation/libgps_wrapper_linux.h
@@ -53,7 +53,6 @@ class CONTENT_EXPORT LibGps {
// libgps API versions (v2.38 => libgps.so.17, v2.94 => libgps.so.19).
// See LibGps::New() for the public API to this.
// Takes ownership of |dl_wrapper|.
- static LibGps* NewV238(LibGpsLibraryWrapper* dl_wrapper);
static LibGps* NewV294(LibGpsLibraryWrapper* dl_wrapper);
scoped_ptr<LibGpsLibraryWrapper> library_;
@@ -71,8 +70,6 @@ class CONTENT_EXPORT LibGpsLibraryWrapper {
typedef gps_data_t* (*gps_open_fn)(const char*, const char*);
typedef int (*gps_close_fn)(gps_data_t*);
typedef int (*gps_poll_fn)(gps_data_t*);
- // v2.34 only
- typedef int (*gps_query_fn)(gps_data_t*, const char*, ...);
// v2.90+
typedef int (*gps_stream_fn)(gps_data_t*, unsigned int, void*);
typedef bool (*gps_waiting_fn)(gps_data_t*);
@@ -81,7 +78,6 @@ class CONTENT_EXPORT LibGpsLibraryWrapper {
gps_open_fn gps_open,
gps_close_fn gps_close,
gps_poll_fn gps_poll,
- gps_query_fn gps_query,
gps_stream_fn gps_stream,
gps_waiting_fn gps_waiting);
~LibGpsLibraryWrapper();
@@ -90,7 +86,6 @@ class CONTENT_EXPORT LibGpsLibraryWrapper {
bool open(const char* host, const char* port);
void close();
int poll();
- int query(const char* fmt);
int stream(int flags);
bool waiting();
const gps_data_t& data() const;
@@ -101,7 +96,6 @@ class CONTENT_EXPORT LibGpsLibraryWrapper {
gps_open_fn gps_open_;
gps_close_fn gps_close_;
gps_poll_fn gps_poll_;
- gps_query_fn gps_query_;
gps_stream_fn gps_stream_;
gps_waiting_fn gps_waiting_;
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 4725ca8..f7dc5b6 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -185,7 +185,6 @@
'browser/geolocation/geolocation_provider.h',
'browser/geolocation/gps_location_provider_linux.cc',
'browser/geolocation/gps_location_provider_linux.h',
- 'browser/geolocation/libgps_2_38_wrapper_linux.cc',
'browser/geolocation/libgps_2_94_wrapper_linux.cc',
'browser/geolocation/libgps_wrapper_linux.cc',
'browser/geolocation/libgps_wrapper_linux.h',