| 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_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 namespace base { |
| 19 template<typename Type> struct DefaultSingletonTraits; | 20 template<typename Type> struct DefaultSingletonTraits; |
| 21 } |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| 22 class LocationArbitrator; | 24 class LocationArbitrator; |
| 23 | 25 |
| 24 class CONTENT_EXPORT GeolocationProviderImpl | 26 class CONTENT_EXPORT GeolocationProviderImpl |
| 25 : public NON_EXPORTED_BASE(GeolocationProvider), | 27 : public NON_EXPORTED_BASE(GeolocationProvider), |
| 26 public base::Thread { | 28 public base::Thread { |
| 27 public: | 29 public: |
| 28 // GeolocationProvider implementation: | 30 // GeolocationProvider implementation: |
| 29 scoped_ptr<GeolocationProvider::Subscription> AddLocationUpdateCallback( | 31 scoped_ptr<GeolocationProvider::Subscription> AddLocationUpdateCallback( |
| 30 const LocationUpdateCallback& callback, | 32 const LocationUpdateCallback& callback, |
| 31 bool use_high_accuracy) override; | 33 bool use_high_accuracy) override; |
| 32 void UserDidOptIntoLocationServices() override; | 34 void UserDidOptIntoLocationServices() override; |
| 33 void OverrideLocationForTesting(const Geoposition& position) override; | 35 void OverrideLocationForTesting(const Geoposition& position) override; |
| 34 | 36 |
| 35 // Callback from the LocationArbitrator. Public for testing. | 37 // Callback from the LocationArbitrator. Public for testing. |
| 36 void OnLocationUpdate(const Geoposition& position); | 38 void OnLocationUpdate(const Geoposition& position); |
| 37 | 39 |
| 38 // Gets a pointer to the singleton instance of the location relayer, which | 40 // 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 | 41 // 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 | 42 // called on the UI thread so that the GeolocationProviderImpl is always |
| 41 // instantiated on the same thread. Ownership is NOT returned. | 43 // instantiated on the same thread. Ownership is NOT returned. |
| 42 static GeolocationProviderImpl* GetInstance(); | 44 static GeolocationProviderImpl* GetInstance(); |
| 43 | 45 |
| 44 bool user_did_opt_into_location_services_for_testing() { | 46 bool user_did_opt_into_location_services_for_testing() { |
| 45 return user_did_opt_into_location_services_; | 47 return user_did_opt_into_location_services_; |
| 46 } | 48 } |
| 47 | 49 |
| 48 protected: | 50 protected: |
| 49 friend struct DefaultSingletonTraits<GeolocationProviderImpl>; | 51 friend struct base::DefaultSingletonTraits<GeolocationProviderImpl>; |
| 50 GeolocationProviderImpl(); | 52 GeolocationProviderImpl(); |
| 51 ~GeolocationProviderImpl() override; | 53 ~GeolocationProviderImpl() override; |
| 52 | 54 |
| 53 // Useful for injecting mock geolocation arbitrator in tests. | 55 // Useful for injecting mock geolocation arbitrator in tests. |
| 54 virtual LocationArbitrator* CreateArbitrator(); | 56 virtual LocationArbitrator* CreateArbitrator(); |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 bool OnGeolocationThread() const; | 59 bool OnGeolocationThread() const; |
| 58 | 60 |
| 59 // Start and stop providers as needed when clients are added or removed. | 61 // Start and stop providers as needed when clients are added or removed. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 89 | 91 |
| 90 // Only to be used on the geolocation thread. | 92 // Only to be used on the geolocation thread. |
| 91 LocationArbitrator* arbitrator_; | 93 LocationArbitrator* arbitrator_; |
| 92 | 94 |
| 93 DISALLOW_COPY_AND_ASSIGN(GeolocationProviderImpl); | 95 DISALLOW_COPY_AND_ASSIGN(GeolocationProviderImpl); |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 } // namespace content | 98 } // namespace content |
| 97 | 99 |
| 98 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_ | 100 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_ |
| OLD | NEW |