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

Side by Side 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: Fix workerid 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "content/browser/service_worker/service_worker_context.h" 7 #include "content/browser/service_worker/service_worker_context.h"
8 #include "content/common/service_worker_messages.h" 8 #include "content/common/service_worker_messages.h"
9 #include "ipc/ipc_message_macros.h" 9 #include "ipc/ipc_message_macros.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( 14 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(
15 ServiceWorkerContext* context) 15 ServiceWorkerContext* context)
16 : context_(context) {} 16 : context_(context) {}
17 17
18 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {} 18 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {}
19 19
20 bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message, 20 bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message,
21 bool* message_was_ok) { 21 bool* message_was_ok) {
22
23 if (IPC_MESSAGE_CLASS(message) != ServiceWorkerMsgStart) 22 if (IPC_MESSAGE_CLASS(message) != ServiceWorkerMsgStart)
24 return false; 23 return false;
25 24
26 bool handled = true; 25 bool handled = true;
27 IPC_BEGIN_MESSAGE_MAP_EX( 26 IPC_BEGIN_MESSAGE_MAP_EX(
28 ServiceWorkerDispatcherHost, message, *message_was_ok) 27 ServiceWorkerDispatcherHost, message, *message_was_ok)
29 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterServiceWorker, 28 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterServiceWorker,
30 OnRegisterServiceWorker) 29 OnRegisterServiceWorker)
31 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker, 30 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker,
32 OnUnregisterServiceWorker) 31 OnUnregisterServiceWorker)
33 IPC_MESSAGE_UNHANDLED(handled = false) 32 IPC_MESSAGE_UNHANDLED(handled = false)
34 IPC_END_MESSAGE_MAP() 33 IPC_END_MESSAGE_MAP()
35 34
36 return handled; 35 return handled;
37 } 36 }
38 37
39 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(int32 registry_id, 38 // TODO(alecflett): Store the worker_id keyed by (domain+pattern,
40 const string16& scope, 39 // script) so we don't always return a new service worker id.
41 const GURL& script_url) { 40 static int32 NextWorkerId() {
michaeln 2013/10/04 01:26:07 i think we usually prefer 'int' where int will do
alecflett 2013/10/07 18:33:58 cpplint will warn/complain if you use native types
41 static int32 worker_id = 0;
42 return worker_id++;
43 }
44
45 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
46 int32 request_id,
47 const string16& scope,
48 const GURL& script_url) {
42 // TODO(alecflett): Enforce that script_url must have the same 49 // TODO(alecflett): Enforce that script_url must have the same
43 // origin as the registering document. 50 // origin as the registering document.
michaeln 2013/10/04 01:26:07 I'd vote to put in place scaffolding/structure tha
alecflett 2013/10/07 18:33:58 OK
51 Send(
52 new ServiceWorkerMsg_ServiceWorkerRegistered(request_id, NextWorkerId()));
44 } 53 }
45 54
46 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( 55 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(
47 int32 registry_id, 56 int32 request_id,
48 const string16& scope) {} 57 const string16& scope) {
58 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(request_id,
59 NextWorkerId()));
60 }
49 61
50 } // namespace content 62 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/child_thread.h » ('j') | content/child/service_worker/service_worker_dispatcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698