| 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 <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 11 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 12 #include "content/browser/bad_message.h" | 14 #include "content/browser/bad_message.h" |
| 13 #include "content/browser/message_port_message_filter.h" | 15 #include "content/browser/message_port_message_filter.h" |
| 14 #include "content/browser/message_port_service.h" | 16 #include "content/browser/message_port_service.h" |
| 15 #include "content/browser/service_worker/embedded_worker_registry.h" | 17 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 16 #include "content/browser/service_worker/service_worker_context_core.h" | 18 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 FindRegistrationHandle(provider_host->provider_id(), registration->id()); | 273 FindRegistrationHandle(provider_host->provider_id(), registration->id()); |
| 272 if (existing_handle) { | 274 if (existing_handle) { |
| 273 existing_handle->IncrementRefCount(); | 275 existing_handle->IncrementRefCount(); |
| 274 return existing_handle; | 276 return existing_handle; |
| 275 } | 277 } |
| 276 | 278 |
| 277 scoped_ptr<ServiceWorkerRegistrationHandle> new_handle( | 279 scoped_ptr<ServiceWorkerRegistrationHandle> new_handle( |
| 278 new ServiceWorkerRegistrationHandle(GetContext()->AsWeakPtr(), | 280 new ServiceWorkerRegistrationHandle(GetContext()->AsWeakPtr(), |
| 279 provider_host, registration)); | 281 provider_host, registration)); |
| 280 ServiceWorkerRegistrationHandle* new_handle_ptr = new_handle.get(); | 282 ServiceWorkerRegistrationHandle* new_handle_ptr = new_handle.get(); |
| 281 RegisterServiceWorkerRegistrationHandle(new_handle.Pass()); | 283 RegisterServiceWorkerRegistrationHandle(std::move(new_handle)); |
| 282 return new_handle_ptr; | 284 return new_handle_ptr; |
| 283 } | 285 } |
| 284 | 286 |
| 285 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( | 287 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
| 286 int thread_id, | 288 int thread_id, |
| 287 int request_id, | 289 int request_id, |
| 288 int provider_id, | 290 int provider_id, |
| 289 const GURL& pattern, | 291 const GURL& pattern, |
| 290 const GURL& script_url) { | 292 const GURL& script_url) { |
| 291 TRACE_EVENT0("ServiceWorker", | 293 TRACE_EVENT0("ServiceWorker", |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) { | 760 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) { |
| 759 bad_message::ReceivedBadMessage( | 761 bad_message::ReceivedBadMessage( |
| 760 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 762 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
| 761 return; | 763 return; |
| 762 } | 764 } |
| 763 provider_host = | 765 provider_host = |
| 764 scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( | 766 scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( |
| 765 render_process_id_, route_id, provider_id, provider_type, | 767 render_process_id_, route_id, provider_id, provider_type, |
| 766 GetContext()->AsWeakPtr(), this)); | 768 GetContext()->AsWeakPtr(), this)); |
| 767 } | 769 } |
| 768 GetContext()->AddProviderHost(provider_host.Pass()); | 770 GetContext()->AddProviderHost(std::move(provider_host)); |
| 769 } | 771 } |
| 770 | 772 |
| 771 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 773 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
| 772 TRACE_EVENT0("ServiceWorker", | 774 TRACE_EVENT0("ServiceWorker", |
| 773 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); | 775 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
| 774 if (!GetContext()) | 776 if (!GetContext()) |
| 775 return; | 777 return; |
| 776 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 778 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
| 777 bad_message::ReceivedBadMessage( | 779 bad_message::ReceivedBadMessage( |
| 778 this, bad_message::SWDH_PROVIDER_DESTROYED_NO_HOST); | 780 this, bad_message::SWDH_PROVIDER_DESTROYED_NO_HOST); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 if (!handle) { | 1322 if (!handle) { |
| 1321 bad_message::ReceivedBadMessage(this, | 1323 bad_message::ReceivedBadMessage(this, |
| 1322 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1324 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1323 return; | 1325 return; |
| 1324 } | 1326 } |
| 1325 handle->version()->StopWorker( | 1327 handle->version()->StopWorker( |
| 1326 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1328 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1327 } | 1329 } |
| 1328 | 1330 |
| 1329 } // namespace content | 1331 } // namespace content |
| OLD | NEW |