OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PUBLIC_BROWSER_GEOLOCATION_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_GEOLOCATION_H_ |
6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_H_ | 6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 struct Geoposition; | 14 struct Geoposition; |
15 | 15 |
16 typedef base::Callback<void(const Geoposition&)> GeolocationUpdateCallback; | |
17 | |
16 // Overrides the current location for testing. This function may be called on | 18 // Overrides the current location for testing. This function may be called on |
17 // any thread. The completion callback will be invoked asynchronously on the | 19 // any thread. The completion callback will be invoked asynchronously on the |
18 // calling thread when the override operation is completed. | 20 // calling thread when the override operation is completed. |
19 // This should be used instead of a mock location provider for a simpler way | 21 // |
20 // to provide fake location results when not testing the innards of the | 22 // This function allows the current location to be faked without having to |
21 // geolocation code. | 23 // manually instantiate a GeolocationProvider backed by a MockLocationProvider |
24 // that serves a fake location. | |
25 // | |
26 // Do not use this function in unit tests. The function instantiates the | |
27 // singleton geolocation stack in the background and manipulates it to report | |
28 // a fake location. Neither step can be undone, breaking unit test isolation | |
29 // (crbug.com/125931). | |
jam
2012/05/02 20:59:04
it's a bit odd adding this warning when existing t
| |
22 void CONTENT_EXPORT OverrideLocationForTesting( | 30 void CONTENT_EXPORT OverrideLocationForTesting( |
23 const Geoposition& position, | 31 const Geoposition& position, |
24 const base::Closure& completion_callback); | 32 const base::Closure& completion_callback); |
25 | 33 |
34 // Overrides the current location for testing. This function affects only | |
35 // callbacks requested through RequestLocationUpdate() in the future. | |
36 // | |
37 // Ownership of the |position| argument is taken. | |
38 // | |
39 // This function may be used in unit tests. It does not bring up the singleton | |
40 // geolocation stack and its effects can be fully undone by calling again with | |
41 // a NULL argument. | |
42 void CONTENT_EXPORT OverrideCallbackLocationForTesting(Geoposition* position); | |
jam
2012/05/02 20:59:04
two ways to override a location is not good. let's
| |
43 | |
44 // Requests a one-time callback when the next location update becomes available. | |
45 // This function may be called on any thread. The callback will be invoked on | |
46 // the calling thread. | |
47 void CONTENT_EXPORT RequestLocationUpdate( | |
48 const GeolocationUpdateCallback& callback); | |
49 | |
26 } // namespace content | 50 } // namespace content |
27 | 51 |
28 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_H_ | 52 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_H_ |
OLD | NEW |