| 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) { |
| 59 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 62 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 60 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
| 61 BrowserThread::IO, FROM_HERE, | 64 BrowserThread::IO, FROM_HERE, |
| 62 base::Bind(&ServiceWorkerDispatcherHost::Init, | 65 base::Bind(&ServiceWorkerDispatcherHost::Init, |
| 63 this, make_scoped_refptr(context_wrapper))); | 66 this, make_scoped_refptr(context_wrapper))); |
| 64 return; | 67 return; |
| 65 } | 68 } |
| 66 context_ = context_wrapper->context()->AsWeakPtr(); | 69 context_ = context_wrapper->context()->AsWeakPtr(); |
| 67 context_->embedded_worker_registry()->AddChildProcessSender( | 70 context_->embedded_worker_registry()->AddChildProcessSender( |
| 68 render_process_id_, this); | 71 render_process_id_, this); |
| 72 context_->embedded_worker_registry()->AddChildProcessNextRoutingIDCallback( |
| 73 render_process_id_, |
| 74 base::Bind(&MessagePortMessageFilter::GetNextRoutingID, |
| 75 message_port_message_filter_)); |
| 69 } | 76 } |
| 70 | 77 |
| 71 void ServiceWorkerDispatcherHost::OnDestruct() const { | 78 void ServiceWorkerDispatcherHost::OnDestruct() const { |
| 72 BrowserThread::DeleteOnIOThread::Destruct(this); | 79 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 73 } | 80 } |
| 74 | 81 |
| 75 bool ServiceWorkerDispatcherHost::OnMessageReceived( | 82 bool ServiceWorkerDispatcherHost::OnMessageReceived( |
| 76 const IPC::Message& message, | 83 const IPC::Message& message, |
| 77 bool* message_was_ok) { | 84 bool* message_was_ok) { |
| 78 bool handled = true; | 85 bool handled = true; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ServiceWorkerStatusCode status) { | 383 ServiceWorkerStatusCode status) { |
| 377 base::string16 error_message; | 384 base::string16 error_message; |
| 378 blink::WebServiceWorkerError::ErrorType error_type; | 385 blink::WebServiceWorkerError::ErrorType error_type; |
| 379 GetServiceWorkerRegistrationStatusResponse( | 386 GetServiceWorkerRegistrationStatusResponse( |
| 380 status, &error_type, &error_message); | 387 status, &error_type, &error_message); |
| 381 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 388 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 382 thread_id, request_id, error_type, error_message)); | 389 thread_id, request_id, error_type, error_message)); |
| 383 } | 390 } |
| 384 | 391 |
| 385 } // namespace content | 392 } // namespace content |
| OLD | NEW |