Chromium Code Reviews| 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/command_line.h" | |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "content/browser/bad_message.h" | 12 #include "content/browser/bad_message.h" |
| 12 #include "content/browser/message_port_message_filter.h" | 13 #include "content/browser/message_port_message_filter.h" |
| 13 #include "content/browser/message_port_service.h" | 14 #include "content/browser/message_port_service.h" |
| 14 #include "content/browser/service_worker/embedded_worker_registry.h" | 15 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 15 #include "content/browser/service_worker/service_worker_context_core.h" | 16 #include "content/browser/service_worker/service_worker_context_core.h" |
| 16 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 17 #include "content/browser/service_worker/service_worker_handle.h" | 18 #include "content/browser/service_worker/service_worker_handle.h" |
| 18 #include "content/browser/service_worker/service_worker_registration.h" | 19 #include "content/browser/service_worker/service_worker_registration.h" |
| 19 #include "content/browser/service_worker/service_worker_registration_handle.h" | 20 #include "content/browser/service_worker/service_worker_registration_handle.h" |
| 20 #include "content/common/service_worker/embedded_worker_messages.h" | 21 #include "content/common/service_worker/embedded_worker_messages.h" |
| 21 #include "content/common/service_worker/service_worker_messages.h" | 22 #include "content/common/service_worker/service_worker_messages.h" |
| 22 #include "content/common/service_worker/service_worker_types.h" | 23 #include "content/common/service_worker/service_worker_types.h" |
| 23 #include "content/common/service_worker/service_worker_utils.h" | 24 #include "content/common/service_worker/service_worker_utils.h" |
| 24 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
| 25 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/content_switches.h" | |
| 26 #include "content/public/common/origin_util.h" | 28 #include "content/public/common/origin_util.h" |
| 27 #include "ipc/ipc_message_macros.h" | 29 #include "ipc/ipc_message_macros.h" |
| 28 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
| 29 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" | 31 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" |
| 30 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 31 | 33 |
| 32 using blink::WebServiceWorkerError; | 34 using blink::WebServiceWorkerError; |
| 33 | 35 |
| 34 namespace content { | 36 namespace content { |
| 35 | 37 |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); | 727 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); |
| 726 TRACE_EVENT0("ServiceWorker", | 728 TRACE_EVENT0("ServiceWorker", |
| 727 "ServiceWorkerDispatcherHost::OnProviderCreated"); | 729 "ServiceWorkerDispatcherHost::OnProviderCreated"); |
| 728 if (!GetContext()) | 730 if (!GetContext()) |
| 729 return; | 731 return; |
| 730 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 732 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
| 731 bad_message::ReceivedBadMessage(this, | 733 bad_message::ReceivedBadMessage(this, |
| 732 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 734 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
| 733 return; | 735 return; |
| 734 } | 736 } |
| 737 | |
| 738 // PlzNavigate: | |
| 739 if (provider_id < kInvalidServiceWorkerProviderId) { | |
|
kinuko
2015/08/21 14:00:44
nit: Could we have a small helper function to chec
Fabrice (no longer in Chrome)
2015/08/26 13:23:24
Done.
| |
| 740 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 741 switches::kEnableBrowserSideNavigation)); | |
| 742 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type); | |
| 743 scoped_ptr<ServiceWorkerProviderHost> navigation_provider_host( | |
| 744 GetContext()->TakeBrowserProviderHost(provider_id)); | |
|
michaeln
2015/09/01 01:15:23
If anything should prevent navigation from proceed
| |
| 745 if (navigation_provider_host == nullptr) { | |
| 746 bad_message::ReceivedBadMessage(this, bad_message::SWDH_NOT_HANDLED); | |
| 747 return; | |
| 748 } | |
| 749 navigation_provider_host->CompleteCrossSiteTransfer( | |
|
nasko
2015/08/20 16:49:50
There are no cross-site transfers in PlzNavigate.
kinuko
2015/08/21 14:00:44
This method is used to complete the NavigationProv
Fabrice (no longer in Chrome)
2015/08/26 13:23:24
Agreed, bad name for PlzNavigate. I'm not sure we
| |
| 750 render_process_id_, route_id, provider_id, provider_type, this); | |
| 751 GetContext()->AddProviderHost(navigation_provider_host.Pass()); | |
| 752 return; | |
| 753 } | |
| 754 | |
| 735 scoped_ptr<ServiceWorkerProviderHost> provider_host( | 755 scoped_ptr<ServiceWorkerProviderHost> provider_host( |
| 736 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, | 756 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, |
| 737 provider_type, GetContext()->AsWeakPtr(), | 757 provider_type, GetContext()->AsWeakPtr(), |
| 738 this)); | 758 this)); |
| 739 GetContext()->AddProviderHost(provider_host.Pass()); | 759 GetContext()->AddProviderHost(provider_host.Pass()); |
| 740 } | 760 } |
| 741 | 761 |
| 742 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 762 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
| 743 TRACE_EVENT0("ServiceWorker", | 763 TRACE_EVENT0("ServiceWorker", |
| 744 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); | 764 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 if (!handle) { | 1306 if (!handle) { |
| 1287 bad_message::ReceivedBadMessage(this, | 1307 bad_message::ReceivedBadMessage(this, |
| 1288 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1308 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1289 return; | 1309 return; |
| 1290 } | 1310 } |
| 1291 handle->version()->StopWorker( | 1311 handle->version()->StopWorker( |
| 1292 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1312 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1293 } | 1313 } |
| 1294 | 1314 |
| 1295 } // namespace content | 1315 } // namespace content |
| OLD | NEW |