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

Unified Diff: chrome/browser/policy/device_status_location_helper.h

Issue 10103029: Add device location reporting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Also added lots of includes to IWYU. Created 8 years, 8 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: chrome/browser/policy/device_status_location_helper.h
diff --git a/chrome/browser/policy/device_status_location_helper.h b/chrome/browser/policy/device_status_location_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..2c92a4b74a1965b2307ba82dfa20d398afff882d
--- /dev/null
+++ b/chrome/browser/policy/device_status_location_helper.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_POLICY_DEVICE_LOCATION_HELPER_H_
+#define CHROME_BROWSER_POLICY_DEVICE_LOCATION_HELPER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/timer.h"
+#include "content/browser/geolocation/geolocation_observer.h"
+#include "content/common/geoposition.h"
+
+class GeolocationProvider;
+class PrefService;
+
+namespace base {
+template<typename Type> class DeleteHelper;
+}
+
+namespace policy {
+
+// Helper class for retrieving the device's geographic location.
+class DeviceStatusLocationHelper : public GeolocationObserver {
+ public:
+ explicit DeviceStatusLocationHelper(PrefService* local_state);
+ void Destruct();
+
+ const Geoposition& GetPosition() const;
+
+ static void RegisterPrefs(PrefService* local_state);
+
+ virtual void OnLocationUpdate(const Geoposition& position) OVERRIDE;
+
+ void SetGeolocationProviderForTest(GeolocationProvider* provider);
+
+ static const unsigned int kPollIntervalSeconds = 1800;
+
+ private:
+ friend class base::DeleteHelper<DeviceStatusLocationHelper>;
+ virtual ~DeviceStatusLocationHelper();
+
+ void Init(const Geoposition& position);
+ void DestructInternal();
+
+ void ScheduleUpdate(const Geoposition& position);
+
+ void StartObserving();
+ void StopObserving();
+
+ void ReceiveUpdate(const Geoposition& position);
+
+ // Used by UI thread only
+ PrefService* local_state_;
+ Geoposition position_;
+
+ // Used by IO thread only
+ base::OneShotTimer<DeviceStatusLocationHelper>* timer_;
+ GeolocationProvider* provider_;
+ bool observing_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceStatusLocationHelper);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_DEVICE_LOCATION_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698