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

Unified Diff: content/browser/geolocation/network_location_provider.cc

Issue 2129313002: Geolocation cleanup: corrects uses of content::AccessTokenStore* and net::URLRequestContextGetter* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wez@ comments. Rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/geolocation/network_location_provider.cc
diff --git a/content/browser/geolocation/network_location_provider.cc b/content/browser/geolocation/network_location_provider.cc
index 8372420b4c20db9754d0620d5f2a4f9cd0ec42e8..00ff9f06c568875437321d38e8d076960a49b783 100644
--- a/content/browser/geolocation/network_location_provider.cc
+++ b/content/browser/geolocation/network_location_provider.cc
@@ -57,15 +57,15 @@ bool NetworkLocationProvider::PositionCache::CachePosition(
}
// Searches for a cached position response for the current WiFi data. Returns
-// the cached position if available, NULL otherwise.
+// the cached position if available, nullptr otherwise.
const Geoposition* NetworkLocationProvider::PositionCache::FindPosition(
const WifiData& wifi_data) {
base::string16 key;
if (!MakeKey(wifi_data, &key)) {
- return NULL;
+ return nullptr;
}
CacheMap::const_iterator iter = cache_.find(key);
- return iter == cache_.end() ? NULL : &iter->second;
+ return iter == cache_.end() ? nullptr : &iter->second;
}
// Makes the key for the map of cached positions, using the available data.
@@ -93,8 +93,8 @@ bool NetworkLocationProvider::PositionCache::MakeKey(
// NetworkLocationProvider factory function
LocationProviderBase* NewNetworkLocationProvider(
- AccessTokenStore* access_token_store,
- net::URLRequestContextGetter* context,
+ const scoped_refptr<AccessTokenStore>& access_token_store,
+ const scoped_refptr<net::URLRequestContextGetter>& context,
const GURL& url,
const base::string16& access_token) {
return new NetworkLocationProvider(
@@ -103,12 +103,12 @@ LocationProviderBase* NewNetworkLocationProvider(
// NetworkLocationProvider
NetworkLocationProvider::NetworkLocationProvider(
- AccessTokenStore* access_token_store,
- net::URLRequestContextGetter* url_context_getter,
+ const scoped_refptr<AccessTokenStore>& access_token_store,
+ const scoped_refptr<net::URLRequestContextGetter>& url_context_getter,
const GURL& url,
const base::string16& access_token)
: access_token_store_(access_token_store),
- wifi_data_provider_manager_(NULL),
+ wifi_data_provider_manager_(nullptr),
wifi_data_update_callback_(
base::Bind(&NetworkLocationProvider::OnWifiDataUpdate,
base::Unretained(this))),
@@ -116,10 +116,8 @@ NetworkLocationProvider::NetworkLocationProvider(
access_token_(access_token),
is_permission_granted_(false),
is_new_data_available_(false),
+ position_cache_(new PositionCache()),
weak_factory_(this) {
- // Create the position cache.
- position_cache_.reset(new PositionCache());
-
request_.reset(new NetworkLocationRequest(
url_context_getter,
url,
@@ -168,9 +166,8 @@ void NetworkLocationProvider::OnLocationResponse(
DCHECK(CalledOnValidThread());
// Record the position and update our cache.
position_ = position;
- if (position.Validate()) {
+ if (position.Validate())
Wez 2016/07/16 00:35:10 nit: Keep the { } for consistency with the rest of
mcasas 2016/07/16 01:17:46 Done.
position_cache_->CachePosition(wifi_data, position);
- }
// Record access_token if it's set.
if (!access_token.empty() && access_token_ != access_token) {
@@ -186,7 +183,7 @@ bool NetworkLocationProvider::StartProvider(bool high_accuracy) {
DCHECK(CalledOnValidThread());
if (IsStarted())
return true;
- DCHECK(wifi_data_provider_manager_ == NULL);
+ DCHECK(wifi_data_provider_manager_ == nullptr);
Wez 2016/07/16 00:35:10 nit: !wifi_data_provider_manager_
mcasas 2016/07/16 01:17:46 Done.
if (!request_->url().is_valid()) {
LOG(WARNING) << "StartProvider() : Failed, Bad URL: "
<< request_->url().possibly_invalid_spec();
@@ -223,7 +220,7 @@ void NetworkLocationProvider::StopProvider() {
if (IsStarted()) {
wifi_data_provider_manager_->Unregister(&wifi_data_update_callback_);
}
- wifi_data_provider_manager_ = NULL;
+ wifi_data_provider_manager_ = nullptr;
weak_factory_.InvalidateWeakPtrs();
}
@@ -268,7 +265,7 @@ void NetworkLocationProvider::RequestPosition() {
}
bool NetworkLocationProvider::IsStarted() const {
- return wifi_data_provider_manager_ != NULL;
+ return wifi_data_provider_manager_ != nullptr;
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698