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