diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 00:25:49 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 00:25:49 +0000 |
commit | a57a16a9c14f6a6ec9416bcf8513b55e206e654d (patch) | |
tree | 393db08d61a986e0e8e6f64ed048eb11f87cec97 /content/browser/geolocation/location_arbitrator_impl.cc | |
parent | 335c458c68efe73f2153365163b7a4b011347f5a (diff) | |
download | chromium_src-a57a16a9c14f6a6ec9416bcf8513b55e206e654d.zip chromium_src-a57a16a9c14f6a6ec9416bcf8513b55e206e654d.tar.gz chromium_src-a57a16a9c14f6a6ec9416bcf8513b55e206e654d.tar.bz2 |
[Geolocation] Fix a race condition in GeolocationArbitratorImpl
Previously, the following sequence of events was possible:
(1) StartProviders() posts an asynchronous task T to continue startup.
(2) StopProviders() is called.
(3) T comes back, and startup continues.
Now, step (3) will short-circuit so that startup does not continue if the
asynchronous continuation comes in after StopProviders() is called.
BUG=166596
Review URL: https://chromiumcodereview.appspot.com/14864017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/geolocation/location_arbitrator_impl.cc')
-rw-r--r-- | content/browser/geolocation/location_arbitrator_impl.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/content/browser/geolocation/location_arbitrator_impl.cc b/content/browser/geolocation/location_arbitrator_impl.cc index 7720c55..4fa19b5 100644 --- a/content/browser/geolocation/location_arbitrator_impl.cc +++ b/content/browser/geolocation/location_arbitrator_impl.cc @@ -29,7 +29,8 @@ GeolocationArbitratorImpl::GeolocationArbitratorImpl( const LocationUpdateCallback& callback) : callback_(callback), position_provider_(NULL), - is_permission_granted_(false) { + is_permission_granted_(false), + is_running_(false) { } GeolocationArbitratorImpl::~GeolocationArbitratorImpl() { @@ -49,6 +50,7 @@ void GeolocationArbitratorImpl::OnPermissionGranted() { void GeolocationArbitratorImpl::StartProviders(bool use_high_accuracy) { // Stash options as OnAccessTokenStoresLoaded has not yet been called. + is_running_ = true; use_high_accuracy_ = use_high_accuracy; if (providers_.empty()) { DCHECK(DefaultNetworkProviderURL().is_valid()); @@ -69,12 +71,13 @@ void GeolocationArbitratorImpl::DoStartProviders() { void GeolocationArbitratorImpl::StopProviders() { providers_.clear(); + is_running_ = false; } void GeolocationArbitratorImpl::OnAccessTokenStoresLoaded( AccessTokenStore::AccessTokenSet access_token_set, net::URLRequestContextGetter* context_getter) { - if (!providers_.empty()) { + if (!is_running_ || !providers_.empty()) { // A second StartProviders() call may have arrived before the first // completed. return; |