Chromium Code Reviews| 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 4cce48905ee5dd38c999ad81fc49f970beb7e981..13eee8ba12e7f2d22bffa1a7d4903710089de0d3 100644 |
| --- a/blimp/engine/feature/geolocation/engine_geolocation_feature.cc |
| +++ b/blimp/engine/feature/geolocation/engine_geolocation_feature.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/threading/thread_task_runner_handle.h" |
| #include "blimp/common/create_blimp_message.h" |
| #include "blimp/common/proto/blimp_message.pb.h" |
| #include "blimp/common/proto/geolocation.pb.h" |
| @@ -20,6 +21,7 @@ |
| namespace blimp { |
| namespace engine { |
| namespace { |
| + |
| class BlimpGeolocationDelegate : public device::GeolocationDelegate { |
| public: |
| explicit BlimpGeolocationDelegate( |
| @@ -120,7 +122,8 @@ void EngineGeolocationFeature::ProcessMessage( |
| void EngineGeolocationFeature::NotifyCallback( |
| const device::Geoposition& position) { |
| - geoposition_received_callback_.Run(position); |
| + task_runner_->PostTask(FROM_HERE, |
| + base::Bind(geoposition_received_callback_, position)); |
| } |
| void EngineGeolocationFeature::RequestAccuracy( |
| @@ -151,6 +154,12 @@ void EngineGeolocationFeature::OnPermissionGranted() { |
| void EngineGeolocationFeature::SetUpdateCallback( |
| const GeopositionReceivedCallback& callback) { |
| geoposition_received_callback_ = callback; |
| + SetTaskRunner(base::ThreadTaskRunnerHandle::Get()); |
|
Kevin M
2016/09/01 20:01:07
This probably doesn't need a helper function - may
CJ
2016/09/01 22:59:42
Done.
|
| +} |
| + |
| +void EngineGeolocationFeature::SetTaskRunner( |
|
Kevin M
2016/09/01 20:01:07
Recommend renaming |task_runner_| to |callback_tas
CJ
2016/09/01 22:59:42
Done.
|
| + scoped_refptr<base::SingleThreadTaskRunner> runner) { |
| + task_runner_ = std::move(runner); |
| } |
| } // namespace engine |