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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 118103002: Add IPC stubs between browser and ServiceWorker's worker context in the child process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 11 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 "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/service_worker/embedded_worker_registry.h" 8 #include "content/browser/service_worker/embedded_worker_registry.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 render_process_id_, this); 54 render_process_id_, this);
55 } 55 }
56 56
57 void ServiceWorkerDispatcherHost::OnDestruct() const { 57 void ServiceWorkerDispatcherHost::OnDestruct() const {
58 BrowserThread::DeleteOnIOThread::Destruct(this); 58 BrowserThread::DeleteOnIOThread::Destruct(this);
59 } 59 }
60 60
61 bool ServiceWorkerDispatcherHost::OnMessageReceived( 61 bool ServiceWorkerDispatcherHost::OnMessageReceived(
62 const IPC::Message& message, 62 const IPC::Message& message,
63 bool* message_was_ok) { 63 bool* message_was_ok) {
64 if (IPC_MESSAGE_CLASS(message) != ServiceWorkerMsgStart)
65 return false;
66
67 bool handled = true; 64 bool handled = true;
68 IPC_BEGIN_MESSAGE_MAP_EX( 65 IPC_BEGIN_MESSAGE_MAP_EX(
69 ServiceWorkerDispatcherHost, message, *message_was_ok) 66 ServiceWorkerDispatcherHost, message, *message_was_ok)
70 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterServiceWorker, 67 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterServiceWorker,
71 OnRegisterServiceWorker) 68 OnRegisterServiceWorker)
72 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker, 69 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker,
73 OnUnregisterServiceWorker) 70 OnUnregisterServiceWorker)
74 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderCreated, 71 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderCreated,
75 OnProviderCreated) 72 OnProviderCreated)
76 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed, 73 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed,
77 OnProviderDestroyed) 74 OnProviderDestroyed)
75 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted,
76 OnWorkerStarted)
77 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped,
78 OnWorkerStopped)
78 IPC_MESSAGE_UNHANDLED(handled = false) 79 IPC_MESSAGE_UNHANDLED(handled = false)
79 IPC_END_MESSAGE_MAP() 80 IPC_END_MESSAGE_MAP()
80 81
81 return handled; 82 return handled;
82 } 83 }
83 84
84 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( 85 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
85 int32 thread_id, 86 int32 thread_id,
86 int32 request_id, 87 int32 request_id,
87 const GURL& pattern, 88 const GURL& pattern,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 int64 registration_id) { 170 int64 registration_id) {
170 if (status != REGISTRATION_OK) { 171 if (status != REGISTRATION_OK) {
171 SendRegistrationError(thread_id, request_id, status); 172 SendRegistrationError(thread_id, request_id, status);
172 return; 173 return;
173 } 174 }
174 175
175 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( 176 Send(new ServiceWorkerMsg_ServiceWorkerRegistered(
176 thread_id, request_id, registration_id)); 177 thread_id, request_id, registration_id));
177 } 178 }
178 179
180 void ServiceWorkerDispatcherHost::OnWorkerStarted(
181 int thread_id, int embedded_worker_id) {
182 if (!context_)
183 return;
184 context_->embedded_worker_registry()->OnWorkerStarted(
185 render_process_id_, thread_id, embedded_worker_id);
186 }
187
188 void ServiceWorkerDispatcherHost::OnWorkerStopped(int embedded_worker_id) {
189 if (!context_)
190 return;
191 context_->embedded_worker_registry()->OnWorkerStopped(
192 render_process_id_, embedded_worker_id);
193 }
194
179 void ServiceWorkerDispatcherHost::UnregistrationComplete( 195 void ServiceWorkerDispatcherHost::UnregistrationComplete(
180 int32 thread_id, 196 int32 thread_id,
181 int32 request_id, 197 int32 request_id,
182 ServiceWorkerRegistrationStatus status) { 198 ServiceWorkerRegistrationStatus status) {
183 if (status != REGISTRATION_OK) { 199 if (status != REGISTRATION_OK) {
184 SendRegistrationError(thread_id, request_id, status); 200 SendRegistrationError(thread_id, request_id, status);
185 return; 201 return;
186 } 202 }
187 203
188 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); 204 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id));
189 } 205 }
190 206
191 void ServiceWorkerDispatcherHost::SendRegistrationError( 207 void ServiceWorkerDispatcherHost::SendRegistrationError(
192 int32 thread_id, 208 int32 thread_id,
193 int32 request_id, 209 int32 request_id,
194 ServiceWorkerRegistrationStatus status) { 210 ServiceWorkerRegistrationStatus status) {
195 base::string16 error_message; 211 base::string16 error_message;
196 blink::WebServiceWorkerError::ErrorType error_type; 212 blink::WebServiceWorkerError::ErrorType error_type;
197 GetServiceWorkerRegistrationStatusResponse( 213 GetServiceWorkerRegistrationStatusResponse(
198 status, &error_type, &error_message); 214 status, &error_type, &error_message);
199 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 215 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
200 thread_id, request_id, error_type, error_message)); 216 thread_id, request_id, error_type, error_message));
201 } 217 }
202 218
203 } // namespace content 219 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_dispatcher_host.h ('k') | content/common/service_worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698