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