Index: content/browser/service_worker/service_worker_dispatcher_host.cc |
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc |
index c531e915e888504b1396aa27dab35bf4db51b7a3..42c7165b9ea0b7b6fc65d963500f2a7533eddb66 100644 |
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc |
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc |
@@ -12,14 +12,14 @@ |
namespace content { |
ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( |
+ int render_process_id, |
ServiceWorkerContext* context) |
- : context_(context) {} |
+ : render_process_id_(render_process_id), context_(context) {} |
ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {} |
bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message, |
bool* message_was_ok) { |
- |
if (IPC_MESSAGE_CLASS(message) != ServiceWorkerMsgStart) |
return false; |
@@ -36,15 +36,41 @@ bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message, |
return handled; |
} |
-void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(int32 registry_id, |
- const string16& scope, |
- const GURL& script_url) { |
- // TODO(alecflett): Enforce that script_url must have the same |
- // origin as the registering document. |
+// TODO(alecflett): Store the service_worker_id keyed by (domain+pattern, |
+// script) so we don't always return a new service worker id. |
+static int64 NextWorkerId() { |
+ static int64 service_worker_id = 0; |
+ return service_worker_id++; |
+} |
+ |
+void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
+ int32 thread_id, |
+ int32 request_id, |
+ const GURL& scope, |
+ const GURL& script_url) { |
+ // We're using cookie access as a proxy for ServiceWorker |
+ // registration permission. |
michaeln
2013/10/24 21:57:39
stray comment is n/a anymore, at least not yet?
alecflett
2013/10/24 22:41:22
Done.
|
+ |
+ // TODO(alecflett): add a ServiceWorker-specific policy query in |
+ // ChildProcessSecurityImpl. |
+ |
+ // TODO(alecflett): Throw an error for origin mismatch, rather than |
+ // just returning. |
+ if (scope.GetOrigin() != script_url.GetOrigin()) |
+ return; |
+ |
+ Send(new ServiceWorkerMsg_ServiceWorkerRegistered( |
+ thread_id, request_id, NextWorkerId())); |
} |
-void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( |
- int32 registry_id, |
- const string16& scope) {} |
+void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id, |
+ int32 request_id, |
+ const GURL& scope) { |
+ // TODO(alecflett): add a ServiceWorker-specific policy query in |
+ // ChildProcessSecurityImpl. |
+ |
+ Send(new ServiceWorkerMsg_ServiceWorkerUnregistered( |
+ thread_id, request_id)); |
+} |
} // namespace content |