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_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ |
6 #define CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "content/browser/geolocation/location_provider.h" | 13 #include "content/browser/geolocation/location_provider.h" |
14 #include "content/common/geoposition.h" | 14 #include "content/public/common/geoposition.h" |
15 | 15 |
16 // Mock implementation of a location provider for testing. | 16 // Mock implementation of a location provider for testing. |
17 class MockLocationProvider : public LocationProviderBase { | 17 class MockLocationProvider : public LocationProviderBase { |
18 public: | 18 public: |
19 // Will update |*self_ref| to point to |this| on construction, and to NULL | 19 // Will update |*self_ref| to point to |this| on construction, and to NULL |
20 // on destruction. | 20 // on destruction. |
21 explicit MockLocationProvider(MockLocationProvider** self_ref); | 21 explicit MockLocationProvider(MockLocationProvider** self_ref); |
22 virtual ~MockLocationProvider(); | 22 virtual ~MockLocationProvider(); |
23 | 23 |
24 // Updates listeners with the new position. | 24 // Updates listeners with the new position. |
25 void HandlePositionChanged(const Geoposition& position); | 25 void HandlePositionChanged(const content::Geoposition& position); |
26 | 26 |
27 // LocationProviderBase implementation. | 27 // LocationProviderBase implementation. |
28 virtual bool StartProvider(bool high_accuracy) OVERRIDE; | 28 virtual bool StartProvider(bool high_accuracy) OVERRIDE; |
29 virtual void StopProvider() OVERRIDE; | 29 virtual void StopProvider() OVERRIDE; |
30 virtual void GetPosition(Geoposition* position) OVERRIDE; | 30 virtual void GetPosition(content::Geoposition* position) OVERRIDE; |
31 virtual void OnPermissionGranted() OVERRIDE; | 31 virtual void OnPermissionGranted() OVERRIDE; |
32 | 32 |
33 Geoposition position_; | 33 content::Geoposition position_; |
34 enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; | 34 enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; |
35 bool is_permission_granted_; | 35 bool is_permission_granted_; |
36 MockLocationProvider** self_ref_; | 36 MockLocationProvider** self_ref_; |
37 | 37 |
38 scoped_refptr<base::MessageLoopProxy> provider_loop_; | 38 scoped_refptr<base::MessageLoopProxy> provider_loop_; |
39 | 39 |
40 // Set when an instance of the mock is created via a factory function. | 40 // Set when an instance of the mock is created via a factory function. |
41 static MockLocationProvider* instance_; | 41 static MockLocationProvider* instance_; |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(MockLocationProvider); | 43 DISALLOW_COPY_AND_ASSIGN(MockLocationProvider); |
(...skipping 11 matching lines...) Expand all Loading... |
55 LocationProviderBase* NewAutoSuccessMockLocationProvider(); | 55 LocationProviderBase* NewAutoSuccessMockLocationProvider(); |
56 // Creates a mock location provider that automatically notifies its | 56 // Creates a mock location provider that automatically notifies its |
57 // listeners with an error when StartProvider is called. | 57 // listeners with an error when StartProvider is called. |
58 LocationProviderBase* NewAutoFailMockLocationProvider(); | 58 LocationProviderBase* NewAutoFailMockLocationProvider(); |
59 // Similar to NewAutoSuccessMockLocationProvider but mimicks the behavior of | 59 // Similar to NewAutoSuccessMockLocationProvider but mimicks the behavior of |
60 // the Network Location provider, in deferring making location updates until | 60 // the Network Location provider, in deferring making location updates until |
61 // a permission request has been confirmed. | 61 // a permission request has been confirmed. |
62 LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider(); | 62 LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider(); |
63 | 63 |
64 #endif // CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ | 64 #endif // CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ |
OLD | NEW |