| OLD | NEW |
| 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 #include "content/browser/geolocation/geolocation_provider_impl.h" | 5 #include "content/browser/geolocation/geolocation_provider_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 base::Bind(&GeolocationProviderImpl::OnClientsChanged, | 85 base::Bind(&GeolocationProviderImpl::OnClientsChanged, |
| 86 base::Unretained(this))); | 86 base::Unretained(this))); |
| 87 } | 87 } |
| 88 | 88 |
| 89 GeolocationProviderImpl::~GeolocationProviderImpl() { | 89 GeolocationProviderImpl::~GeolocationProviderImpl() { |
| 90 Stop(); | 90 Stop(); |
| 91 DCHECK(!arbitrator_); | 91 DCHECK(!arbitrator_); |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool GeolocationProviderImpl::OnGeolocationThread() const { | 94 bool GeolocationProviderImpl::OnGeolocationThread() const { |
| 95 return task_runner()->BelongsToCurrentThread(); | 95 return base::MessageLoop::current() == message_loop(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void GeolocationProviderImpl::OnClientsChanged() { | 98 void GeolocationProviderImpl::OnClientsChanged() { |
| 99 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 99 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 100 base::Closure task; | 100 base::Closure task; |
| 101 if (high_accuracy_callbacks_.empty() && low_accuracy_callbacks_.empty()) { | 101 if (high_accuracy_callbacks_.empty() && low_accuracy_callbacks_.empty()) { |
| 102 DCHECK(IsRunning()); | 102 DCHECK(IsRunning()); |
| 103 if (!ignore_location_updates_) { | 103 if (!ignore_location_updates_) { |
| 104 // We have no more observers, so we clear the cached geoposition so that | 104 // We have no more observers, so we clear the cached geoposition so that |
| 105 // when the next observer is added we will not provide a stale position. | 105 // when the next observer is added we will not provide a stale position. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 | 172 |
| 173 std::unique_ptr<LocationArbitrator> | 173 std::unique_ptr<LocationArbitrator> |
| 174 GeolocationProviderImpl::CreateArbitrator() { | 174 GeolocationProviderImpl::CreateArbitrator() { |
| 175 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( | 175 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( |
| 176 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); | 176 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); |
| 177 return base::WrapUnique(new LocationArbitratorImpl(callback)); | 177 return base::WrapUnique(new LocationArbitratorImpl(callback)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace content | 180 } // namespace content |
| OLD | NEW |