diff options
author | mek <mek@chromium.org> | 2014-10-23 18:00:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-24 01:01:08 +0000 |
commit | a38764be36077683d9fd7e5190fbae0ce8733d4c (patch) | |
tree | 985f47c2e7d2fff62a70c76f4abe5126cc32a6db /content/child/geofencing | |
parent | 7cafb2ce64d1ac88866f6379e446688608ef596f (diff) | |
download | chromium_src-a38764be36077683d9fd7e5190fbae0ce8733d4c.zip chromium_src-a38764be36077683d9fd7e5190fbae0ce8733d4c.tar.gz chromium_src-a38764be36077683d9fd7e5190fbae0ce8733d4c.tar.bz2 |
Chrome side of passing on the service worker registration with geofencing API calls.
BUG=383125
Review URL: https://codereview.chromium.org/623823002
Cr-Commit-Position: refs/heads/master@{#301010}
Diffstat (limited to 'content/child/geofencing')
4 files changed, 70 insertions, 20 deletions
diff --git a/content/child/geofencing/geofencing_dispatcher.cc b/content/child/geofencing/geofencing_dispatcher.cc index 1b0f849..eec721f 100644 --- a/content/child/geofencing/geofencing_dispatcher.cc +++ b/content/child/geofencing/geofencing_dispatcher.cc @@ -8,9 +8,11 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/thread_task_runner_handle.h" +#include "content/child/service_worker/web_service_worker_registration_impl.h" #include "content/child/thread_safe_sender.h" #include "content/child/worker_thread_task_runner.h" #include "content/common/geofencing_messages.h" +#include "content/common/service_worker/service_worker_types.h" #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" #include "third_party/WebKit/public/platform/WebGeofencingError.h" #include "third_party/WebKit/public/platform/WebGeofencingRegistration.h" @@ -63,28 +65,60 @@ void GeofencingDispatcher::OnMessageReceived(const IPC::Message& msg) { void GeofencingDispatcher::RegisterRegion( const blink::WebString& region_id, const blink::WebCircularGeofencingRegion& region, + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingCallbacks* callbacks) { DCHECK(callbacks); int request_id = region_registration_requests_.Add(callbacks); - Send(new GeofencingHostMsg_RegisterRegion( - CurrentWorkerId(), request_id, region_id.utf8(), region)); + // TODO(mek): Immediately reject requests lacking a service worker + // registration, without bouncing through browser process. + int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; + if (service_worker_registration) { + serviceworker_registration_id = + static_cast<WebServiceWorkerRegistrationImpl*>( + service_worker_registration)->registration_id(); + } + Send(new GeofencingHostMsg_RegisterRegion(CurrentWorkerId(), + request_id, + region_id.utf8(), + region, + serviceworker_registration_id)); } void GeofencingDispatcher::UnregisterRegion( const blink::WebString& region_id, + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingCallbacks* callbacks) { DCHECK(callbacks); int request_id = region_unregistration_requests_.Add(callbacks); - Send(new GeofencingHostMsg_UnregisterRegion( - CurrentWorkerId(), request_id, region_id.utf8())); + // TODO(mek): Immediately reject requests lacking a service worker + // registration, without bouncing through browser process. + int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; + if (service_worker_registration) { + serviceworker_registration_id = + static_cast<WebServiceWorkerRegistrationImpl*>( + service_worker_registration)->registration_id(); + } + Send(new GeofencingHostMsg_UnregisterRegion(CurrentWorkerId(), + request_id, + region_id.utf8(), + serviceworker_registration_id)); } void GeofencingDispatcher::GetRegisteredRegions( + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingRegionsCallbacks* callbacks) { DCHECK(callbacks); int request_id = get_registered_regions_requests_.Add(callbacks); - Send(new GeofencingHostMsg_GetRegisteredRegions(CurrentWorkerId(), - request_id)); + // TODO(mek): Immediately reject requests lacking a service worker + // registration, without bouncing through browser process. + int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; + if (service_worker_registration) { + serviceworker_registration_id = + static_cast<WebServiceWorkerRegistrationImpl*>( + service_worker_registration)->registration_id(); + } + Send(new GeofencingHostMsg_GetRegisteredRegions( + CurrentWorkerId(), request_id, serviceworker_registration_id)); } GeofencingDispatcher* GeofencingDispatcher::GetOrCreateThreadSpecificInstance( diff --git a/content/child/geofencing/geofencing_dispatcher.h b/content/child/geofencing/geofencing_dispatcher.h index fc3988e..57a2a43 100644 --- a/content/child/geofencing/geofencing_dispatcher.h +++ b/content/child/geofencing/geofencing_dispatcher.h @@ -33,12 +33,18 @@ class GeofencingDispatcher : public WorkerTaskRunner::Observer { void OnMessageReceived(const IPC::Message& msg); // Corresponding to WebGeofencingProvider methods. - void RegisterRegion(const blink::WebString& region_id, - const blink::WebCircularGeofencingRegion& region, - blink::WebGeofencingCallbacks* callbacks); - void UnregisterRegion(const blink::WebString& region_id, - blink::WebGeofencingCallbacks* callbacks); - void GetRegisteredRegions(blink::WebGeofencingRegionsCallbacks* callbacks); + void RegisterRegion( + const blink::WebString& region_id, + const blink::WebCircularGeofencingRegion& region, + blink::WebServiceWorkerRegistration* service_worker_registration, + blink::WebGeofencingCallbacks* callbacks); + void UnregisterRegion( + const blink::WebString& region_id, + blink::WebServiceWorkerRegistration* service_worker_registration, + blink::WebGeofencingCallbacks* callbacks); + void GetRegisteredRegions( + blink::WebServiceWorkerRegistration* service_worker_registration, + blink::WebGeofencingRegionsCallbacks* callbacks); // |thread_safe_sender| needs to be passed in because if the call leads to // construction it will be needed. diff --git a/content/child/geofencing/web_geofencing_provider_impl.cc b/content/child/geofencing/web_geofencing_provider_impl.cc index d058ffe..5d78b98 100644 --- a/content/child/geofencing/web_geofencing_provider_impl.cc +++ b/content/child/geofencing/web_geofencing_provider_impl.cc @@ -20,19 +20,24 @@ WebGeofencingProviderImpl::~WebGeofencingProviderImpl() { void WebGeofencingProviderImpl::registerRegion( const blink::WebString& regionId, const blink::WebCircularGeofencingRegion& region, + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingCallbacks* callbacks) { - GetDispatcher()->RegisterRegion(regionId, region, callbacks); + GetDispatcher()->RegisterRegion( + regionId, region, service_worker_registration, callbacks); } void WebGeofencingProviderImpl::unregisterRegion( const blink::WebString& regionId, + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingCallbacks* callbacks) { - GetDispatcher()->UnregisterRegion(regionId, callbacks); + GetDispatcher()->UnregisterRegion( + regionId, service_worker_registration, callbacks); } void WebGeofencingProviderImpl::getRegisteredRegions( + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingRegionsCallbacks* callbacks) { - GetDispatcher()->GetRegisteredRegions(callbacks); + GetDispatcher()->GetRegisteredRegions(service_worker_registration, callbacks); } GeofencingDispatcher* WebGeofencingProviderImpl::GetDispatcher() { diff --git a/content/child/geofencing/web_geofencing_provider_impl.h b/content/child/geofencing/web_geofencing_provider_impl.h index a1dd744..9aac795 100644 --- a/content/child/geofencing/web_geofencing_provider_impl.h +++ b/content/child/geofencing/web_geofencing_provider_impl.h @@ -21,12 +21,17 @@ class WebGeofencingProviderImpl private: // WebGeofencingProvider implementation. - virtual void registerRegion(const blink::WebString& regionId, - const blink::WebCircularGeofencingRegion& region, - blink::WebGeofencingCallbacks* callbacks); - virtual void unregisterRegion(const blink::WebString& regionId, - blink::WebGeofencingCallbacks* callbacks); + virtual void registerRegion( + const blink::WebString& regionId, + const blink::WebCircularGeofencingRegion& region, + blink::WebServiceWorkerRegistration* service_worker_registration, + blink::WebGeofencingCallbacks* callbacks); + virtual void unregisterRegion( + const blink::WebString& regionId, + blink::WebServiceWorkerRegistration* service_worker_registration, + blink::WebGeofencingCallbacks* callbacks); virtual void getRegisteredRegions( + blink::WebServiceWorkerRegistration* service_worker_registration, blink::WebGeofencingRegionsCallbacks* callbacks); GeofencingDispatcher* GetDispatcher(); |