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

Side by Side Diff: content/browser/geolocation/libgps_2_94_wrapper_linux.cc

Issue 8463022: Make chrome communicate with gpsd through libgps/shared memory (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: addressing joth@ 's comments Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 // Defines a variant of libgps wrapper for use with the 2.94 release of the API.
6
7 #include "content/browser/geolocation/libgps_wrapper_linux.h"
8
9 #include "base/logging.h"
10 #include "content/common/geoposition.h"
11 #include "third_party/gpsd/release-2.94/gps.h"
12
13 class LibGpsV294 : public LibGps {
14 public:
15 explicit LibGpsV294(LibGpsLibraryWrapper* dl_wrapper) : LibGps(dl_wrapper) {}
16
17 // LibGps
18 virtual bool StartStreaming() {
19 return library().stream(WATCH_ENABLE) == 0;
20 }
21 virtual bool DataWaiting() {
22 return library().waiting();
23 }
24 virtual bool GetPositionIfFixed(Geoposition* position) {
25 // This function is duplicated between the library versions, however it
26 // cannot be shared as each one must be strictly compiled against the
27 // corresponding version of gps.h.
28 DCHECK(position);
29 const gps_data_t& gps_data = library().data();
30 if (gps_data.status == STATUS_NO_FIX)
31 return false;
32 position->latitude = gps_data.fix.latitude;
33 position->longitude = gps_data.fix.longitude;
34 position->accuracy = std::max(gps_data.fix.epx, gps_data.fix.epy);
35 if (position->accuracy != position->accuracy) {
36 // TODO(joth): Fixme. This is a workaround for http://crbug.com/99326
37 LOG(WARNING) << "libgps reported accuracy NaN, forcing to zero";
38 position->accuracy = 0;
39 }
40 position->altitude = gps_data.fix.altitude;
41 position->altitude_accuracy = gps_data.fix.epv;
42 position->heading = gps_data.fix.track;
43 position->speed = gps_data.fix.speed;
44 return true;
45 }
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(LibGpsV294);
49 };
50
51 LibGps* LibGps::NewV294(LibGpsLibraryWrapper* dl_wrapper) {
52 return new LibGpsV294(dl_wrapper);
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698