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