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

Unified Diff: blimp/engine/feature/geolocation/engine_geolocation_feature.cc

Issue 2328453003: Makes use of EngineGeolocationFeature weak_ptr threadsafe. (Closed)
Patch Set: Addresses Wez's #23 comments. Created 4 years, 2 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: blimp/engine/feature/geolocation/engine_geolocation_feature.cc
diff --git a/blimp/engine/feature/geolocation/engine_geolocation_feature.cc b/blimp/engine/feature/geolocation/engine_geolocation_feature.cc
index 3e8551db1b6b5b51e3e56513db08cc8ea7af1d8f..f1b913cfc9cbd2d60ed5873d2b70414e19299442 100644
--- a/blimp/engine/feature/geolocation/engine_geolocation_feature.cc
+++ b/blimp/engine/feature/geolocation/engine_geolocation_feature.cc
@@ -27,17 +27,20 @@ class BlimpGeolocationDelegate : public device::GeolocationDelegate {
explicit BlimpGeolocationDelegate(
base::WeakPtr<BlimpLocationProvider::Delegate> feature_delegate) {
feature_delegate_ = feature_delegate;
+ feature_task_runner_ = base::ThreadTaskRunnerHandle::Get();
}
bool UseNetworkLocationProviders() final { return false; }
std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider()
final {
- return base::MakeUnique<BlimpLocationProvider>(feature_delegate_);
+ return base::MakeUnique<BlimpLocationProvider>(feature_delegate_,
+ feature_task_runner_);
}
private:
base::WeakPtr<BlimpLocationProvider::Delegate> feature_delegate_;
+ scoped_refptr<base::SingleThreadTaskRunner> feature_task_runner_;
DISALLOW_COPY_AND_ASSIGN(BlimpGeolocationDelegate);
};
@@ -122,8 +125,7 @@ void EngineGeolocationFeature::ProcessMessage(
void EngineGeolocationFeature::NotifyCallback(
const device::Geoposition& position) {
- callback_task_runner_->PostTask(
- FROM_HERE, base::Bind(geoposition_received_callback_, position));
+ geoposition_received_callback_.Run(position);
}
void EngineGeolocationFeature::RequestAccuracy(
@@ -154,9 +156,6 @@ void EngineGeolocationFeature::OnPermissionGranted() {
void EngineGeolocationFeature::SetUpdateCallback(
const GeopositionReceivedCallback& callback) {
geoposition_received_callback_ = callback;
-
- // Set |callback_task_runner_| to run on the current thread.
- callback_task_runner_ = base::ThreadTaskRunnerHandle::Get();
}
} // namespace engine

Powered by Google App Engine
This is Rietveld 408576698