OLD | NEW |
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/debug/trace_event.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "content/browser/message_port_message_filter.h" | 10 #include "content/browser/message_port_message_filter.h" |
10 #include "content/browser/message_port_service.h" | 11 #include "content/browser/message_port_service.h" |
11 #include "content/browser/service_worker/embedded_worker_registry.h" | 12 #include "content/browser/service_worker/embedded_worker_registry.h" |
12 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
14 #include "content/browser/service_worker/service_worker_handle.h" | 15 #include "content/browser/service_worker/service_worker_handle.h" |
15 #include "content/browser/service_worker/service_worker_registration.h" | 16 #include "content/browser/service_worker/service_worker_registration.h" |
16 #include "content/browser/service_worker/service_worker_registration_handle.h" | 17 #include "content/browser/service_worker/service_worker_registration_handle.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 base::Bind(&ServiceWorkerDispatcherHost::Init, | 83 base::Bind(&ServiceWorkerDispatcherHost::Init, |
83 this, make_scoped_refptr(context_wrapper))); | 84 this, make_scoped_refptr(context_wrapper))); |
84 return; | 85 return; |
85 } | 86 } |
86 context_wrapper_ = context_wrapper; | 87 context_wrapper_ = context_wrapper; |
87 GetContext()->embedded_worker_registry()->AddChildProcessSender( | 88 GetContext()->embedded_worker_registry()->AddChildProcessSender( |
88 render_process_id_, this); | 89 render_process_id_, this); |
89 } | 90 } |
90 | 91 |
91 void ServiceWorkerDispatcherHost::OnFilterAdded(IPC::Sender* sender) { | 92 void ServiceWorkerDispatcherHost::OnFilterAdded(IPC::Sender* sender) { |
| 93 TRACE_EVENT0("ServiceWorker", |
| 94 "ServiceWorkerDispatcherHost::OnFilterAdded"); |
92 BrowserMessageFilter::OnFilterAdded(sender); | 95 BrowserMessageFilter::OnFilterAdded(sender); |
93 channel_ready_ = true; | 96 channel_ready_ = true; |
94 std::vector<IPC::Message*> messages; | 97 std::vector<IPC::Message*> messages; |
95 pending_messages_.release(&messages); | 98 pending_messages_.release(&messages); |
96 for (size_t i = 0; i < messages.size(); ++i) { | 99 for (size_t i = 0; i < messages.size(); ++i) { |
97 BrowserMessageFilter::Send(messages[i]); | 100 BrowserMessageFilter::Send(messages[i]); |
98 } | 101 } |
99 } | 102 } |
100 | 103 |
101 void ServiceWorkerDispatcherHost::OnDestruct() const { | 104 void ServiceWorkerDispatcherHost::OnDestruct() const { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 int handle_id = handle->handle_id(); | 180 int handle_id = handle->handle_id(); |
178 registration_handles_.AddWithID(handle.release(), handle_id); | 181 registration_handles_.AddWithID(handle.release(), handle_id); |
179 } | 182 } |
180 | 183 |
181 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( | 184 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
182 int thread_id, | 185 int thread_id, |
183 int request_id, | 186 int request_id, |
184 int provider_id, | 187 int provider_id, |
185 const GURL& pattern, | 188 const GURL& pattern, |
186 const GURL& script_url) { | 189 const GURL& script_url) { |
| 190 TRACE_EVENT0("ServiceWorker", |
| 191 "ServiceWorkerDispatcherHost::OnRegisterServiceWorker"); |
187 if (!GetContext()) { | 192 if (!GetContext()) { |
188 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 193 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
189 thread_id, | 194 thread_id, |
190 request_id, | 195 request_id, |
191 WebServiceWorkerError::ErrorTypeAbort, | 196 WebServiceWorkerError::ErrorTypeAbort, |
192 base::ASCIIToUTF16(kShutdownErrorMessage))); | 197 base::ASCIIToUTF16(kShutdownErrorMessage))); |
193 return; | 198 return; |
194 } | 199 } |
195 | 200 |
196 ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost( | 201 ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost( |
197 render_process_id_, provider_id); | 202 render_process_id_, provider_id); |
198 if (!provider_host) { | 203 if (!provider_host) { |
199 BadMessageReceived(); | 204 BadMessageReceived(); |
200 return; | 205 return; |
201 } | 206 } |
202 if (!provider_host->IsContextAlive()) { | 207 if (!provider_host->IsContextAlive()) { |
203 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 208 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
204 thread_id, | 209 thread_id, |
205 request_id, | 210 request_id, |
206 WebServiceWorkerError::ErrorTypeAbort, | 211 WebServiceWorkerError::ErrorTypeAbort, |
207 base::ASCIIToUTF16(kShutdownErrorMessage))); | 212 base::ASCIIToUTF16(kShutdownErrorMessage))); |
208 return; | 213 return; |
209 } | 214 } |
210 | 215 |
211 if (!CanRegisterServiceWorker( | 216 if (!CanRegisterServiceWorker( |
212 provider_host->document_url(), pattern, script_url)) { | 217 provider_host->document_url(), pattern, script_url)) { |
213 BadMessageReceived(); | 218 BadMessageReceived(); |
214 return; | 219 return; |
215 } | 220 } |
| 221 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", |
| 222 "ServiceWorkerDispatcherHost::RegisterServiceWorker", |
| 223 request_id, |
| 224 "Pattern", pattern.spec(), |
| 225 "Script URL", script_url.spec()); |
216 GetContext()->RegisterServiceWorker( | 226 GetContext()->RegisterServiceWorker( |
217 pattern, | 227 pattern, |
218 script_url, | 228 script_url, |
219 render_process_id_, | 229 render_process_id_, |
220 provider_host, | 230 provider_host, |
221 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, | 231 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, |
222 this, | 232 this, |
223 thread_id, | 233 thread_id, |
224 provider_id, | 234 provider_id, |
225 request_id)); | 235 request_id)); |
226 } | 236 } |
227 | 237 |
228 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( | 238 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( |
229 int thread_id, | 239 int thread_id, |
230 int request_id, | 240 int request_id, |
231 int provider_id, | 241 int provider_id, |
232 const GURL& pattern) { | 242 const GURL& pattern) { |
| 243 TRACE_EVENT0("ServiceWorker", |
| 244 "ServiceWorkerDispatcherHost::OnUnregisterServiceWorker"); |
233 if (!GetContext()) { | 245 if (!GetContext()) { |
234 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 246 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
235 thread_id, | 247 thread_id, |
236 request_id, | 248 request_id, |
237 blink::WebServiceWorkerError::ErrorTypeAbort, | 249 blink::WebServiceWorkerError::ErrorTypeAbort, |
238 base::ASCIIToUTF16(kShutdownErrorMessage))); | 250 base::ASCIIToUTF16(kShutdownErrorMessage))); |
239 return; | 251 return; |
240 } | 252 } |
241 | 253 |
242 ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost( | 254 ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost( |
243 render_process_id_, provider_id); | 255 render_process_id_, provider_id); |
244 if (!provider_host) { | 256 if (!provider_host) { |
245 BadMessageReceived(); | 257 BadMessageReceived(); |
246 return; | 258 return; |
247 } | 259 } |
248 if (!provider_host->IsContextAlive()) { | 260 if (!provider_host->IsContextAlive()) { |
249 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 261 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
250 thread_id, | 262 thread_id, |
251 request_id, | 263 request_id, |
252 blink::WebServiceWorkerError::ErrorTypeAbort, | 264 blink::WebServiceWorkerError::ErrorTypeAbort, |
253 base::ASCIIToUTF16(kShutdownErrorMessage))); | 265 base::ASCIIToUTF16(kShutdownErrorMessage))); |
254 return; | 266 return; |
255 } | 267 } |
256 | 268 |
257 if (!CanUnregisterServiceWorker(provider_host->document_url(), pattern)) { | 269 if (!CanUnregisterServiceWorker(provider_host->document_url(), pattern)) { |
258 BadMessageReceived(); | 270 BadMessageReceived(); |
259 return; | 271 return; |
260 } | 272 } |
261 | 273 |
| 274 TRACE_EVENT_ASYNC_BEGIN1( |
| 275 "ServiceWorker", |
| 276 "ServiceWorkerDispatcherHost::UnregisterServiceWorker", |
| 277 request_id, |
| 278 "Pattern", pattern.spec()); |
262 GetContext()->UnregisterServiceWorker( | 279 GetContext()->UnregisterServiceWorker( |
263 pattern, | 280 pattern, |
264 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, | 281 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, |
265 this, | 282 this, |
266 thread_id, | 283 thread_id, |
267 request_id)); | 284 request_id)); |
268 } | 285 } |
269 | 286 |
270 void ServiceWorkerDispatcherHost::OnPostMessageToWorker( | 287 void ServiceWorkerDispatcherHost::OnPostMessageToWorker( |
271 int handle_id, | 288 int handle_id, |
272 const base::string16& message, | 289 const base::string16& message, |
273 const std::vector<int>& sent_message_port_ids) { | 290 const std::vector<int>& sent_message_port_ids) { |
| 291 TRACE_EVENT0("ServiceWorker", |
| 292 "ServiceWorkerDispatcherHost::OnPostMessageToWorker"); |
274 if (!GetContext()) | 293 if (!GetContext()) |
275 return; | 294 return; |
276 | 295 |
277 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); | 296 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); |
278 if (!handle) { | 297 if (!handle) { |
279 BadMessageReceived(); | 298 BadMessageReceived(); |
280 return; | 299 return; |
281 } | 300 } |
282 | 301 |
283 std::vector<int> new_routing_ids; | 302 std::vector<int> new_routing_ids; |
284 message_port_message_filter_->UpdateMessagePortsWithNewRoutes( | 303 message_port_message_filter_->UpdateMessagePortsWithNewRoutes( |
285 sent_message_port_ids, &new_routing_ids); | 304 sent_message_port_ids, &new_routing_ids); |
286 handle->version()->SendMessage( | 305 handle->version()->SendMessage( |
287 ServiceWorkerMsg_MessageToWorker(message, | 306 ServiceWorkerMsg_MessageToWorker(message, |
288 sent_message_port_ids, | 307 sent_message_port_ids, |
289 new_routing_ids), | 308 new_routing_ids), |
290 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 309 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
291 } | 310 } |
292 | 311 |
293 void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) { | 312 void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) { |
| 313 TRACE_EVENT0("ServiceWorker", |
| 314 "ServiceWorkerDispatcherHost::OnProviderCreated"); |
294 if (!GetContext()) | 315 if (!GetContext()) |
295 return; | 316 return; |
296 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 317 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
297 BadMessageReceived(); | 318 BadMessageReceived(); |
298 return; | 319 return; |
299 } | 320 } |
300 scoped_ptr<ServiceWorkerProviderHost> provider_host( | 321 scoped_ptr<ServiceWorkerProviderHost> provider_host( |
301 new ServiceWorkerProviderHost( | 322 new ServiceWorkerProviderHost( |
302 render_process_id_, provider_id, GetContext()->AsWeakPtr(), this)); | 323 render_process_id_, provider_id, GetContext()->AsWeakPtr(), this)); |
303 GetContext()->AddProviderHost(provider_host.Pass()); | 324 GetContext()->AddProviderHost(provider_host.Pass()); |
304 } | 325 } |
305 | 326 |
306 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 327 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
| 328 TRACE_EVENT0("ServiceWorker", |
| 329 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
307 if (!GetContext()) | 330 if (!GetContext()) |
308 return; | 331 return; |
309 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 332 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
310 BadMessageReceived(); | 333 BadMessageReceived(); |
311 return; | 334 return; |
312 } | 335 } |
313 GetContext()->RemoveProviderHost(render_process_id_, provider_id); | 336 GetContext()->RemoveProviderHost(render_process_id_, provider_id); |
314 } | 337 } |
315 | 338 |
316 void ServiceWorkerDispatcherHost::OnSetHostedVersionId( | 339 void ServiceWorkerDispatcherHost::OnSetHostedVersionId( |
317 int provider_id, int64 version_id) { | 340 int provider_id, int64 version_id) { |
| 341 TRACE_EVENT0("ServiceWorker", |
| 342 "ServiceWorkerDispatcherHost::OnSetHostedVersionId"); |
318 if (!GetContext()) | 343 if (!GetContext()) |
319 return; | 344 return; |
320 ServiceWorkerProviderHost* provider_host = | 345 ServiceWorkerProviderHost* provider_host = |
321 GetContext()->GetProviderHost(render_process_id_, provider_id); | 346 GetContext()->GetProviderHost(render_process_id_, provider_id); |
322 if (!provider_host) { | 347 if (!provider_host) { |
323 BadMessageReceived(); | 348 BadMessageReceived(); |
324 return; | 349 return; |
325 } | 350 } |
326 if (!provider_host->IsContextAlive()) | 351 if (!provider_host->IsContextAlive()) |
327 return; | 352 return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 ServiceWorkerVersionAttributes attrs; | 408 ServiceWorkerVersionAttributes attrs; |
384 attrs.installing = handle->CreateServiceWorkerHandleAndPass( | 409 attrs.installing = handle->CreateServiceWorkerHandleAndPass( |
385 registration->installing_version()); | 410 registration->installing_version()); |
386 attrs.waiting = handle->CreateServiceWorkerHandleAndPass( | 411 attrs.waiting = handle->CreateServiceWorkerHandleAndPass( |
387 registration->waiting_version()); | 412 registration->waiting_version()); |
388 attrs.active = handle->CreateServiceWorkerHandleAndPass( | 413 attrs.active = handle->CreateServiceWorkerHandleAndPass( |
389 registration->active_version()); | 414 registration->active_version()); |
390 | 415 |
391 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( | 416 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( |
392 thread_id, request_id, info, attrs)); | 417 thread_id, request_id, info, attrs)); |
| 418 TRACE_EVENT_ASYNC_END2("ServiceWorker", |
| 419 "ServiceWorkerDispatcherHost::RegisterServiceWorker", |
| 420 request_id, |
| 421 "Registration ID", registration_id, |
| 422 "Version ID", version_id); |
393 } | 423 } |
394 | 424 |
395 void ServiceWorkerDispatcherHost::OnWorkerReadyForInspection( | 425 void ServiceWorkerDispatcherHost::OnWorkerReadyForInspection( |
396 int embedded_worker_id) { | 426 int embedded_worker_id) { |
| 427 TRACE_EVENT0("ServiceWorker", |
| 428 "ServiceWorkerDispatcherHost::OnWorkerReadyForInspection"); |
397 if (!GetContext()) | 429 if (!GetContext()) |
398 return; | 430 return; |
399 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 431 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
400 if (!registry->CanHandle(embedded_worker_id)) | 432 if (!registry->CanHandle(embedded_worker_id)) |
401 return; | 433 return; |
402 registry->OnWorkerReadyForInspection(render_process_id_, embedded_worker_id); | 434 registry->OnWorkerReadyForInspection(render_process_id_, embedded_worker_id); |
403 } | 435 } |
404 | 436 |
405 void ServiceWorkerDispatcherHost::OnWorkerScriptLoaded( | 437 void ServiceWorkerDispatcherHost::OnWorkerScriptLoaded( |
406 int embedded_worker_id, | 438 int embedded_worker_id, |
407 int thread_id) { | 439 int thread_id) { |
| 440 TRACE_EVENT0("ServiceWorker", |
| 441 "ServiceWorkerDispatcherHost::OnWorkerScriptLoaded"); |
408 if (!GetContext()) | 442 if (!GetContext()) |
409 return; | 443 return; |
410 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 444 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
411 if (!registry->CanHandle(embedded_worker_id)) | 445 if (!registry->CanHandle(embedded_worker_id)) |
412 return; | 446 return; |
413 registry->OnWorkerScriptLoaded( | 447 registry->OnWorkerScriptLoaded( |
414 render_process_id_, thread_id, embedded_worker_id); | 448 render_process_id_, thread_id, embedded_worker_id); |
415 } | 449 } |
416 | 450 |
417 void ServiceWorkerDispatcherHost::OnWorkerScriptLoadFailed( | 451 void ServiceWorkerDispatcherHost::OnWorkerScriptLoadFailed( |
418 int embedded_worker_id) { | 452 int embedded_worker_id) { |
| 453 TRACE_EVENT0("ServiceWorker", |
| 454 "ServiceWorkerDispatcherHost::OnWorkerScriptLoadFailed"); |
419 if (!GetContext()) | 455 if (!GetContext()) |
420 return; | 456 return; |
421 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 457 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
422 if (!registry->CanHandle(embedded_worker_id)) | 458 if (!registry->CanHandle(embedded_worker_id)) |
423 return; | 459 return; |
424 registry->OnWorkerScriptLoadFailed(render_process_id_, embedded_worker_id); | 460 registry->OnWorkerScriptLoadFailed(render_process_id_, embedded_worker_id); |
425 } | 461 } |
426 | 462 |
427 void ServiceWorkerDispatcherHost::OnWorkerStarted(int embedded_worker_id) { | 463 void ServiceWorkerDispatcherHost::OnWorkerStarted(int embedded_worker_id) { |
| 464 TRACE_EVENT0("ServiceWorker", |
| 465 "ServiceWorkerDispatcherHost::OnWorkerStarted"); |
428 if (!GetContext()) | 466 if (!GetContext()) |
429 return; | 467 return; |
430 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 468 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
431 if (!registry->CanHandle(embedded_worker_id)) | 469 if (!registry->CanHandle(embedded_worker_id)) |
432 return; | 470 return; |
433 registry->OnWorkerStarted(render_process_id_, embedded_worker_id); | 471 registry->OnWorkerStarted(render_process_id_, embedded_worker_id); |
434 } | 472 } |
435 | 473 |
436 void ServiceWorkerDispatcherHost::OnWorkerStopped(int embedded_worker_id) { | 474 void ServiceWorkerDispatcherHost::OnWorkerStopped(int embedded_worker_id) { |
| 475 TRACE_EVENT0("ServiceWorker", |
| 476 "ServiceWorkerDispatcherHost::OnWorkerStopped"); |
437 if (!GetContext()) | 477 if (!GetContext()) |
438 return; | 478 return; |
439 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 479 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
440 if (!registry->CanHandle(embedded_worker_id)) | 480 if (!registry->CanHandle(embedded_worker_id)) |
441 return; | 481 return; |
442 registry->OnWorkerStopped(render_process_id_, embedded_worker_id); | 482 registry->OnWorkerStopped(render_process_id_, embedded_worker_id); |
443 } | 483 } |
444 | 484 |
445 void ServiceWorkerDispatcherHost::OnPausedAfterDownload( | 485 void ServiceWorkerDispatcherHost::OnPausedAfterDownload( |
446 int embedded_worker_id) { | 486 int embedded_worker_id) { |
| 487 TRACE_EVENT0("ServiceWorker", |
| 488 "ServiceWorkerDispatcherHost::OnPausedAfterDownload"); |
447 if (!GetContext()) | 489 if (!GetContext()) |
448 return; | 490 return; |
449 GetContext()->embedded_worker_registry()->OnPausedAfterDownload( | 491 GetContext()->embedded_worker_registry()->OnPausedAfterDownload( |
450 render_process_id_, embedded_worker_id); | 492 render_process_id_, embedded_worker_id); |
451 } | 493 } |
452 | 494 |
453 void ServiceWorkerDispatcherHost::OnReportException( | 495 void ServiceWorkerDispatcherHost::OnReportException( |
454 int embedded_worker_id, | 496 int embedded_worker_id, |
455 const base::string16& error_message, | 497 const base::string16& error_message, |
456 int line_number, | 498 int line_number, |
457 int column_number, | 499 int column_number, |
458 const GURL& source_url) { | 500 const GURL& source_url) { |
| 501 TRACE_EVENT0("ServiceWorker", |
| 502 "ServiceWorkerDispatcherHost::OnReportException"); |
459 if (!GetContext()) | 503 if (!GetContext()) |
460 return; | 504 return; |
461 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 505 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
462 if (!registry->CanHandle(embedded_worker_id)) | 506 if (!registry->CanHandle(embedded_worker_id)) |
463 return; | 507 return; |
464 registry->OnReportException(embedded_worker_id, | 508 registry->OnReportException(embedded_worker_id, |
465 error_message, | 509 error_message, |
466 line_number, | 510 line_number, |
467 column_number, | 511 column_number, |
468 source_url); | 512 source_url); |
469 } | 513 } |
470 | 514 |
471 void ServiceWorkerDispatcherHost::OnReportConsoleMessage( | 515 void ServiceWorkerDispatcherHost::OnReportConsoleMessage( |
472 int embedded_worker_id, | 516 int embedded_worker_id, |
473 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params) { | 517 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params) { |
| 518 TRACE_EVENT0("ServiceWorker", |
| 519 "ServiceWorkerDispatcherHost::OnReportConsoleMessage"); |
474 if (!GetContext()) | 520 if (!GetContext()) |
475 return; | 521 return; |
476 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 522 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
477 if (!registry->CanHandle(embedded_worker_id)) | 523 if (!registry->CanHandle(embedded_worker_id)) |
478 return; | 524 return; |
479 registry->OnReportConsoleMessage(embedded_worker_id, | 525 registry->OnReportConsoleMessage(embedded_worker_id, |
480 params.source_identifier, | 526 params.source_identifier, |
481 params.message_level, | 527 params.message_level, |
482 params.message, | 528 params.message, |
483 params.line_number, | 529 params.line_number, |
484 params.source_url); | 530 params.source_url); |
485 } | 531 } |
486 | 532 |
487 void ServiceWorkerDispatcherHost::OnIncrementServiceWorkerRefCount( | 533 void ServiceWorkerDispatcherHost::OnIncrementServiceWorkerRefCount( |
488 int handle_id) { | 534 int handle_id) { |
| 535 TRACE_EVENT0("ServiceWorker", |
| 536 "ServiceWorkerDispatcherHost::OnIncrementServiceWorkerRefCount"); |
489 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); | 537 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); |
490 if (!handle) { | 538 if (!handle) { |
491 BadMessageReceived(); | 539 BadMessageReceived(); |
492 return; | 540 return; |
493 } | 541 } |
494 handle->IncrementRefCount(); | 542 handle->IncrementRefCount(); |
495 } | 543 } |
496 | 544 |
497 void ServiceWorkerDispatcherHost::OnDecrementServiceWorkerRefCount( | 545 void ServiceWorkerDispatcherHost::OnDecrementServiceWorkerRefCount( |
498 int handle_id) { | 546 int handle_id) { |
| 547 TRACE_EVENT0("ServiceWorker", |
| 548 "ServiceWorkerDispatcherHost::OnDecrementServiceWorkerRefCount"); |
499 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); | 549 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); |
500 if (!handle) { | 550 if (!handle) { |
501 BadMessageReceived(); | 551 BadMessageReceived(); |
502 return; | 552 return; |
503 } | 553 } |
504 handle->DecrementRefCount(); | 554 handle->DecrementRefCount(); |
505 if (handle->HasNoRefCount()) | 555 if (handle->HasNoRefCount()) |
506 handles_.Remove(handle_id); | 556 handles_.Remove(handle_id); |
507 } | 557 } |
508 | 558 |
509 void ServiceWorkerDispatcherHost::OnIncrementRegistrationRefCount( | 559 void ServiceWorkerDispatcherHost::OnIncrementRegistrationRefCount( |
510 int registration_handle_id) { | 560 int registration_handle_id) { |
| 561 TRACE_EVENT0("ServiceWorker", |
| 562 "ServiceWorkerDispatcherHost::OnIncrementRegistrationRefCount"); |
511 ServiceWorkerRegistrationHandle* handle = | 563 ServiceWorkerRegistrationHandle* handle = |
512 registration_handles_.Lookup(registration_handle_id); | 564 registration_handles_.Lookup(registration_handle_id); |
513 if (!handle) { | 565 if (!handle) { |
514 BadMessageReceived(); | 566 BadMessageReceived(); |
515 return; | 567 return; |
516 } | 568 } |
517 handle->IncrementRefCount(); | 569 handle->IncrementRefCount(); |
518 } | 570 } |
519 | 571 |
520 void ServiceWorkerDispatcherHost::OnDecrementRegistrationRefCount( | 572 void ServiceWorkerDispatcherHost::OnDecrementRegistrationRefCount( |
521 int registration_handle_id) { | 573 int registration_handle_id) { |
| 574 TRACE_EVENT0("ServiceWorker", |
| 575 "ServiceWorkerDispatcherHost::OnDecrementRegistrationRefCount"); |
522 ServiceWorkerRegistrationHandle* handle = | 576 ServiceWorkerRegistrationHandle* handle = |
523 registration_handles_.Lookup(registration_handle_id); | 577 registration_handles_.Lookup(registration_handle_id); |
524 if (!handle) { | 578 if (!handle) { |
525 BadMessageReceived(); | 579 BadMessageReceived(); |
526 return; | 580 return; |
527 } | 581 } |
528 handle->DecrementRefCount(); | 582 handle->DecrementRefCount(); |
529 if (handle->HasNoRefCount()) | 583 if (handle->HasNoRefCount()) |
530 registration_handles_.Remove(registration_handle_id); | 584 registration_handles_.Remove(registration_handle_id); |
531 } | 585 } |
532 | 586 |
533 void ServiceWorkerDispatcherHost::UnregistrationComplete( | 587 void ServiceWorkerDispatcherHost::UnregistrationComplete( |
534 int thread_id, | 588 int thread_id, |
535 int request_id, | 589 int request_id, |
536 ServiceWorkerStatusCode status) { | 590 ServiceWorkerStatusCode status) { |
537 if (status != SERVICE_WORKER_OK) { | 591 if (status != SERVICE_WORKER_OK) { |
538 SendUnregistrationError(thread_id, request_id, status); | 592 SendUnregistrationError(thread_id, request_id, status); |
539 return; | 593 return; |
540 } | 594 } |
541 | 595 |
542 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); | 596 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); |
| 597 TRACE_EVENT_ASYNC_END1( |
| 598 "ServiceWorker", |
| 599 "ServiceWorkerDispatcherHost::UnregisterServiceWorker", |
| 600 request_id, |
| 601 "Status", status); |
543 } | 602 } |
544 | 603 |
545 void ServiceWorkerDispatcherHost::SendRegistrationError( | 604 void ServiceWorkerDispatcherHost::SendRegistrationError( |
546 int thread_id, | 605 int thread_id, |
547 int request_id, | 606 int request_id, |
548 ServiceWorkerStatusCode status) { | 607 ServiceWorkerStatusCode status) { |
549 base::string16 error_message; | 608 base::string16 error_message; |
550 blink::WebServiceWorkerError::ErrorType error_type; | 609 blink::WebServiceWorkerError::ErrorType error_type; |
551 GetServiceWorkerRegistrationStatusResponse( | 610 GetServiceWorkerRegistrationStatusResponse( |
552 status, &error_type, &error_message); | 611 status, &error_type, &error_message); |
(...skipping 11 matching lines...) Expand all Loading... |
564 status, &error_type, &error_message); | 623 status, &error_type, &error_message); |
565 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 624 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
566 thread_id, request_id, error_type, error_message)); | 625 thread_id, request_id, error_type, error_message)); |
567 } | 626 } |
568 | 627 |
569 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { | 628 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { |
570 return context_wrapper_->context(); | 629 return context_wrapper_->context(); |
571 } | 630 } |
572 | 631 |
573 } // namespace content | 632 } // namespace content |
OLD | NEW |