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