Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: content/browser/geofencing/geofencing_manager.h

Issue 701953007: Expose mock geofencing service via testRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mention unifying bug in a comment Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_GEOFENCING_GEOFENCING_MANAGER_H_
6 #define CONTENT_BROWSER_GEOFENCING_GEOFENCING_MANAGER_H_ 6 #define CONTENT_BROWSER_GEOFENCING_GEOFENCING_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "content/browser/geofencing/geofencing_registration_delegate.h" 16 #include "content/browser/geofencing/geofencing_registration_delegate.h"
17 #include "content/browser/service_worker/service_worker_storage.h" 17 #include "content/browser/service_worker/service_worker_storage.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/common/geofencing_status.h" 19 #include "content/common/geofencing_types.h"
20 #include "content/common/service_worker/service_worker_status_code.h" 20 #include "content/common/service_worker/service_worker_status_code.h"
21 21
22 template <typename T> 22 template <typename T>
23 struct DefaultSingletonTraits; 23 struct DefaultSingletonTraits;
24 class GURL; 24 class GURL;
25 25
26 namespace blink { 26 namespace blink {
27 struct WebCircularGeofencingRegion; 27 struct WebCircularGeofencingRegion;
28 }; 28 };
29 29
30 namespace content { 30 namespace content {
31 31
32 class GeofencingService; 32 class GeofencingService;
33 class MockGeofencingService;
33 class ServiceWorkerContextWrapper; 34 class ServiceWorkerContextWrapper;
34 class ServiceWorkerRegistration; 35 class ServiceWorkerRegistration;
35 36
36 // This is the main API to the geofencing subsystem. There is one instance of 37 // This is the main API to the geofencing subsystem. There is one instance of
37 // this class per storage partition. 38 // this class per storage partition.
38 // This class is responsible for keeping track of which geofences are currently 39 // This class is responsible for keeping track of which geofences are currently
39 // registered by websites/workers, persisting this list of registrations and 40 // registered by websites/workers, persisting this list of registrations and
40 // registering them with the global |GeofencingService|. 41 // registering them with the global |GeofencingService|.
41 // This class is created on the UI thread, but all its methods should only be 42 // This class is created on the UI thread, but all its methods should only be
42 // called from the IO thread. 43 // called from the IO thread.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Returns all currently registered regions. In case of failure (no geofencing 83 // Returns all currently registered regions. In case of failure (no geofencing
83 // provider available for example) return an error status, while leaving 84 // provider available for example) return an error status, while leaving
84 // |regions| untouched. 85 // |regions| untouched.
85 // This only returns regions for which the callback passed to RegisterRegion 86 // This only returns regions for which the callback passed to RegisterRegion
86 // has been called already (so it doesn't include still in progress 87 // has been called already (so it doesn't include still in progress
87 // registrations). 88 // registrations).
88 GeofencingStatus GetRegisteredRegions( 89 GeofencingStatus GetRegisteredRegions(
89 int64 service_worker_registration_id, 90 int64 service_worker_registration_id,
90 std::map<std::string, blink::WebCircularGeofencingRegion>* result); 91 std::map<std::string, blink::WebCircularGeofencingRegion>* result);
91 92
93 // Enables or disables mock geofencing service.
94 void SetMockProvider(GeofencingMockState mock_state);
95
96 // Set the mock geofencing position.
97 // TODO(mek): Unify this mock position with the devtools exposed geolocation
98 // mock position (http://crbug.com/440902).
99 void SetMockPosition(double latitude, double longitude);
100
92 void SetServiceForTesting(GeofencingService* service) { 101 void SetServiceForTesting(GeofencingService* service) {
93 service_ = service; 102 service_ = service;
94 } 103 }
95 104
96 protected: 105 protected:
97 friend class base::RefCountedThreadSafe<GeofencingManager>; 106 friend class base::RefCountedThreadSafe<GeofencingManager>;
98 ~GeofencingManager() override; 107 ~GeofencingManager() override;
99 108
100 private: 109 private:
101 // Internal bookkeeping associated with each registered geofence. 110 // Internal bookkeeping associated with each registered geofence.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 typedef std::map<int64, RegionIdRegistrationMap> 171 typedef std::map<int64, RegionIdRegistrationMap>
163 ServiceWorkerRegistrationsMap; 172 ServiceWorkerRegistrationsMap;
164 ServiceWorkerRegistrationsMap registrations_; 173 ServiceWorkerRegistrationsMap registrations_;
165 174
166 // Map of all registered regions by geofencing_registration_id. 175 // Map of all registered regions by geofencing_registration_id.
167 typedef std::map<int64, RegionIdRegistrationMap::iterator> 176 typedef std::map<int64, RegionIdRegistrationMap::iterator>
168 RegistrationIdRegistrationMap; 177 RegistrationIdRegistrationMap;
169 RegistrationIdRegistrationMap registrations_by_id_; 178 RegistrationIdRegistrationMap registrations_by_id_;
170 179
171 GeofencingService* service_; 180 GeofencingService* service_;
181 scoped_ptr<MockGeofencingService> mock_service_;
172 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 182 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
173 183
174 DISALLOW_COPY_AND_ASSIGN(GeofencingManager); 184 DISALLOW_COPY_AND_ASSIGN(GeofencingManager);
175 }; 185 };
176 186
177 } // namespace content 187 } // namespace content
178 188
179 #endif // CONTENT_BROWSER_GEOFENCING_GEOFENCING_MANAGER_H_ 189 #endif // CONTENT_BROWSER_GEOFENCING_GEOFENCING_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/geofencing/geofencing_dispatcher_host.cc ('k') | content/browser/geofencing/geofencing_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698