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

Unified Diff: third_party/WebKit/Source/web/WebGeolocationController.cpp

Issue 1444333002: WebGeolocationController: improve handling of bare GeolocationController* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/web/WebGeolocationController.cpp
diff --git a/third_party/WebKit/Source/web/WebGeolocationController.cpp b/third_party/WebKit/Source/web/WebGeolocationController.cpp
index 1d8fb59bc4b985d7c50d6a31d37bacaee6ea7d1b..84ba1f48d6ccd49dc16189851113c4b7ba93853e 100644
--- a/third_party/WebKit/Source/web/WebGeolocationController.cpp
+++ b/third_party/WebKit/Source/web/WebGeolocationController.cpp
@@ -29,19 +29,74 @@
#include "modules/geolocation/GeolocationController.h"
#include "modules/geolocation/GeolocationError.h"
#include "modules/geolocation/GeolocationPosition.h"
+#include "platform/heap/Handle.h"
#include "public/web/WebGeolocationError.h"
#include "public/web/WebGeolocationPosition.h"
+#include "wtf/RefCounted.h"
namespace blink {
+#if ENABLE(OILPAN)
+// TODO(Oilpan): once GeolocationController is always on the heap,
+// shorten out this GeolocationControllerPrivate intermediary.
+class GeolocationControllerPrivate : public GeolocationController {
+public:
+ static GeolocationController& controller(const WebPrivatePtr<GeolocationControllerPrivate>& controller)
+ {
+ ASSERT(!controller.isNull());
+ return *controller;
+ }
+};
+#else
+class GeolocationControllerPrivate final : public RefCounted<GeolocationControllerPrivate> {
+public:
+ static PassRefPtr<GeolocationControllerPrivate> create(GeolocationController* controller)
+ {
+ return adoptRef(new GeolocationControllerPrivate(controller));
+ }
+
+ static GeolocationController& controller(const WebPrivatePtr<GeolocationControllerPrivate>& controller)
+ {
+ ASSERT(!controller.isNull());
+ ASSERT(controller->m_controller);
+ return *controller->m_controller;
+ }
+
+private:
+ explicit GeolocationControllerPrivate(GeolocationController* controller)
+ : m_controller(controller)
+ {
+ }
+
+ // Non-Oilpan, this bare pointer is owned as a supplement and kept alive
+ // by the frame of the WebLocalFrame which creates the WebGeolocationController
+ // object that wraps it all up.
+ GeolocationController* m_controller;
+};
+#endif
+
+WebGeolocationController::WebGeolocationController(GeolocationController* controller)
+#if ENABLE(OILPAN)
+ : m_private(static_cast<GeolocationControllerPrivate*>(controller))
+#else
+ : m_private(GeolocationControllerPrivate::create(controller))
+#endif
+{
+}
+
+void WebGeolocationController::reset()
+{
+ m_private.reset();
+}
+
void WebGeolocationController::positionChanged(const WebGeolocationPosition& webPosition)
{
- m_private->positionChanged(static_cast<GeolocationPosition*>(webPosition));
+ GeolocationControllerPrivate::controller(m_private).positionChanged(static_cast<GeolocationPosition*>(webPosition));
}
void WebGeolocationController::errorOccurred(const WebGeolocationError& webError)
{
- m_private->errorOccurred(static_cast<GeolocationError*>(webError));
+ GeolocationControllerPrivate::controller(m_private).errorOccurred(static_cast<GeolocationError*>(webError));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698