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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 25008006: Flush out initial [un]registerServiceWorker roundtrip (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 7 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
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..a60f8bb3e936befb84b226ca651ac1e316f8ea87 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,38 @@ 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::OnUnregisterServiceWorker(
- int32 registry_id,
- const string16& scope) {}
+void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
+ int32 thread_id,
+ int32 request_id,
+ const GURL& scope,
+ const GURL& script_url) {
+ // TODO(alecflett): add a ServiceWorker-specific policy query in
+ // ChildProcessSecurityImpl. See http://crbug.com/311631.
+
+ // 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 thread_id,
+ int32 request_id,
+ const GURL& scope) {
+ // TODO(alecflett): add a ServiceWorker-specific policy query in
+ // ChildProcessSecurityImpl. See http://crbug.com/311631.
+
+ Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(
+ thread_id, request_id));
+}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698