| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 wrapper around the C libgps API (gps.h). Similar to the libgpsmm.h | |
| 6 // API provided by that package. | |
| 7 | |
| 8 #ifndef CONTENT_BROWSER_GEOLOCATION_LIBGPS_WRAPPER_LINUX_H_ | |
| 9 #define CONTENT_BROWSER_GEOLOCATION_LIBGPS_WRAPPER_LINUX_H_ | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "content/common/content_export.h" | |
| 14 | |
| 15 struct gps_data_t; | |
| 16 | |
| 17 namespace content { | |
| 18 struct Geoposition; | |
| 19 | |
| 20 class CONTENT_EXPORT LibGps { | |
| 21 public: | |
| 22 virtual ~LibGps(); | |
| 23 // Attempts to dynamically load the libgps.so library and returns NULL on | |
| 24 // failure. | |
| 25 static LibGps* New(); | |
| 26 | |
| 27 bool Start(); | |
| 28 void Stop(); | |
| 29 bool Read(Geoposition* position); | |
| 30 | |
| 31 protected: | |
| 32 typedef int (*gps_open_fn)(const char*, const char*, struct gps_data_t*); | |
| 33 typedef int (*gps_close_fn)(struct gps_data_t*); | |
| 34 typedef int (*gps_read_fn)(struct gps_data_t*); | |
| 35 | |
| 36 explicit LibGps(void* dl_handle, | |
| 37 gps_open_fn gps_open, | |
| 38 gps_close_fn gps_close, | |
| 39 gps_read_fn gps_read); | |
| 40 | |
| 41 // Returns false if there is not fix available. | |
| 42 virtual bool GetPositionIfFixed(Geoposition* position); | |
| 43 | |
| 44 private: | |
| 45 void* dl_handle_; | |
| 46 gps_open_fn gps_open_; | |
| 47 gps_close_fn gps_close_; | |
| 48 gps_read_fn gps_read_; | |
| 49 | |
| 50 scoped_ptr<gps_data_t> gps_data_; | |
| 51 bool is_open_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(LibGps); | |
| 54 }; | |
| 55 | |
| 56 } // namespace content | |
| 57 | |
| 58 #endif // CONTENT_BROWSER_GEOLOCATION_LIBGPS_WRAPPER_LINUX_H_ | |
| OLD | NEW |