| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); | 720 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); |
| 721 TRACE_EVENT0("ServiceWorker", | 721 TRACE_EVENT0("ServiceWorker", |
| 722 "ServiceWorkerDispatcherHost::OnProviderCreated"); | 722 "ServiceWorkerDispatcherHost::OnProviderCreated"); |
| 723 if (!GetContext()) | 723 if (!GetContext()) |
| 724 return; | 724 return; |
| 725 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 725 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
| 726 bad_message::ReceivedBadMessage(this, | 726 bad_message::ReceivedBadMessage(this, |
| 727 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 727 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
| 728 return; | 728 return; |
| 729 } | 729 } |
| 730 scoped_ptr<ServiceWorkerProviderHost> provider_host( | 730 |
| 731 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, | 731 scoped_ptr<ServiceWorkerProviderHost> provider_host; |
| 732 provider_type, GetContext()->AsWeakPtr(), | 732 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) { |
| 733 this)); | 733 // PlzNavigate |
| 734 // Retrieve the provider host previously created for navigation requests. |
| 735 provider_host = scoped_ptr<ServiceWorkerProviderHost>( |
| 736 GetContext()->TakeNavigationProviderHost(provider_id)); |
| 737 if (provider_host == nullptr) { |
| 738 bad_message::ReceivedBadMessage( |
| 739 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
| 740 return; |
| 741 } |
| 742 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type); |
| 743 provider_host->CompleteNavigationInitialized(render_process_id_, route_id, |
| 744 this); |
| 745 } else { |
| 746 provider_host = |
| 747 scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( |
| 748 render_process_id_, route_id, provider_id, provider_type, |
| 749 GetContext()->AsWeakPtr(), this)); |
| 750 } |
| 734 GetContext()->AddProviderHost(provider_host.Pass()); | 751 GetContext()->AddProviderHost(provider_host.Pass()); |
| 735 } | 752 } |
| 736 | 753 |
| 737 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 754 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
| 738 TRACE_EVENT0("ServiceWorker", | 755 TRACE_EVENT0("ServiceWorker", |
| 739 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); | 756 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
| 740 if (!GetContext()) | 757 if (!GetContext()) |
| 741 return; | 758 return; |
| 742 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 759 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
| 743 bad_message::ReceivedBadMessage( | 760 bad_message::ReceivedBadMessage( |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 if (!handle) { | 1289 if (!handle) { |
| 1273 bad_message::ReceivedBadMessage(this, | 1290 bad_message::ReceivedBadMessage(this, |
| 1274 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1291 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1275 return; | 1292 return; |
| 1276 } | 1293 } |
| 1277 handle->version()->StopWorker( | 1294 handle->version()->StopWorker( |
| 1278 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1295 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1279 } | 1296 } |
| 1280 | 1297 |
| 1281 } // namespace content | 1298 } // namespace content |
| OLD | NEW |