OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_GEOFENCING_MOCK_GEOFENCING_SERVICE_H_ | 5 #ifndef CONTENT_BROWSER_GEOFENCING_MOCK_GEOFENCING_SERVICE_H_ |
6 #define CONTENT_BROWSER_GEOFENCING_MOCK_GEOFENCING_SERVICE_H_ | 6 #define CONTENT_BROWSER_GEOFENCING_MOCK_GEOFENCING_SERVICE_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 | 11 |
10 #include "content/browser/geofencing/geofencing_service.h" | 12 #include "content/browser/geofencing/geofencing_service.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 // This class implements a geofencing service that doesn't rely on any | 16 // This class implements a geofencing service that doesn't rely on any |
15 // underlying platform implementation. Instead whenever SetMockPosition is | 17 // underlying platform implementation. Instead whenever SetMockPosition is |
16 // called this class will compare the provided position with all currently | 18 // called this class will compare the provided position with all currently |
17 // registered regions, and emit corresponding geofencing events. | 19 // registered regions, and emit corresponding geofencing events. |
18 // | 20 // |
19 // If an instance is created with |service_available| set to false, the mock | 21 // If an instance is created with |service_available| set to false, the mock |
20 // will behave as if the platform does not support geofencing. | 22 // will behave as if the platform does not support geofencing. |
21 class MockGeofencingService : public GeofencingService { | 23 class MockGeofencingService : public GeofencingService { |
22 public: | 24 public: |
23 explicit MockGeofencingService(bool service_available); | 25 explicit MockGeofencingService(bool service_available); |
24 ~MockGeofencingService() override; | 26 ~MockGeofencingService() override; |
25 | 27 |
26 void SetMockPosition(double latitude, double longitude); | 28 void SetMockPosition(double latitude, double longitude); |
27 | 29 |
28 // GeofencingService implementation. | 30 // GeofencingService implementation. |
29 bool IsServiceAvailable() override; | 31 bool IsServiceAvailable() override; |
30 int64 RegisterRegion(const blink::WebCircularGeofencingRegion& region, | 32 int64_t RegisterRegion(const blink::WebCircularGeofencingRegion& region, |
31 GeofencingRegistrationDelegate* delegate) override; | 33 GeofencingRegistrationDelegate* delegate) override; |
32 void UnregisterRegion(int64 geofencing_registration_id) override; | 34 void UnregisterRegion(int64_t geofencing_registration_id) override; |
33 | 35 |
34 private: | 36 private: |
35 struct Registration; | 37 struct Registration; |
36 | 38 |
37 bool available_; | 39 bool available_; |
38 std::map<int64, Registration> registrations_; | 40 std::map<int64_t, Registration> registrations_; |
39 int64 next_id_; | 41 int64_t next_id_; |
40 bool has_position_; | 42 bool has_position_; |
41 double last_latitude_; | 43 double last_latitude_; |
42 double last_longitude_; | 44 double last_longitude_; |
43 }; | 45 }; |
44 | 46 |
45 } // namespace content | 47 } // namespace content |
46 | 48 |
47 #endif // CONTENT_BROWSER_GEOFENCING_MOCK_GEOFENCING_SERVICE_H_ | 49 #endif // CONTENT_BROWSER_GEOFENCING_MOCK_GEOFENCING_SERVICE_H_ |
OLD | NEW |