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_GEOFENCING_SERVICE_H_ | 5 #ifndef CONTENT_BROWSER_GEOFENCING_GEOFENCING_SERVICE_H_ |
6 #define CONTENT_BROWSER_GEOFENCING_GEOFENCING_SERVICE_H_ | 6 #define CONTENT_BROWSER_GEOFENCING_GEOFENCING_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
11 | 12 |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/common/geofencing_types.h" | 16 #include "content/common/geofencing_types.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 template <typename T> | 19 template <typename T> |
20 struct DefaultSingletonTraits; | 20 struct DefaultSingletonTraits; |
21 } | 21 } |
22 | 22 |
23 namespace blink { | 23 namespace blink { |
24 struct WebCircularGeofencingRegion; | 24 struct WebCircularGeofencingRegion; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 int64_t RegisterRegion(const blink::WebCircularGeofencingRegion& region, | 71 int64_t RegisterRegion(const blink::WebCircularGeofencingRegion& region, |
72 GeofencingRegistrationDelegate* delegate) override; | 72 GeofencingRegistrationDelegate* delegate) override; |
73 void UnregisterRegion(int64_t geofencing_registration_id) override; | 73 void UnregisterRegion(int64_t geofencing_registration_id) override; |
74 | 74 |
75 protected: | 75 protected: |
76 friend class GeofencingServiceTest; | 76 friend class GeofencingServiceTest; |
77 friend struct base::DefaultSingletonTraits<GeofencingServiceImpl>; | 77 friend struct base::DefaultSingletonTraits<GeofencingServiceImpl>; |
78 GeofencingServiceImpl(); | 78 GeofencingServiceImpl(); |
79 ~GeofencingServiceImpl() override; | 79 ~GeofencingServiceImpl() override; |
80 | 80 |
81 void SetProviderForTesting(scoped_ptr<GeofencingProvider> provider); | 81 void SetProviderForTesting(std::unique_ptr<GeofencingProvider> provider); |
82 int RegistrationCountForTesting(); | 82 int RegistrationCountForTesting(); |
83 | 83 |
84 private: | 84 private: |
85 struct Registration; | 85 struct Registration; |
86 typedef std::map<int64_t, Registration> RegistrationsMap; | 86 typedef std::map<int64_t, Registration> RegistrationsMap; |
87 | 87 |
88 // This method checks if a |GeofencingProvider| exists, creates a new one if | 88 // This method checks if a |GeofencingProvider| exists, creates a new one if |
89 // not, and finally returns false if it can't create a provider for the | 89 // not, and finally returns false if it can't create a provider for the |
90 // current platform. | 90 // current platform. |
91 bool EnsureProvider(); | 91 bool EnsureProvider(); |
92 | 92 |
93 // Returns a new unique ID to use for the next geofence registration. | 93 // Returns a new unique ID to use for the next geofence registration. |
94 int64_t GetNextId(); | 94 int64_t GetNextId(); |
95 | 95 |
96 // Notifies the correct delegate that registration has completed for a | 96 // Notifies the correct delegate that registration has completed for a |
97 // specific geofence registration. | 97 // specific geofence registration. |
98 void NotifyRegistrationFinished(int64_t geofencing_registration_id, | 98 void NotifyRegistrationFinished(int64_t geofencing_registration_id, |
99 GeofencingStatus status); | 99 GeofencingStatus status); |
100 | 100 |
101 int64_t next_registration_id_; | 101 int64_t next_registration_id_; |
102 RegistrationsMap registrations_; | 102 RegistrationsMap registrations_; |
103 scoped_ptr<GeofencingProvider> provider_; | 103 std::unique_ptr<GeofencingProvider> provider_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(GeofencingServiceImpl); | 105 DISALLOW_COPY_AND_ASSIGN(GeofencingServiceImpl); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace content | 108 } // namespace content |
109 | 109 |
110 #endif // CONTENT_BROWSER_GEOFENCING_GEOFENCING_SERVICE_H_ | 110 #endif // CONTENT_BROWSER_GEOFENCING_GEOFENCING_SERVICE_H_ |
OLD | NEW |