Chromium Code Reviews| Index: Source/modules/geofencing/Geofencing.cpp |
| diff --git a/Source/modules/geofencing/Geofencing.cpp b/Source/modules/geofencing/Geofencing.cpp |
| index eeb8e6a61b66d6b5d64da0427334703b331c2451..eae86acbb887430a8a9785d893e6f285b7047aa5 100644 |
| --- a/Source/modules/geofencing/Geofencing.cpp |
| +++ b/Source/modules/geofencing/Geofencing.cpp |
| @@ -13,6 +13,7 @@ |
| #include "modules/geofencing/CircularGeofencingRegion.h" |
| #include "modules/geofencing/GeofencingError.h" |
| #include "modules/geofencing/GeofencingRegion.h" |
| +#include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebCircularGeofencingRegion.h" |
| #include "public/platform/WebGeofencingProvider.h" |
| @@ -46,7 +47,8 @@ private: |
| } // namespace |
| -Geofencing::Geofencing() |
| +Geofencing::Geofencing(ServiceWorkerRegistration* registration) |
| + : m_registration(registration) |
| { |
| } |
| @@ -58,8 +60,12 @@ ScriptPromise Geofencing::registerRegion(ScriptState* scriptState, GeofencingReg |
| RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
| ScriptPromise promise = resolver->promise(); |
| - // FIXME: somehow pass a reference to the current serviceworker to the provider. |
| - provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->webRegion(), new CallbackPromiseAdapter<void, GeofencingError>(resolver)); |
| + WebGeofencingCallbacks* callbacks = new CallbackPromiseAdapter<void, GeofencingError>(resolver); |
| + provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->webRegion(), callbacks); |
| + WebServiceWorkerRegistration* serviceworker = nullptr; |
|
Michael van Ouwerkerk
2014/10/09 10:56:27
Here and below, probably clearer to call the varia
Marijn Kruisselbrink
2014/10/09 18:10:54
Done.
|
| + if (m_registration) |
| + serviceworker = m_registration->webRegistration(); |
| + provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->webRegion(), serviceworker, callbacks); |
|
Michael van Ouwerkerk
2014/10/09 10:56:27
Why is registerRegion called twice?
Marijn Kruisselbrink
2014/10/09 18:10:54
Because I can't update blink and chromium in the s
|
| return promise; |
| } |
| @@ -71,8 +77,12 @@ ScriptPromise Geofencing::unregisterRegion(ScriptState* scriptState, const Strin |
| RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
| ScriptPromise promise = resolver->promise(); |
| - // FIXME: somehow pass a reference to the current serviceworker to the provider. |
| - provider->unregisterRegion(regionId, new CallbackPromiseAdapter<void, GeofencingError>(resolver)); |
| + WebGeofencingCallbacks* callbacks = new CallbackPromiseAdapter<void, GeofencingError>(resolver); |
| + provider->unregisterRegion(regionId, callbacks); |
| + WebServiceWorkerRegistration* serviceworker = nullptr; |
| + if (m_registration) |
| + serviceworker = m_registration->webRegistration(); |
| + provider->unregisterRegion(regionId, serviceworker, callbacks); |
|
Michael van Ouwerkerk
2014/10/09 10:56:27
Why is unregisterRegion called twice?
Marijn Kruisselbrink
2014/10/09 18:10:54
Same as for registerRegion.
|
| return promise; |
| } |
| @@ -84,9 +94,18 @@ ScriptPromise Geofencing::getRegisteredRegions(ScriptState* scriptState) const |
| RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
| ScriptPromise promise = resolver->promise(); |
| - // FIXME: somehow pass a reference to the current serviceworker to the provider. |
| - provider->getRegisteredRegions(new CallbackPromiseAdapter<RegionArray, GeofencingError>(resolver)); |
| + WebGeofencingRegionsCallbacks* callbacks = new CallbackPromiseAdapter<RegionArray, GeofencingError>(resolver); |
| + provider->getRegisteredRegions(callbacks); |
| + WebServiceWorkerRegistration* serviceworker = nullptr; |
| + if (m_registration) |
| + serviceworker = m_registration->webRegistration(); |
| + provider->getRegisteredRegions(serviceworker, callbacks); |
|
Michael van Ouwerkerk
2014/10/09 10:56:27
Why is getRegisteredRegions called twice?
Marijn Kruisselbrink
2014/10/09 18:10:54
Same as for registerRegion.
|
| return promise; |
| } |
| +void Geofencing::trace(Visitor* visitor) |
| +{ |
| + visitor->trace(m_registration); |
| +} |
| + |
| } // namespace blink |