Chromium Code Reviews| 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..4a49049af92b313381b36e1f2edf21cf08a14a30 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,35 @@ 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. |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation) && |
|
michaeln
2015/10/07 01:16:44
nit: would we ever expect a valid id value when th
Fabrice (no longer in Chrome)
2015/10/07 12:59:43
Sounds good.
|
| + service_worker_provider_id_ != kInvalidServiceWorkerProviderId) { |
| + BrowserContext* browser_context = |
| + frame_tree_node_->navigator()->GetController()->GetBrowserContext(); |
| + DCHECK(browser_context); |
| + |
| + // TODO: Picking the partition based on the URL is incorrect. |
|
clamy
2015/10/07 07:53:30
nit: name in TODO. You can put mine if you want.
Fabrice (no longer in Chrome)
2015/10/07 12:59:43
Done.
|
| + // 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); |
| } |