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

Side by Side Diff: device/geolocation/fake_location_provider.h

Issue 2161223003: Adds GeolocationFeature for Blimp Geolocation project. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@engine_feature_prep
Patch Set: Addresses nyquist's #79 comments Created 4 years, 4 months 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 (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 DEVICE_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ 5 #ifndef DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_
6 #define DEVICE_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ 6 #define DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "device/geolocation/geoposition.h" 13 #include "device/geolocation/geoposition.h"
14 #include "device/geolocation/location_provider_base.h" 14 #include "device/geolocation/location_provider_base.h"
15 15
16 namespace device { 16 namespace device {
17 17
18 // Mock implementation of a location provider for testing. 18 // Fake implementation of a location provider for testing.
19 class MockLocationProvider : public LocationProviderBase { 19 class FakeLocationProvider : public LocationProviderBase {
20 public: 20 public:
21 enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; 21 enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_;
22 22
23 MockLocationProvider(); 23 FakeLocationProvider();
24 ~MockLocationProvider() override; 24 ~FakeLocationProvider() override;
25
26 bool IsProviderStarted() const;
27 25
28 // Updates listeners with the new position. 26 // Updates listeners with the new position.
29 void HandlePositionChanged(const Geoposition& position); 27 void HandlePositionChanged(const Geoposition& position);
30 28
29 bool IsProviderStarted() const;
Wez 2016/08/19 18:50:25 nit: See comments in other CL re making this a sim
CJ 2016/08/19 22:22:34 Done. Let me know if this is what was intended.
30
31 // LocationProvider implementation. 31 // LocationProvider implementation.
32 bool StartProvider(bool high_accuracy) override; 32 bool StartProvider(bool high_accuracy) override;
33 void StopProvider() override; 33 void StopProvider() override;
34 const Geoposition& GetPosition() override; 34 const Geoposition& GetPosition() override;
35 void OnPermissionGranted() override; 35 void OnPermissionGranted() override;
36 36
37 bool is_permission_granted_; 37 bool is_permission_granted_;
38 Geoposition position_; 38 Geoposition position_;
Wez 2016/08/19 18:50:26 nit: These PoD members can be in-line initialized.
CJ 2016/08/19 22:22:34 Done.
39 scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_; 39 scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_;
40 40
41 private: 41 private:
42 DISALLOW_COPY_AND_ASSIGN(MockLocationProvider); 42 DISALLOW_COPY_AND_ASSIGN(FakeLocationProvider);
43 }; 43 };
44 44
45 // Factory functions for the various sorts of mock location providers, 45 // Factory functions for the various sorts of mock location providers,
46 // for use with LocationArbitrator::SetProviderFactoryForTest (i.e. 46 // for use with LocationArbitrator::SetProviderFactoryForTest (i.e.
47 // not intended for test code to use to get access to the mock, you can use 47 // not intended for test code to use to get access to the mock, you can use
48 // MockLocationProvider::instance_ for this, or make a custom factory method). 48 // FakeLocationProvider::instance_ for this, or make a custom factory method).
49 49
50 // Creates a mock location provider with no default behavior. 50 // Creates a mock location provider with no default behavior.
51 LocationProvider* NewMockLocationProvider(); 51 LocationProvider* NewFakeLocationProvider();
52 // Creates a mock location provider that automatically notifies its 52 // Creates a mock location provider that automatically notifies its
53 // listeners with a valid location when StartProvider is called. 53 // listeners with a valid location when StartProvider is called.
54 LocationProvider* NewAutoSuccessMockLocationProvider(); 54 LocationProvider* NewAutoSuccessFakeLocationProvider();
55 // Creates a mock location provider that automatically notifies its 55 // Creates a mock location provider that automatically notifies its
56 // listeners with an error when StartProvider is called. 56 // listeners with an error when StartProvider is called.
57 LocationProvider* NewAutoFailMockLocationProvider(); 57 LocationProvider* NewAutoFailFakeLocationProvider();
58 // Similar to NewAutoSuccessMockLocationProvider but mimicks the behavior of 58 // Similar to NewAutoSuccessFakeLocationProvider but mimicks the behavior of
59 // the Network Location provider, in deferring making location updates until 59 // the Network Location provider, in deferring making location updates until
60 // a permission request has been confirmed. 60 // a permission request has been confirmed.
61 LocationProvider* NewAutoSuccessMockNetworkLocationProvider(); 61 LocationProvider* NewAutoSuccessFakeNetworkLocationProvider();
Wez 2016/08/19 18:50:25 Do any call-sites actually use these? I'd assume
CJ 2016/08/19 22:22:34 Yeah they are gone now.
62 62
63 } // namespace device 63 } // namespace device
64 64
65 #endif // DEVICE_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ 65 #endif // DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698