Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1376)

Unified Diff: content/browser/loader/navigation_url_loader_impl_core.cc

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Glorious Post-Blink Merge Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/navigation_url_loader_impl_core.cc
diff --git a/content/browser/loader/navigation_url_loader_impl_core.cc b/content/browser/loader/navigation_url_loader_impl_core.cc
index 7cbf6999946551028e17f588a2d5277e81119cff..1298dfae5b9babadb3206ac874c2f6642af68631 100644
--- a/content/browser/loader/navigation_url_loader_impl_core.cc
+++ b/content/browser/loader/navigation_url_loader_impl_core.cc
@@ -10,7 +10,10 @@
#include "content/browser/frame_host/navigation_request_info.h"
#include "content/browser/loader/navigation_resource_handler.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
+#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/browser/service_worker/service_worker_request_handler.h"
#include "content/common/navigation_params.h"
+#include "content/common/service_worker/service_worker_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/common/resource_response.h"
@@ -20,9 +23,13 @@
namespace content {
NavigationURLLoaderImplCore::NavigationURLLoaderImplCore(
- const base::WeakPtr<NavigationURLLoaderImpl>& loader)
+ const base::WeakPtr<NavigationURLLoaderImpl>& loader,
+ ServiceWorkerContext* service_worker_context)
: loader_(loader),
- resource_handler_(nullptr) {
+ resource_handler_(nullptr),
+ service_worker_context_(
+ static_cast<ServiceWorkerContextWrapper*>(service_worker_context)),
+ service_worker_handler_(nullptr) {
// This object is created on the UI thread but otherwise is accessed and
// deleted on the IO thread.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -47,8 +54,8 @@ void NavigationURLLoaderImplCore::Start(
base::TimeTicks::Now()));
ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
michaeln 2015/09/23 19:18:17 Upon return from this function, the newly created
Fabrice (no longer in Chrome) 2015/09/30 17:32:08 This is now completely different.
- resource_context, frame_tree_node_id,
- *request_info, this);
+ resource_context, frame_tree_node_id, *request_info, this,
+ service_worker_context_.get());
}
void NavigationURLLoaderImplCore::FollowRedirect() {
@@ -58,6 +65,11 @@ void NavigationURLLoaderImplCore::FollowRedirect() {
resource_handler_->FollowRedirect();
}
+void NavigationURLLoaderImplCore::SetServiceWorkerHandler(
+ ServiceWorkerRequestHandler* service_worker_handler) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ service_worker_handler_ = service_worker_handler;
+}
void NavigationURLLoaderImplCore::NotifyRequestRedirected(
const net::RedirectInfo& redirect_info,
@@ -80,6 +92,14 @@ void NavigationURLLoaderImplCore::NotifyResponseStarted(
scoped_ptr<StreamHandle> body) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (service_worker_handler_) {
+ scoped_ptr<ServiceWorkerProviderHost> provider_host =
+ service_worker_handler_->TakeBrowserProviderHost();
+ if (provider_host)
+ service_worker_context_->RegisterBrowserProviderHost(
+ provider_host.Pass());
+ }
+
// If, by the time the task reaches the UI thread, |loader_| has already been
// destroyed, NotifyResponseStarted will not run. |body| will be destructed
// and the request released at that point.
« no previous file with comments | « content/browser/loader/navigation_url_loader_impl_core.h ('k') | content/browser/loader/navigation_url_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698