Thanks for the patch. I prefer if the geoclue version is detected automatically instead of having to pass an option to configure, if possible. As martin said, we need the cmake support too. I think we should use a common class name and header files, and different implementation (cpp files only) for geoclue 1 and 2. That way we don't even change anything in WebKit layer, because the provider api used by the api layer is the same.
And here we are leaking the new proxy? updateLocation doesn't seem to take the ownership, it simply gets info from the location proxy. Maybe we could pass a GRefPtr to make it more explicit and we don't need comments.
Why are we duplicating this? Can't we use the same provider client for both geoclue 1 and 2? This looks exactly the same that GeolocationProviderGeoclueClient.h
Comment on attachment 225392
Patch Proposal
View in context: https:/ /bugs.webkit. org/attachment. cgi?id= 225392& action= review
Thanks for the patch. I prefer if the geoclue version is detected automatically instead of having to pass an option to configure, if possible. As martin said, we need the cmake support too. I think we should use a common class name and header files, and different implementation (cpp files only) for geoclue 1 and 2. That way we don't even change anything in WebKit layer, because the provider api used by the api layer is the same.
> Source/ Platform/ GNUmakefile. am:15 builddir) /DerivedSources /geoclue2
> + -I$(top_
This should probably be something like DerivedSources/ WebCore/ geoclue2. Do we really need generated code for this?
> Source/ WebCore/ GNUmakefile. am:389
> +# Geoclue interface
I think it's pretty obvious already :-)
> Source/ WebCore/ GNUmakefile. am:391 /geoclue2/ geoclue- interface. c: DerivedSources/ geoclue2/ geoclue- interface. h /geoclue2/ geoclue- interface. h:
> +DerivedSources
> +DerivedSources
We should probably name the generated files GeoClue2Interface.h and GeoClue2Interface.c for consistency.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:31 GRefPtr. h>
> +#include <wtf/gobject/
This si already included by the header.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:34 WTFString. h>
> +#include <wtf/text/
Ditto.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:41
> +using namespace WebCore;
> +
> +namespace {
Why?
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:48 LEVEL_COUNTRY = 1, LEVEL_CITY = 4, LEVEL_STREET = 6, LEVEL_EXACT = 8,
> +typedef enum {
> + GCLUE_ACCURACY_
> + GCLUE_ACCURACY_
> + GCLUE_ACCURACY_
> + GCLUE_ACCURACY_
> +} GClueAccuracyLevel;
This should follow webkit coding style since it's private
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:55 iderGeoclue2* provider = static_ cast<Geolocatio nProviderGeoclu e2*>(self) ;
> + GeolocationProv
You could probably cast the callback and use GeolocationProv iderGeoclue2* provider as parameter instead of void* self.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:60 >setGeoclueMana gerProxyAndGetC lient(managerPr oxy);
> + provider-
Add a comment here that the provider takes the ownership.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:68 iderGeoclue2* provider = static_ cast<Geolocatio nProviderGeoclu e2*>(self) ;
> + GeolocationProv
Ditto.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:82 iderGeoclue2* provider = static_ cast<Geolocatio nProviderGeoclu e2*>(self) ;
> + GeolocationProv
Ditto.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:87 >setGeoclueClie ntProxyAndStart (clientProxy) ;
> + provider-
Add a comment here about the ownership transfer too.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:101 >updateLocation (locationProxy) ;
> + provider-
And here we are leaking the new proxy? updateLocation doesn't seem to take the ownership, it simply gets info from the location proxy. Maybe we could pass a GRefPtr to make it more explicit and we don't need comments.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:107 roxyCallback, self);
> + 0, createLocationP
0 -> nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:138 clear() ; clear() ;
> + m_clientProxy.
> + m_managerProxy.
These are going to be deleted now
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:146 proxy_new_ for_bus( G_BUS_TYPE_ SYSTEM, G_DBUS_ PROXY_FLAGS_ NONE, GEOCLUE_BUS_NAME, GEOCLUE_ MANAGER_ PATH, 0, createGeoclueMa nagerProxyCallb ack, this);
> + gclue_manager_
0 -> nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:151 call_get_ client( m_managerProxy. get(), 0, getGeoclueClien tCallback, this);
> + gclue_manager_
0 -> nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:161 call_stop( m_clientProxy. get(), 0, 0, 0);
> + gclue_client_
nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:163 .clear( );
> + m_locationProxy
Where is this set?
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:169 uracy = enable;
> + m_enableHighAcc
Should we check if the value has actually changed and return early if it hasn't?
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:185 call_start( m_clientProxy. get(), 0, startClientCall back, this);
> + gclue_client_
nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:192 call_get_ client( m_managerProxy. get(), 0, getGeoclueClien tCallback, this);
> + gclue_manager_
nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:197 proxy_new_ for_bus( G_BUS_TYPE_ SYSTEM, G_DBUS_ PROXY_FLAGS_ NONE, GEOCLUE_BUS_NAME, path,
> + gclue_client_
This doesn't use anything from the object, could we do this directly in the callback that call this, like you are doing for for the location proxy?
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:198 ientProxyCallba ck, this);
> + 0, createGeoclueCl
nullptr
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:220
> + m_altitude = 0; // altitude is not supported now
This will never change
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. cpp:222
> + m_altitudeAccuracy = 0; // altitude accuracy is not supported now
Ditto.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. h:46 erProxyAndGetCl ient(GClueManag er*); ientProxyAndIni tialize( const gchar*); tProxyAndStart( GClueClient* ); GClueLocation* );
> + // To be used from signal callbacks.
> + void setGeoclueManag
> + void createGeoclueCl
> + void setGeoclueClien
> + void updateLocation(
> + void errorOccurred(const char*);
Can we make the callbacks static members and we don't need all this API to be public?
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2. h:55 GClueLocation> m_locationProxy;
> + GRefPtr<
This looks unused.
> Source/ WebCore/ platform/ geoclue2/ GeolocationProv iderGeoclue2Cli ent.h:31 iderGeoclue2Cli ent { hanged( int timestamp, double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy) = 0; rred(const char* message) = 0;
> +class GeolocationProv
> +public:
> + virtual void notifyPositionC
> + virtual void notifyErrorOccu
> +};
Why are we duplicating this? Can't we use the same provider client for both geoclue 1 and 2? This looks exactly the same that GeolocationProv iderGeoclueClie nt.h
> Source/ WebKit/ gtk/WebCoreSupp ort/Geolocation ClientGtk. h:46 GEOCLUE_ API_VERSION_ 2) iderGeoclueClie nt GeolocationProv iderClient; iderGeoclue2Cli ent GeolocationProv iderClient;
> +#if !defined(
> +typedef GeolocationProv
> +#else
> +typedef GeolocationProv
> +#endif
I guess we don't need this, if we use the same client, because it's the same in the end, no?
> Source/ WebKit/ gtk/WebCoreSupp ort/Geolocation ClientGtk. h:76 GEOCLUE_ API_VERSION_ 2) :GeolocationPro viderGeoclue2 m_provider; :GeolocationPro viderGeoclue m_provider;
> +#if defined(
> + WebCore:
> +#else
> WebCore:
> +#endif
Since we are compiling one or the other, and the api is the same, why not using the same name and we don't need more #ifdefs here?