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

Side by Side Diff: content/browser/geolocation/geolocation_provider_impl.h

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_ 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/public/browser/geolocation_provider.h" 16 #include "content/public/browser/geolocation_provider.h"
17 #include "content/public/common/geoposition.h" 17 #include "content/public/common/geoposition.h"
18 18
19 template<typename Type> struct DefaultSingletonTraits; 19 template<typename Type> struct DefaultSingletonTraits;
20 20
21 namespace content { 21 namespace content {
22 class LocationArbitrator; 22 class LocationArbitrator;
23 23
24 class CONTENT_EXPORT GeolocationProviderImpl 24 class CONTENT_EXPORT GeolocationProviderImpl
25 : public NON_EXPORTED_BASE(GeolocationProvider), 25 : public NON_EXPORTED_BASE(GeolocationProvider),
26 public base::Thread { 26 public base::Thread {
27 public: 27 public:
28 // GeolocationProvider implementation: 28 // GeolocationProvider implementation:
29 virtual scoped_ptr<GeolocationProvider::Subscription> 29 scoped_ptr<GeolocationProvider::Subscription> AddLocationUpdateCallback(
30 AddLocationUpdateCallback(const LocationUpdateCallback& callback, 30 const LocationUpdateCallback& callback,
31 bool use_high_accuracy) override; 31 bool use_high_accuracy) override;
32 virtual void UserDidOptIntoLocationServices() override; 32 void UserDidOptIntoLocationServices() override;
33 virtual void OverrideLocationForTesting(const Geoposition& position) override; 33 void OverrideLocationForTesting(const Geoposition& position) override;
34 34
35 // Callback from the LocationArbitrator. Public for testing. 35 // Callback from the LocationArbitrator. Public for testing.
36 void OnLocationUpdate(const Geoposition& position); 36 void OnLocationUpdate(const Geoposition& position);
37 37
38 // Gets a pointer to the singleton instance of the location relayer, which 38 // Gets a pointer to the singleton instance of the location relayer, which
39 // is in turn bound to the browser's global context objects. This must only be 39 // is in turn bound to the browser's global context objects. This must only be
40 // called on the UI thread so that the GeolocationProviderImpl is always 40 // called on the UI thread so that the GeolocationProviderImpl is always
41 // instantiated on the same thread. Ownership is NOT returned. 41 // instantiated on the same thread. Ownership is NOT returned.
42 static GeolocationProviderImpl* GetInstance(); 42 static GeolocationProviderImpl* GetInstance();
43 43
44 bool user_did_opt_into_location_services_for_testing() { 44 bool user_did_opt_into_location_services_for_testing() {
45 return user_did_opt_into_location_services_; 45 return user_did_opt_into_location_services_;
46 } 46 }
47 47
48 protected: 48 protected:
49 friend struct DefaultSingletonTraits<GeolocationProviderImpl>; 49 friend struct DefaultSingletonTraits<GeolocationProviderImpl>;
50 GeolocationProviderImpl(); 50 GeolocationProviderImpl();
51 virtual ~GeolocationProviderImpl(); 51 ~GeolocationProviderImpl() override;
52 52
53 // Useful for injecting mock geolocation arbitrator in tests. 53 // Useful for injecting mock geolocation arbitrator in tests.
54 virtual LocationArbitrator* CreateArbitrator(); 54 virtual LocationArbitrator* CreateArbitrator();
55 55
56 private: 56 private:
57 bool OnGeolocationThread() const; 57 bool OnGeolocationThread() const;
58 58
59 // Start and stop providers as needed when clients are added or removed. 59 // Start and stop providers as needed when clients are added or removed.
60 void OnClientsChanged(); 60 void OnClientsChanged();
61 61
62 // Stops the providers when there are no more registered clients. Note that 62 // Stops the providers when there are no more registered clients. Note that
63 // once the Geolocation thread is started, it will stay alive (but sitting 63 // once the Geolocation thread is started, it will stay alive (but sitting
64 // idle without any pending messages). 64 // idle without any pending messages).
65 void StopProviders(); 65 void StopProviders();
66 66
67 // Starts the geolocation providers or updates their options (delegates to 67 // Starts the geolocation providers or updates their options (delegates to
68 // arbitrator). 68 // arbitrator).
69 void StartProviders(bool use_high_accuracy); 69 void StartProviders(bool use_high_accuracy);
70 70
71 // Updates the providers on the geolocation thread, which must be running. 71 // Updates the providers on the geolocation thread, which must be running.
72 void InformProvidersPermissionGranted(); 72 void InformProvidersPermissionGranted();
73 73
74 // Notifies all registered clients that a position update is available. 74 // Notifies all registered clients that a position update is available.
75 void NotifyClients(const Geoposition& position); 75 void NotifyClients(const Geoposition& position);
76 76
77 // Thread 77 // Thread
78 virtual void Init() override; 78 void Init() override;
79 virtual void CleanUp() override; 79 void CleanUp() override;
80 80
81 base::CallbackList<void(const Geoposition&)> high_accuracy_callbacks_; 81 base::CallbackList<void(const Geoposition&)> high_accuracy_callbacks_;
82 base::CallbackList<void(const Geoposition&)> low_accuracy_callbacks_; 82 base::CallbackList<void(const Geoposition&)> low_accuracy_callbacks_;
83 83
84 bool user_did_opt_into_location_services_; 84 bool user_did_opt_into_location_services_;
85 Geoposition position_; 85 Geoposition position_;
86 86
87 // True only in testing, where we want to use a custom position. 87 // True only in testing, where we want to use a custom position.
88 bool ignore_location_updates_; 88 bool ignore_location_updates_;
89 89
90 // Only to be used on the geolocation thread. 90 // Only to be used on the geolocation thread.
91 LocationArbitrator* arbitrator_; 91 LocationArbitrator* arbitrator_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(GeolocationProviderImpl); 93 DISALLOW_COPY_AND_ASSIGN(GeolocationProviderImpl);
94 }; 94 };
95 95
96 } // namespace content 96 } // namespace content
97 97
98 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_ 98 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698