Index: device/geolocation/rate_limiting_location_provider_proxy.cc |
diff --git a/device/geolocation/rate_limiting_location_provider_proxy.cc b/device/geolocation/rate_limiting_location_provider_proxy.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ff9e7b55b4d7f111b234cb868e108f34dfdd0de0 |
--- /dev/null |
+++ b/device/geolocation/rate_limiting_location_provider_proxy.cc |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "device/geolocation/rate_limiting_location_provider_proxy.h" |
+ |
+#include "device/geolocation/geolocation_delegate.h" |
+#include "device/geolocation/geoposition.h" |
+#include "device/geolocation/location_arbitrator.h" |
+ |
+namespace device { |
+ |
+RateLimitingLocationProviderProxy::RateLimitingLocationProviderProxy() |
+ : location_provider_(new LocationArbitrator(new GeolocationDelegate())) { |
Kevin M
2016/08/22 22:09:34
nit: remove () from new GeolocationDelegate()
CJ
2016/08/23 18:07:13
Done.
|
+ location_provider_->SetUpdateCallback( |
+ base::Bind(&RateLimitingLocationProviderProxy::OnLocationUpdate, |
+ base::Unretained(this))); |
+} |
+ |
+RateLimitingLocationProviderProxy::~RateLimitingLocationProviderProxy() {} |
+ |
+void RateLimitingLocationProviderProxy::SetUpdateCallback( |
+ const LocationProviderUpdateCallback& callback) { |
+ DCHECK(!callback.is_null()); |
+ feature_update_callback_ = callback; |
+} |
+ |
+bool RateLimitingLocationProviderProxy::StartProvider( |
+ bool enable_high_accuracy) { |
+ return location_provider_->StartProvider(enable_high_accuracy); |
+} |
+ |
+void RateLimitingLocationProviderProxy::StopProvider() { |
+ location_provider_->StopProvider(); |
+} |
+ |
+const device::Geoposition& RateLimitingLocationProviderProxy::GetPosition() { |
+ return location_provider_->GetPosition(); |
+} |
+ |
+void RateLimitingLocationProviderProxy::OnPermissionGranted() { |
+ location_provider_->OnPermissionGranted(); |
+} |
+ |
+void RateLimitingLocationProviderProxy::OnLocationUpdate( |
+ const LocationProvider* provider, |
+ const Geoposition& new_position) { |
+ feature_update_callback_.Run(this, new_position); |
+} |
+ |
+} // namespace device |