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

Unified Diff: third_party/WebKit/Source/modules/geolocation/Geolocation.h

Issue 1367853002: Move GeolocationDispatcher into blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: third_party/WebKit/Source/modules/geolocation/Geolocation.h
diff --git a/third_party/WebKit/Source/modules/geolocation/Geolocation.h b/third_party/WebKit/Source/modules/geolocation/Geolocation.h
index 6518b959b7977789051bfb3c7acc4774cf8be38b..8c41a8b9205ed15d0bc341523a6f20b7792cee7a 100644
--- a/third_party/WebKit/Source/modules/geolocation/Geolocation.h
+++ b/third_party/WebKit/Source/modules/geolocation/Geolocation.h
@@ -28,7 +28,8 @@
#define Geolocation_h
#include "bindings/core/v8/ScriptWrappable.h"
-#include "core/dom/ActiveDOMObject.h"
+#include "core/dom/ContextLifecycleObserver.h"
+#include "core/page/PageLifecycleObserver.h"
#include "modules/ModulesExport.h"
#include "modules/geolocation/GeoNotifier.h"
#include "modules/geolocation/GeolocationWatchers.h"
@@ -39,6 +40,9 @@
#include "modules/geolocation/PositionOptions.h"
#include "platform/Timer.h"
#include "platform/heap/Handle.h"
+#include "third_party/WebKit/public/platform/modules/geolocation/geolocation.mojom-blink.h"
+#include "third_party/WebKit/public/platform/modules/permissions/permission.mojom-blink.h"
+#include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom-blink.h"
namespace blink {
@@ -50,15 +54,18 @@ class ExecutionContext;
class MODULES_EXPORT Geolocation final
: public GarbageCollectedFinalized<Geolocation>
, public ScriptWrappable
- , public ActiveDOMObject {
+ , public ContextLifecycleObserver
+ , public PageLifecycleObserver {
DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(Geolocation);
public:
static Geolocation* create(ExecutionContext*);
- ~Geolocation() override;
+ ~Geolocation();
DECLARE_VIRTUAL_TRACE();
- void stop() override;
+ // Inherited from ContextLifecycleObserver AND PageLifecycleObserver.
+ void contextDestroyed() override;
+
Document* document() const;
LocalFrame* frame() const;
@@ -73,17 +80,12 @@ public:
// Removes all references to the watcher, it will not be updated again.
void clearWatch(int watchID);
- void setIsAllowed(bool);
-
bool isAllowed() const { return m_geolocationPermission == PermissionAllowed; }
// Notifies this that a new position is available. Must never be called
// before permission is granted by the user.
void positionChanged();
- // Notifies this that an error has occurred, it must be handled immediately.
- void setError(GeolocationError*);
-
// Discards the notifier because a fatal error occurred for it.
void fatalErrorOccurred(GeoNotifier*);
@@ -95,10 +97,10 @@ public:
// Discards the notifier if it is a oneshot because it timed it.
void requestTimedOut(GeoNotifier*);
-private:
- // Returns the last known position, if any. May return null.
- Geoposition* lastPosition();
+ // Inherited from PageLifecycleObserver.
+ void pageVisibilityChanged() override;
+private:
bool isDenied() const { return m_geolocationPermission == PermissionDenied; }
explicit Geolocation(ExecutionContext*);
@@ -141,33 +143,37 @@ private:
// Requests permission to share positions with the page.
void requestPermission();
- // Attempts to register this with the controller for receiving updates.
- // Returns false if there is no controller to register with.
- bool startUpdating(GeoNotifier*);
+ // Connects to the Geolocation mojo service and starts polling for updates.
+ void startUpdating(GeoNotifier*);
void stopUpdating();
- // Processes the notifiers that were waiting for a permission decision. If
- // granted and this can be registered with the controller then the
- // notifier's timers are started. Otherwise, a fatal error is set on them.
- void handlePendingPermissionNotifiers();
+ void updateGeolocationServiceConnection();
+ void queryNextPosition();
// Attempts to obtain a position for the given notifier, either by using
- // the cached position or by requesting one from the controller. Sets a
- // fatal error if permission is denied or no position can be obtained.
+ // the cached position or by requesting one from the GeolocationService.
+ // Sets a fatal error if permission is denied or no position can be
+ // obtained.
void startRequest(GeoNotifier*);
bool haveSuitableCachedPosition(const PositionOptions&);
- // Runs the success callbacks for the set of notifiers awaiting a cached
- // position, the set is then cleared. The oneshots are removed everywhere.
- void makeCachedPositionCallbacks();
-
// Record whether the origin trying to access Geolocation would be allowed
// to access a feature that can only be accessed by secure origins.
// See https://goo.gl/Y0ZkNV
void recordOriginTypeAccess() const;
+ void onPositionUpdated(mojom::blink::GeopositionPtr);
+
+ // Processes the notifiers that were waiting for a permission decision. If
+ // granted then the notifier's timers are started. Otherwise, a fatal error
+ // is set on them.
+ void onGeolocationPermissionUpdated(mojom::blink::PermissionStatus);
+
+ void onGeolocationConnectionError();
+ void onPermissionConnectionError();
+
GeoNotifierSet m_oneShots;
GeolocationWatchers m_watchers;
GeoNotifierSet m_pendingForPermissionNotifiers;
@@ -184,8 +190,17 @@ private:
};
Permission m_geolocationPermission;
+ mojom::blink::GeolocationServicePtr m_geolocationService;
+ bool m_enableHighAccuracy = false;
+ mojom::blink::PermissionServicePtr m_permissionService;
+
+ // Whether a GeoNotifier is waiting for a position update.
+ bool m_updating = false;
- GeoNotifierSet m_requestsAwaitingCachedPosition;
+ // Set to true when m_geolocationService is disconnected. This is used to
+ // detect when m_geolocationService is disconnected and reconnected while
+ // running callbacks in response to a call to onPositionUpdated().
+ bool m_disconnectedGeolocationService = false;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698