| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "blimp/engine/feature/geolocation/blimp_location_provider.h" | 5 #include "blimp/engine/feature/geolocation/blimp_location_provider.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/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "device/geolocation/geoposition.h" | 10 #include "content/public/common/geoposition.h" |
| 11 | 11 |
| 12 namespace blimp { | 12 namespace blimp { |
| 13 namespace engine { | 13 namespace engine { |
| 14 | 14 |
| 15 BlimpLocationProvider::BlimpLocationProvider( | 15 BlimpLocationProvider::BlimpLocationProvider( |
| 16 base::WeakPtr<BlimpLocationProvider::Delegate> delegate) | 16 base::WeakPtr<BlimpLocationProvider::Delegate> delegate) |
| 17 : delegate_(delegate), is_started_(false) {} | 17 : delegate_(delegate), is_started_(false) {} |
| 18 | 18 |
| 19 BlimpLocationProvider::~BlimpLocationProvider() { | 19 BlimpLocationProvider::~BlimpLocationProvider() { |
| 20 if (is_started_) { | 20 if (is_started_) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 void BlimpLocationProvider::StopProvider() { | 39 void BlimpLocationProvider::StopProvider() { |
| 40 DCHECK(is_started_); | 40 DCHECK(is_started_); |
| 41 if (delegate_) { | 41 if (delegate_) { |
| 42 delegate_->RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST); | 42 delegate_->RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST); |
| 43 is_started_ = false; | 43 is_started_ = false; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void BlimpLocationProvider::GetPosition(device::Geoposition* position) { | 47 void BlimpLocationProvider::GetPosition(content::Geoposition* position) { |
| 48 *position = cached_position_; | 48 *position = cached_position_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void BlimpLocationProvider::RequestRefresh() { | 51 void BlimpLocationProvider::RequestRefresh() { |
| 52 DCHECK(is_started_); | 52 DCHECK(is_started_); |
| 53 if (delegate_) { | 53 if (delegate_) { |
| 54 delegate_->RequestRefresh(); | 54 delegate_->RequestRefresh(); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 void BlimpLocationProvider::OnPermissionGranted() { | 58 void BlimpLocationProvider::OnPermissionGranted() { |
| 59 RequestRefresh(); | 59 RequestRefresh(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void BlimpLocationProvider::SetUpdateCallback( | 62 void BlimpLocationProvider::SetUpdateCallback( |
| 63 const LocationProviderUpdateCallback& callback) { | 63 const LocationProviderUpdateCallback& callback) { |
| 64 if (delegate_) { | 64 if (delegate_) { |
| 65 delegate_->SetUpdateCallback(base::Bind(callback, base::Unretained(this))); | 65 delegate_->SetUpdateCallback(base::Bind(callback, base::Unretained(this))); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace engine | 69 } // namespace engine |
| 70 } // namespace blimp | 70 } // namespace blimp |
| OLD | NEW |