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

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: Addresses mvanouwerkerk's #81 comments 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 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/cancelable_callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "content/browser/geolocation/location_arbitrator.h" 16 #include "content/browser/geolocation/location_arbitrator.h"
16 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
17 #include "content/public/browser/access_token_store.h" 18 #include "content/public/browser/access_token_store.h"
18 #include "content/public/browser/location_provider.h" 19 #include "content/public/browser/location_provider.h"
19 #include "content/public/common/geoposition.h" 20 #include "content/public/common/geoposition.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 net::URLRequestContextGetter* context, 62 net::URLRequestContextGetter* context,
62 const GURL& url, 63 const GURL& url,
63 const base::string16& access_token); 64 const base::string16& access_token);
64 virtual LocationProvider* NewSystemLocationProvider(); 65 virtual LocationProvider* NewSystemLocationProvider();
65 virtual base::Time GetTimeNow() const; 66 virtual base::Time GetTimeNow() const;
66 67
67 private: 68 private:
68 // Takes ownership of |provider| on entry; it will either be added to 69 // Takes ownership of |provider| on entry; it will either be added to
69 // |providers_| or deleted on error (e.g. it fails to start). 70 // |providers_| or deleted on error (e.g. it fails to start).
70 void RegisterProvider(LocationProvider* provider); 71 void RegisterProvider(LocationProvider* provider);
72
73 // Checks for either an override or a system location provider and
74 // calls RegisterProvider for it.
75 void RegisterSystemProvider();
Wez 2016/06/10 23:40:34 nit: If you're going to have a per-function commen
CJ 2016/06/13 23:45:20 Done.
71 void OnAccessTokenStoresLoaded( 76 void OnAccessTokenStoresLoaded(
72 AccessTokenStore::AccessTokenMap access_token_map, 77 AccessTokenStore::AccessTokenMap access_token_map,
73 net::URLRequestContextGetter* context_getter); 78 net::URLRequestContextGetter* context_getter);
74 void DoStartProviders(); 79 void DoStartProviders();
75 80
76 // Gets called when a provider has a new position. 81 // Gets called when a provider has a new position.
77 void OnLocationUpdate(const LocationProvider* provider, 82 void OnLocationUpdate(const LocationProvider* provider,
78 const Geoposition& new_position); 83 const Geoposition& new_position);
79 84
80 // Returns true if |new_position| is an improvement over |old_position|. 85 // 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 86 // Set |from_same_provider| to true if both the positions came from the same
82 // provider. 87 // provider.
83 bool IsNewPositionBetter(const Geoposition& old_position, 88 bool IsNewPositionBetter(const Geoposition& old_position,
84 const Geoposition& new_position, 89 const Geoposition& new_position,
85 bool from_same_provider) const; 90 bool from_same_provider) const;
86 91
87 scoped_refptr<AccessTokenStore> access_token_store_; 92 scoped_refptr<AccessTokenStore> access_token_store_;
88 LocationUpdateCallback arbitrator_update_callback_; 93 LocationUpdateCallback arbitrator_update_callback_;
89 LocationProvider::LocationProviderUpdateCallback provider_update_callback_; 94 LocationProvider::LocationProviderUpdateCallback provider_update_callback_;
95 base::CancelableCallback<void(AccessTokenStore::AccessTokenMap,
96 net::URLRequestContextGetter*)>
97 token_store_callback_;
90 ScopedVector<LocationProvider> providers_; 98 ScopedVector<LocationProvider> providers_;
91 bool enable_high_accuracy_; 99 bool enable_high_accuracy_;
92 // The provider which supplied the current |position_| 100 // The provider which supplied the current |position_|
93 const LocationProvider* position_provider_; 101 const LocationProvider* position_provider_;
94 bool is_permission_granted_; 102 bool is_permission_granted_;
95 // The current best estimate of our position. 103 // The current best estimate of our position.
96 Geoposition position_; 104 Geoposition position_;
97 105
98 // Tracks whether providers should be running. 106 // Tracks whether providers should be running.
99 bool is_running_; 107 bool is_running_;
100 108
101 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl); 109 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl);
102 }; 110 };
103 111
104 // Factory functions for the various types of location provider to abstract 112 // Factory functions for the various types of location provider to abstract
105 // over the platform-dependent implementations. 113 // over the platform-dependent implementations.
106 LocationProvider* NewSystemLocationProvider(); 114 LocationProvider* NewSystemLocationProvider();
107 115
108 } // namespace content 116 } // namespace content
109 117
110 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ 118 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698