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

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: In response to Wez's #86 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 #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 base::CancelableCallback<void(AccessTokenStore::AccessTokenMap,
95 net::URLRequestContextGetter*)>
96 token_store_callback_;
Charlie Reis 2016/06/16 21:56:54 Just a reminder for this request.
CJ 2016/06/21 22:16:07 Done.
97 std::vector<std::unique_ptr<LocationProvider>> providers_;
91 bool enable_high_accuracy_; 98 bool enable_high_accuracy_;
92 // The provider which supplied the current |position_| 99 // The provider which supplied the current |position_|
93 const LocationProvider* position_provider_; 100 const LocationProvider* position_provider_;
94 bool is_permission_granted_; 101 bool is_permission_granted_;
95 // The current best estimate of our position. 102 // The current best estimate of our position.
96 Geoposition position_; 103 Geoposition position_;
97 104
98 // Tracks whether providers should be running. 105 // Tracks whether providers should be running.
99 bool is_running_; 106 bool is_running_;
100 107
101 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl); 108 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl);
102 }; 109 };
103 110
104 // Factory functions for the various types of location provider to abstract 111 // Factory functions for the various types of location provider to abstract
105 // over the platform-dependent implementations. 112 // over the platform-dependent implementations.
106 LocationProvider* NewSystemLocationProvider(); 113 LocationProvider* NewSystemLocationProvider();
107 114
108 } // namespace content 115 } // namespace content
109 116
110 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ 117 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698