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

Unified Diff: Source/modules/geofencing/Geofencing.cpp

Issue 623813002: Blink side of exposing the service worker registration associated with geofencing API calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: hopefully correctly fix compile Created 6 years, 2 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
« no previous file with comments | « Source/modules/geofencing/Geofencing.h ('k') | Source/modules/geofencing/NavigatorGeofencing.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/geofencing/Geofencing.cpp
diff --git a/Source/modules/geofencing/Geofencing.cpp b/Source/modules/geofencing/Geofencing.cpp
index eeb8e6a61b66d6b5d64da0427334703b331c2451..633798e1e5739f9baa3212298f4efbde635468e4 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,13 @@ 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);
+ // FIXME: remove this call once chromium is updated to implement the other registerRegion.
+ provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->webRegion(), callbacks);
+ WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr;
+ if (m_registration)
+ serviceWorkerRegistration = m_registration->webRegistration();
+ provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->webRegion(), serviceWorkerRegistration, callbacks);
return promise;
}
@@ -71,8 +78,13 @@ 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);
+ // FIXME: remove this call once chromium is updated to implement the other unregisterRegion.
+ provider->unregisterRegion(regionId, callbacks);
+ WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr;
+ if (m_registration)
+ serviceWorkerRegistration = m_registration->webRegistration();
+ provider->unregisterRegion(regionId, serviceWorkerRegistration, callbacks);
return promise;
}
@@ -84,9 +96,19 @@ 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);
+ // FIXME: remove this call once chromium is updated to implement the other getRegisteredRegions.
+ provider->getRegisteredRegions(callbacks);
+ WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr;
+ if (m_registration)
+ serviceWorkerRegistration = m_registration->webRegistration();
+ provider->getRegisteredRegions(serviceWorkerRegistration, callbacks);
return promise;
}
+void Geofencing::trace(Visitor* visitor)
+{
+ visitor->trace(m_registration);
+}
+
} // namespace blink
« no previous file with comments | « Source/modules/geofencing/Geofencing.h ('k') | Source/modules/geofencing/NavigatorGeofencing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698