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..8af33a7cc271b0f558766a79592c2b13243f4091 100644 |
| --- a/content/child/service_worker/service_worker_network_provider.cc |
| +++ b/content/child/service_worker/service_worker_network_provider.cc |
| @@ -5,9 +5,11 @@ |
| #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/public/common/content_switches.h" |
| namespace content { |
| @@ -46,17 +48,41 @@ ServiceWorkerNetworkProvider* ServiceWorkerNetworkProvider::FromDocumentState( |
| ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( |
| int route_id, |
| - ServiceWorkerProviderType provider_type) |
| - : provider_id_(GenerateProviderIdForType(provider_type)) { |
| + ServiceWorkerProviderType provider_type, |
| + int browser_provider_id) { |
|
kinuko
2015/08/21 14:00:44
provider_id_(kInvalidServiceWorkerProviderId) here
Fabrice (no longer in Chrome)
2015/08/26 13:23:24
This won't work because GenerateProviderIdForType
|
| + if (browser_provider_id < kInvalidServiceWorkerProviderId) { |
| + // 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; |
| + } else if (browser_provider_id == kInvalidServiceWorkerProviderId) { |
| + // Initialize a new provider ID in all other cases. |
| + provider_id_ = GenerateProviderIdForType(provider_type); |
| + } else { |
| + NOTREACHED() << "The browser_provider_id argument was set to " |
| + << browser_provider_id << "."; |
| + } |
| + |
| 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) {} |
| + |
| ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { |
| if (provider_id_ == kInvalidServiceWorkerProviderId) |
| return; |