| 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 18a2fcd24ab4115fecf54d92e5332f4349d6696c..d67bd93db8a674a978dd52c63fccf5b397eb639f 100644
|
| --- a/content/browser/frame_host/navigation_handle_impl.cc
|
| +++ b/content/browser/frame_host/navigation_handle_impl.cc
|
| @@ -4,9 +4,15 @@
|
|
|
| #include "content/browser/frame_host/navigation_handle_impl.h"
|
|
|
| +#include "base/command_line.h"
|
| #include "content/browser/frame_host/navigator_delegate.h"
|
| +#include "content/browser/service_worker/service_worker_context_wrapper.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 {
|
| @@ -15,14 +21,18 @@ namespace content {
|
| scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create(
|
| const GURL& url,
|
| bool is_main_frame,
|
| - NavigatorDelegate* delegate) {
|
| - return scoped_ptr<NavigationHandleImpl>(
|
| - new NavigationHandleImpl(url, is_main_frame, delegate));
|
| + NavigatorDelegate* delegate,
|
| + int service_worker_provider_id) {
|
| + return scoped_ptr<NavigationHandleImpl>(new NavigationHandleImpl(
|
| + url, is_main_frame, delegate, service_worker_provider_id));
|
| }
|
|
|
| -NavigationHandleImpl::NavigationHandleImpl(const GURL& url,
|
| - const bool is_main_frame,
|
| - NavigatorDelegate* delegate)
|
| +
|
| +NavigationHandleImpl::NavigationHandleImpl(
|
| + const GURL& url,
|
| + bool is_main_frame,
|
| + NavigatorDelegate* delegate,
|
| + int service_worker_provider_id)
|
| : url_(url),
|
| is_main_frame_(is_main_frame),
|
| is_post_(false),
|
| @@ -34,11 +44,36 @@ NavigationHandleImpl::NavigationHandleImpl(const GURL& url,
|
| is_same_page_(false),
|
| state_(INITIAL),
|
| is_transferring_(false),
|
| - delegate_(delegate) {
|
| + delegate_(delegate),
|
| + service_worker_provider_id_(service_worker_provider_id) {
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + BrowserContext* browser_context = delegate_->GetBrowserContext();
|
| + DCHECK(browser_context);
|
| + // Picking the partition based on the URL is incorrect.
|
| + // See crbug.com/513539
|
| + StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(
|
| + browser_context, url);
|
| + DCHECK(partition);
|
| + service_worker_context_ = scoped_refptr<ServiceWorkerContextWrapper>(
|
| + static_cast<ServiceWorkerContextWrapper*>(
|
| + partition->GetServiceWorkerContext()));
|
| + }
|
| delegate_->DidStartNavigation(this);
|
| }
|
|
|
| NavigationHandleImpl::~NavigationHandleImpl() {
|
| + // PlzNavigate
|
| + // Post a task to the IO thread to clean up the ServiceWorkerProviderHost.
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&ServiceWorkerContextWrapper::RemoveNavigationProviderHost,
|
| + service_worker_context_,
|
| + service_worker_provider_id_));
|
| + }
|
| delegate_->DidFinishNavigation(this);
|
| }
|
|
|
|
|