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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 if (IsBrowserSideNavigationEnabled() && | 1009 if (IsBrowserSideNavigationEnabled() && |
| 1010 ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) { | 1010 ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) { |
| 1011 std::unique_ptr<ServiceWorkerProviderHost> provider_host; | 1011 std::unique_ptr<ServiceWorkerProviderHost> provider_host; |
| 1012 // PlzNavigate | 1012 // PlzNavigate |
| 1013 // Retrieve the provider host previously created for navigation requests. | 1013 // Retrieve the provider host previously created for navigation requests. |
| 1014 ServiceWorkerNavigationHandleCore* navigation_handle_core = | 1014 ServiceWorkerNavigationHandleCore* navigation_handle_core = |
| 1015 GetContext()->GetNavigationHandleCore(info.provider_id); | 1015 GetContext()->GetNavigationHandleCore(info.provider_id); |
| 1016 if (navigation_handle_core != nullptr) | 1016 if (navigation_handle_core != nullptr) |
| 1017 provider_host = navigation_handle_core->RetrievePreCreatedHost(); | 1017 provider_host = navigation_handle_core->RetrievePreCreatedHost(); |
| 1018 | 1018 |
| 1019 // If no host is found, the navigation has been cancelled in the meantime. | 1019 // If no host is found, create one. |
| 1020 // Just return as the navigation will be stopped in the renderer as well. | 1020 if (provider_host == nullptr) { |
|
michaeln
2017/03/23 22:25:07
Do we know how this happens?
The only way to get
clamy
2017/04/05 12:23:48
My personal hunch (I haven't been able to reproduc
| |
| 1021 if (provider_host == nullptr) | 1021 GetContext()->AddProviderHost( |
| 1022 ServiceWorkerProviderHost::Create(render_process_id_, std::move(info), | |
| 1023 GetContext()->AsWeakPtr(), this)); | |
| 1022 return; | 1024 return; |
| 1025 } | |
| 1026 | |
| 1027 // Otherwise, completed the initialization of the pre-created host. | |
| 1023 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, info.type); | 1028 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, info.type); |
| 1024 provider_host->CompleteNavigationInitialized(render_process_id_, | 1029 provider_host->CompleteNavigationInitialized(render_process_id_, |
| 1025 info.route_id, this); | 1030 info.route_id, this); |
| 1026 GetContext()->AddProviderHost(std::move(provider_host)); | 1031 GetContext()->AddProviderHost(std::move(provider_host)); |
| 1027 } else { | 1032 } else { |
| 1028 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) { | 1033 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) { |
| 1029 bad_message::ReceivedBadMessage( | 1034 bad_message::ReceivedBadMessage( |
| 1030 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 1035 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
| 1031 return; | 1036 return; |
| 1032 } | 1037 } |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1775 if (!handle) { | 1780 if (!handle) { |
| 1776 bad_message::ReceivedBadMessage(this, | 1781 bad_message::ReceivedBadMessage(this, |
| 1777 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1782 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1778 return; | 1783 return; |
| 1779 } | 1784 } |
| 1780 handle->version()->StopWorker( | 1785 handle->version()->StopWorker( |
| 1781 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1786 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1782 } | 1787 } |
| 1783 | 1788 |
| 1784 } // namespace content | 1789 } // namespace content |
| OLD | NEW |