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

Unified Diff: device/geolocation/rate_limiting_location_provider_proxy.cc

Issue 2249283003: Hooks together Geolocation Feature in the Client and Engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lai
Patch Set: Addresses kmarshall's #16 comments. Created 4 years, 4 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: 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..dd891bcb469fb9c55d84c2785a9b0066bb22ee4c
--- /dev/null
+++ b/device/geolocation/rate_limiting_location_provider_proxy.cc
@@ -0,0 +1,56 @@
+// 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)) {
Wez 2016/08/24 23:07:18 This class is just supposed to be a proxy - i.e. a
CJ 2016/08/25 19:08:22 Changed to take in a LocationProvider. Should have
+ location_provider_->SetUpdateCallback(
+ base::Bind(&RateLimitingLocationProviderProxy::OnLocationUpdate,
+ base::Unretained(this)));
+}
+
+RateLimitingLocationProviderProxy::~RateLimitingLocationProviderProxy() {}
+
+void RateLimitingLocationProviderProxy::SetLocationProviderForTest(
+ std::unique_ptr<LocationProvider> location_provider) {
+ location_provider_ = std::move(location_provider);
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698