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..9d6dd4add07fcde780581301d9829040fa1e02c3 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,34 @@ 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); |
+ StoragePartition* partition = BrowserContext::GetStoragePartitionForSite( |
michaeln
2015/10/01 01:42:15
picking the partition based on the url is actually
Fabrice (no longer in Chrome)
2015/10/01 18:29:54
Done.
|
+ browser_context, url); |
+ DCHECK(partition); |
+ service_worker_context_ = scoped_refptr<ServiceWorkerContextWrapper>( |
+ static_cast<ServiceWorkerContextWrapper*>( |
+ partition->GetServiceWorkerContext())); |
+ } |
delegate_->DidStartNavigation(this); |
} |
NavigationHandleImpl::~NavigationHandleImpl() { |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)) { |
+ // PlzNavigate |
clamy
2015/10/01 12:41:26
nit: I would put this comment above the if conditi
Fabrice (no longer in Chrome)
2015/10/01 18:29:54
Done.
|
+ // Post task to IO thread to destroy the Host. |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, |
+ FROM_HERE, |
+ base::Bind(&ServiceWorkerContextWrapper::RemoveNavigationProviderHost, |
+ service_worker_context_, |
+ service_worker_provider_id_)); |
+ } |
delegate_->DidFinishNavigation(this); |
} |