Chromium Code Reviews| Index: blimp/engine/feature/geolocation/blimp_location_provider.cc |
| diff --git a/blimp/engine/feature/geolocation/blimp_location_provider.cc b/blimp/engine/feature/geolocation/blimp_location_provider.cc |
| index de86b9fc1e65b31384c8cbdd43cca52128e388ca..58354b24b512cb8fc0277491dc615e0e0f35c641 100644 |
| --- a/blimp/engine/feature/geolocation/blimp_location_provider.cc |
| +++ b/blimp/engine/feature/geolocation/blimp_location_provider.cc |
| @@ -4,58 +4,67 @@ |
| #include "blimp/engine/feature/geolocation/blimp_location_provider.h" |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "content/public/common/geoposition.h" |
| namespace blimp { |
| namespace engine { |
| -BlimpLocationProvider::BlimpLocationProvider() {} |
| +BlimpLocationProvider::BlimpLocationProvider( |
| + base::WeakPtr<BlimpLocationProvider::Delegate> delegate) { |
| + DCHECK(delegate); |
| + |
| + delegate_ = delegate; |
| + is_started_ = false; |
|
Wez
2016/07/22 01:18:58
nit: Can we move these to be member initializers,
CJ
2016/07/22 20:03:29
Done.
|
| +} |
| BlimpLocationProvider::~BlimpLocationProvider() { |
| StopProvider(); |
| } |
| bool BlimpLocationProvider::StartProvider(bool high_accuracy) { |
| - NOTIMPLEMENTED(); |
| - return true; |
| + if (delegate_) { |
| + if (high_accuracy) { |
| + delegate_->RequestAccuracy( |
| + GeolocationSetInterestLevelMessage::HIGH_ACCURACY); |
| + } else { |
| + delegate_->RequestAccuracy( |
| + GeolocationSetInterestLevelMessage::LOW_ACCURACY); |
| + } |
| + is_started_ = true; |
| + return true; |
| + } |
| + return false; |
| } |
| void BlimpLocationProvider::StopProvider() { |
| + if (delegate_ && is_started_) { |
|
Wez
2016/07/22 01:18:58
Did we establish whether it's valid to call StopPr
CJ
2016/07/22 20:03:29
Done.
|
| + delegate_->RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST); |
| + is_started_ = false; |
| + } |
| } |
| void BlimpLocationProvider::GetPosition(content::Geoposition* position) { |
| - DCHECK(position); |
| - |
| - *position = position_; |
| + *position = cached_position_; |
| } |
| void BlimpLocationProvider::RequestRefresh() { |
| - NOTIMPLEMENTED(); |
| + if (delegate_ && is_started_) { |
|
Wez
2016/07/22 01:18:58
Again, is it actually valid for the caller to requ
CJ
2016/07/22 20:03:29
Done.
|
| + delegate_->RequestRefresh(); |
| + } |
| } |
| void BlimpLocationProvider::OnPermissionGranted() { |
| RequestRefresh(); |
| - NOTIMPLEMENTED(); |
| -} |
| - |
| -void BlimpLocationProvider::NotifyCallback( |
| - const content::Geoposition& position) { |
| - DCHECK(!callback_.is_null()); |
| - |
| - callback_.Run(this, position); |
| -} |
| - |
| -void BlimpLocationProvider::OnLocationResponse( |
| - const content::Geoposition& position) { |
| - NotifyCallback(position); |
| - NOTIMPLEMENTED(); |
| } |
| void BlimpLocationProvider::SetUpdateCallback( |
| const LocationProviderUpdateCallback& callback) { |
| - DCHECK(!callback.is_null()); |
| - |
| - callback_ = callback; |
| + if (delegate_) { |
| + delegate_->SetUpdateCallback(base::Bind(callback, base::Unretained(this))); |
| + } |
| } |
| } // namespace engine |