Index: content/browser/service_worker/service_worker_request_handler.cc |
diff --git a/content/browser/service_worker/service_worker_request_handler.cc b/content/browser/service_worker/service_worker_request_handler.cc |
index c0b739494a5b8f3a3ed10fd864a42329ca88eb35..d19b724c62a604600c25f41f437c310a1ab30974 100644 |
--- a/content/browser/service_worker/service_worker_request_handler.cc |
+++ b/content/browser/service_worker/service_worker_request_handler.cc |
@@ -6,6 +6,8 @@ |
#include <string> |
+#include "base/command_line.h" |
+#include "content/browser/loader/navigation_url_loader_impl_core.h" |
#include "content/browser/service_worker/service_worker_context_core.h" |
#include "content/browser/service_worker/service_worker_context_wrapper.h" |
#include "content/browser/service_worker/service_worker_provider_host.h" |
@@ -15,11 +17,11 @@ |
#include "content/common/resource_request_body.h" |
#include "content/common/service_worker/service_worker_types.h" |
#include "content/public/browser/resource_context.h" |
+#include "content/public/common/content_switches.h" |
#include "net/base/net_util.h" |
#include "net/url_request/url_request.h" |
#include "net/url_request/url_request_interceptor.h" |
#include "storage/browser/blob/blob_storage_context.h" |
- |
namespace content { |
namespace { |
@@ -63,6 +65,15 @@ void ServiceWorkerRequestHandler::InitializeHandler( |
RequestContextType request_context_type, |
RequestContextFrameType frame_type, |
scoped_refptr<ResourceRequestBody> body) { |
+ // PlzNavigate: |
+ if (request->url().SchemeIsBlob()) { |
michaeln
2015/07/24 22:22:27
Is there a more direct way of identifying plznavig
horo
2015/07/27 09:11:17
Removed these code from ServiceWorkerRequestHandle
|
+ scoped_ptr<ServiceWorkerProviderHost> navigation_provider_host( |
+ context_wrapper->context()->TakeNavigationProviderHost(request->url())); |
+ if (navigation_provider_host) { |
+ context_wrapper->context()->TransferProviderHostIn( |
+ process_id, provider_id, navigation_provider_host.Pass()); |
+ } |
+ } |
if (!request->url().SchemeIsHTTPOrHTTPS()) |
return; |
@@ -86,7 +97,6 @@ void ServiceWorkerRequestHandler::InitializeHandler( |
} |
return; |
} |
- |
scoped_ptr<ServiceWorkerRequestHandler> handler( |
provider_host->CreateRequestHandler(request_mode, |
credentials_mode, |
@@ -101,6 +111,44 @@ void ServiceWorkerRequestHandler::InitializeHandler( |
request->SetUserData(&kUserDataKey, handler.release()); |
} |
+void ServiceWorkerRequestHandler::InitializeNavigationHandler( |
+ net::URLRequest* request, |
+ ServiceWorkerContextWrapper* context_wrapper, |
+ storage::BlobStorageContext* blob_storage_context, |
+ bool skip_service_worker, |
+ bool is_main_frame, |
+ scoped_refptr<ResourceRequestBody> body, |
+ NavigationURLLoaderImplCore* loader) { |
+ CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)); |
+ if (!request->url().SchemeIsHTTPOrHTTPS()) |
+ return; |
+ if (!context_wrapper || !context_wrapper->context()) |
+ return; |
+ scoped_ptr<ServiceWorkerProviderHost> provider_host( |
+ context_wrapper->context()->CreateNavigationProviderHost()); |
+ loader->SetServiceWorkerProviderHost(provider_host.Pass()); |
+ if (skip_service_worker) { |
+ // TODO(horo): Does it work correctly?. |
+ provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); |
+ provider_host->SetTopmostFrameUrl(request->first_party_for_cookies()); |
+ provider_host->AddAllMatchingRegistrations(); |
+ return; |
+ } |
+ scoped_ptr<ServiceWorkerRequestHandler> handler( |
+ loader->service_worker_provider_host()->CreateRequestHandler( |
+ FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_SAME_ORIGIN, |
+ is_main_frame ? RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME, |
+ REQUEST_CONTEXT_TYPE_LOCATION, // TODO(horo): pass in |
+ // FrameHostMsg_BeginNavigation |
+ REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, // TODO(horo): pass in |
+ // FrameHostMsg_BeginNavigation |
+ blob_storage_context->AsWeakPtr(), body)); |
+ if (!handler) |
+ return; |
+ request->SetUserData(&kUserDataKey, handler.release()); |
+} |
+ |
ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( |
net::URLRequest* request) { |
return static_cast<ServiceWorkerRequestHandler*>( |