| Index: content/browser/frame_host/navigation_handle_impl.cc
|
| diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
|
| index 786d70a6f0ef84207091ce754ae456bc0ee03487..de74b3978d24b6db8f776ff91699ef08d0c5c872 100644
|
| --- a/content/browser/frame_host/navigation_handle_impl.cc
|
| +++ b/content/browser/frame_host/navigation_handle_impl.cc
|
| @@ -4,11 +4,18 @@
|
|
|
| #include "content/browser/frame_host/navigation_handle_impl.h"
|
|
|
| +#include "base/command_line.h"
|
| #include "content/browser/frame_host/frame_tree_node.h"
|
| #include "content/browser/frame_host/navigator.h"
|
| #include "content/browser/frame_host/navigator_delegate.h"
|
| +#include "content/browser/service_worker/service_worker_context_wrapper.h"
|
| +#include "content/common/service_worker/service_worker_types.h"
|
| +#include "content/public/browser/browser_context.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| +#include "content/public/browser/storage_partition.h"
|
| #include "content/public/common/content_client.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "net/url_request/redirect_info.h"
|
|
|
| namespace content {
|
| @@ -33,11 +40,36 @@ NavigationHandleImpl::NavigationHandleImpl(const GURL& url,
|
| is_same_page_(false),
|
| state_(INITIAL),
|
| is_transferring_(false),
|
| - frame_tree_node_(frame_tree_node) {
|
| + frame_tree_node_(frame_tree_node),
|
| + service_worker_provider_id_(kInvalidServiceWorkerProviderId) {
|
| GetDelegate()->DidStartNavigation(this);
|
| }
|
|
|
| NavigationHandleImpl::~NavigationHandleImpl() {
|
| + // PlzNavigate
|
| + // Post a task to the IO thread to clean up the ServiceWorkerProviderHost.
|
| + // This is needed in case the navigation does not succeed.
|
| + if (service_worker_provider_id_ != kInvalidServiceWorkerProviderId) {
|
| + DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation));
|
| + BrowserContext* browser_context =
|
| + frame_tree_node_->navigator()->GetController()->GetBrowserContext();
|
| + DCHECK(browser_context);
|
| +
|
| + // TODO(clamy): Picking the partition based on the URL is incorrect.
|
| + // See crbug.com/513539
|
| + StoragePartition* partition =
|
| + BrowserContext::GetStoragePartitionForSite(browser_context, url_);
|
| + DCHECK(partition);
|
| + ServiceWorkerContextWrapper* service_worker_context =
|
| + static_cast<ServiceWorkerContextWrapper*>(
|
| + partition->GetServiceWorkerContext());
|
| +
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&ServiceWorkerContextWrapper::RemoveNavigationProviderHost,
|
| + service_worker_context, service_worker_provider_id_));
|
| + }
|
| GetDelegate()->DidFinishNavigation(this);
|
| }
|
|
|
|
|