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

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

Issue 2028823002: Refactor to make BlimpLocationProvider accessible to content layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes try issue Created 4 years, 6 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_LOCATION_ARBITRATOR_IMPL_H_ 5 #ifndef CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
6 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ 6 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector>
9 10
10 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/cancelable_callback.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "content/browser/geolocation/location_arbitrator.h" 17 #include "content/browser/geolocation/location_arbitrator.h"
16 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
17 #include "content/public/browser/access_token_store.h" 19 #include "content/public/browser/access_token_store.h"
18 #include "content/public/browser/location_provider.h" 20 #include "content/public/browser/location_provider.h"
19 #include "content/public/common/geoposition.h" 21 #include "content/public/common/geoposition.h"
20 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
(...skipping 28 matching lines...) Expand all
49 void StopProviders() override; 51 void StopProviders() override;
50 void OnPermissionGranted() override; 52 void OnPermissionGranted() override;
51 bool HasPermissionBeenGranted() const override; 53 bool HasPermissionBeenGranted() const override;
52 54
53 protected: 55 protected:
54 AccessTokenStore* GetAccessTokenStore(); 56 AccessTokenStore* GetAccessTokenStore();
55 57
56 // These functions are useful for injection of dependencies in derived 58 // These functions are useful for injection of dependencies in derived
57 // testing classes. 59 // testing classes.
58 virtual AccessTokenStore* NewAccessTokenStore(); 60 virtual AccessTokenStore* NewAccessTokenStore();
59 virtual LocationProvider* NewNetworkLocationProvider( 61 virtual std::unique_ptr<LocationProvider> NewNetworkLocationProvider(
60 AccessTokenStore* access_token_store, 62 AccessTokenStore* access_token_store,
61 net::URLRequestContextGetter* context, 63 net::URLRequestContextGetter* context,
62 const GURL& url, 64 const GURL& url,
63 const base::string16& access_token); 65 const base::string16& access_token);
64 virtual LocationProvider* NewSystemLocationProvider(); 66 virtual std::unique_ptr<LocationProvider> NewSystemLocationProvider();
65 virtual base::Time GetTimeNow() const; 67 virtual base::Time GetTimeNow() const;
66 68
67 private: 69 private:
68 // Takes ownership of |provider| on entry; it will either be added to 70 // Provider will either be added to |providers_| or
69 // |providers_| or deleted on error (e.g. it fails to start). 71 // deleted on error (e.g. it fails to start).
70 void RegisterProvider(LocationProvider* provider); 72 void RegisterProvider(std::unique_ptr<LocationProvider> provider);
73
74 void RegisterSystemProvider();
71 void OnAccessTokenStoresLoaded( 75 void OnAccessTokenStoresLoaded(
72 AccessTokenStore::AccessTokenMap access_token_map, 76 AccessTokenStore::AccessTokenMap access_token_map,
73 net::URLRequestContextGetter* context_getter); 77 net::URLRequestContextGetter* context_getter);
74 void DoStartProviders(); 78 void DoStartProviders();
75 79
76 // Gets called when a provider has a new position. 80 // Gets called when a provider has a new position.
77 void OnLocationUpdate(const LocationProvider* provider, 81 void OnLocationUpdate(const LocationProvider* provider,
78 const Geoposition& new_position); 82 const Geoposition& new_position);
79 83
80 // Returns true if |new_position| is an improvement over |old_position|. 84 // Returns true if |new_position| is an improvement over |old_position|.
81 // Set |from_same_provider| to true if both the positions came from the same 85 // Set |from_same_provider| to true if both the positions came from the same
82 // provider. 86 // provider.
83 bool IsNewPositionBetter(const Geoposition& old_position, 87 bool IsNewPositionBetter(const Geoposition& old_position,
84 const Geoposition& new_position, 88 const Geoposition& new_position,
85 bool from_same_provider) const; 89 bool from_same_provider) const;
86 90
87 scoped_refptr<AccessTokenStore> access_token_store_; 91 scoped_refptr<AccessTokenStore> access_token_store_;
88 LocationUpdateCallback arbitrator_update_callback_; 92 LocationUpdateCallback arbitrator_update_callback_;
89 LocationProvider::LocationProviderUpdateCallback provider_update_callback_; 93 LocationProvider::LocationProviderUpdateCallback provider_update_callback_;
90 ScopedVector<LocationProvider> providers_; 94
95 // The CancelableCallback will prevent OnAccessTokenStoresLoaded from being
96 // called multiple times by calling Reset() at the time of binding.
97 base::CancelableCallback<void(AccessTokenStore::AccessTokenMap,
98 net::URLRequestContextGetter*)>
99 token_store_callback_;
100 std::vector<std::unique_ptr<LocationProvider>> providers_;
91 bool enable_high_accuracy_; 101 bool enable_high_accuracy_;
92 // The provider which supplied the current |position_| 102 // The provider which supplied the current |position_|
93 const LocationProvider* position_provider_; 103 const LocationProvider* position_provider_;
94 bool is_permission_granted_; 104 bool is_permission_granted_;
95 // The current best estimate of our position. 105 // The current best estimate of our position.
96 Geoposition position_; 106 Geoposition position_;
97 107
98 // Tracks whether providers should be running. 108 // Tracks whether providers should be running.
99 bool is_running_; 109 bool is_running_;
100 110
101 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl); 111 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl);
102 }; 112 };
103 113
104 // Factory functions for the various types of location provider to abstract 114 // Factory functions for the various types of location provider to abstract
105 // over the platform-dependent implementations. 115 // over the platform-dependent implementations.
106 LocationProvider* NewSystemLocationProvider(); 116 LocationProvider* NewSystemLocationProvider();
107 117
108 } // namespace content 118 } // namespace content
109 119
110 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ 120 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
OLDNEW
« no previous file with comments | « blimp/engine/feature/geolocation/blimp_location_provider.cc ('k') | content/browser/geolocation/location_arbitrator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698