Chromium Code Reviews| Index: content/child/service_worker/service_worker_network_provider.cc |
| diff --git a/content/child/service_worker/service_worker_network_provider.cc b/content/child/service_worker/service_worker_network_provider.cc |
| index bd521b844840a88aafba94bd15e409986a85adae..2e5a51c5b066565d18c0476cb6561c1853b3e7d1 100644 |
| --- a/content/child/service_worker/service_worker_network_provider.cc |
| +++ b/content/child/service_worker/service_worker_network_provider.cc |
| @@ -5,9 +5,12 @@ |
| #include "content/child/service_worker/service_worker_network_provider.h" |
| #include "base/atomic_sequence_num.h" |
| +#include "base/command_line.h" |
| #include "content/child/child_thread_impl.h" |
| #include "content/child/service_worker/service_worker_provider_context.h" |
| #include "content/common/service_worker/service_worker_messages.h" |
| +#include "content/common/service_worker/service_worker_utils.h" |
| +#include "content/public/common/content_switches.h" |
| namespace content { |
| @@ -46,17 +49,39 @@ ServiceWorkerNetworkProvider* ServiceWorkerNetworkProvider::FromDocumentState( |
| ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( |
| int route_id, |
| - ServiceWorkerProviderType provider_type) |
| - : provider_id_(GenerateProviderIdForType(provider_type)) { |
| + ServiceWorkerProviderType provider_type, |
| + int browser_provider_id) { |
| + provider_id_ = kInvalidServiceWorkerProviderId; |
| + if (ServiceWorkerUtils::IsBrowserAssignedProviderId(browser_provider_id)) { |
| + // PlzNavigate |
| + CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation)); |
| + // This was a browser-initiated navigation, the ServiceWorkerProviderHost |
| + // has already been initialized, copy the provider_id value. |
| + provider_id_ = browser_provider_id; |
|
michaeln
2015/09/01 01:15:23
Is it possible for provider_type to be SERVICE_WOR
Fabrice (no longer in Chrome)
2015/09/07 12:09:48
DCHECK'd
|
| + } else { |
| + // Initialize a new provider ID in all other cases. |
| + DCHECK_EQ(kInvalidServiceWorkerProviderId, browser_provider_id); |
| + provider_id_ = GenerateProviderIdForType(provider_type); |
| + } |
| if (provider_id_ == kInvalidServiceWorkerProviderId) |
| return; |
| + |
| context_ = new ServiceWorkerProviderContext(provider_id_); |
| if (!ChildThreadImpl::current()) |
| return; // May be null in some tests. |
| + |
| ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_ProviderCreated( |
| provider_id_, route_id, provider_type)); |
| } |
| +ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( |
| + int route_id, |
| + ServiceWorkerProviderType provider_type) |
| + : ServiceWorkerNetworkProvider(route_id, |
| + provider_type, |
| + kInvalidServiceWorkerProviderId) {} |
|
michaeln
2015/09/01 01:15:23
maybe invoke GenerateProviderIdForType(provider_ty
Fabrice (no longer in Chrome)
2015/09/07 12:09:48
We still have some sanity DCHECKs, I don't think i
|
| + |
| ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { |
| if (provider_id_ == kInvalidServiceWorkerProviderId) |
| return; |