| 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/bind.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_utils.h" | 17 #include "content/browser/service_worker/service_worker_utils.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 44 : BrowserMessageFilter(kFilteredMessageClasses, | 45 : BrowserMessageFilter(kFilteredMessageClasses, |
| 45 arraysize(kFilteredMessageClasses)), | 46 arraysize(kFilteredMessageClasses)), |
| 46 render_process_id_(render_process_id), | 47 render_process_id_(render_process_id), |
| 47 message_port_message_filter_(message_port_message_filter) {} | 48 message_port_message_filter_(message_port_message_filter) {} |
| 48 | 49 |
| 49 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { | 50 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { |
| 50 if (context_) { | 51 if (context_) { |
| 51 context_->RemoveAllProviderHostsForProcess(render_process_id_); | 52 context_->RemoveAllProviderHostsForProcess(render_process_id_); |
| 52 context_->embedded_worker_registry()->RemoveChildProcessSender( | 53 context_->embedded_worker_registry()->RemoveChildProcessSender( |
| 53 render_process_id_); | 54 render_process_id_); |
| 55 context_->embedded_worker_registry() |
| 56 ->RemoveChildProcessNextRoutingIDCallback(render_process_id_); |
| 54 } | 57 } |
| 55 } | 58 } |
| 56 | 59 |
| 57 void ServiceWorkerDispatcherHost::Init( | 60 void ServiceWorkerDispatcherHost::Init( |
| 58 ServiceWorkerContextWrapper* context_wrapper) { | 61 ServiceWorkerContextWrapper* context_wrapper, |
| 62 const base::Callback<int(void)>& next_routing_id_callback) { |
| 59 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 63 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 60 BrowserThread::PostTask( | 64 BrowserThread::PostTask(BrowserThread::IO, |
| 61 BrowserThread::IO, FROM_HERE, | 65 FROM_HERE, |
| 62 base::Bind(&ServiceWorkerDispatcherHost::Init, | 66 base::Bind(&ServiceWorkerDispatcherHost::Init, |
| 63 this, make_scoped_refptr(context_wrapper))); | 67 this, |
| 68 make_scoped_refptr(context_wrapper), |
| 69 next_routing_id_callback)); |
| 64 return; | 70 return; |
| 65 } | 71 } |
| 66 context_ = context_wrapper->context()->AsWeakPtr(); | 72 context_ = context_wrapper->context()->AsWeakPtr(); |
| 67 context_->embedded_worker_registry()->AddChildProcessSender( | 73 context_->embedded_worker_registry()->AddChildProcessSender( |
| 68 render_process_id_, this); | 74 render_process_id_, this); |
| 75 context_->embedded_worker_registry()->AddChildProcessNextRoutingIDCallback( |
| 76 render_process_id_, next_routing_id_callback); |
| 69 } | 77 } |
| 70 | 78 |
| 71 void ServiceWorkerDispatcherHost::OnDestruct() const { | 79 void ServiceWorkerDispatcherHost::OnDestruct() const { |
| 72 BrowserThread::DeleteOnIOThread::Destruct(this); | 80 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 73 } | 81 } |
| 74 | 82 |
| 75 bool ServiceWorkerDispatcherHost::OnMessageReceived( | 83 bool ServiceWorkerDispatcherHost::OnMessageReceived( |
| 76 const IPC::Message& message, | 84 const IPC::Message& message, |
| 77 bool* message_was_ok) { | 85 bool* message_was_ok) { |
| 78 bool handled = true; | 86 bool handled = true; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ServiceWorkerStatusCode status) { | 384 ServiceWorkerStatusCode status) { |
| 377 base::string16 error_message; | 385 base::string16 error_message; |
| 378 blink::WebServiceWorkerError::ErrorType error_type; | 386 blink::WebServiceWorkerError::ErrorType error_type; |
| 379 GetServiceWorkerRegistrationStatusResponse( | 387 GetServiceWorkerRegistrationStatusResponse( |
| 380 status, &error_type, &error_message); | 388 status, &error_type, &error_message); |
| 381 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 389 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 382 thread_id, request_id, error_type, error_message)); | 390 thread_id, request_id, error_type, error_message)); |
| 383 } | 391 } |
| 384 | 392 |
| 385 } // namespace content | 393 } // namespace content |
| OLD | NEW |