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

Side by Side Diff: content/browser/service_worker/service_worker_request_handler.h

Issue 2897063002: Network service: Implement URLLoader chaining for interceptors (Closed)
Patch Set: documentation Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/supports_user_data.h" 13 #include "base/supports_user_data.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/browser/loader/url_loader_request_handler.h"
15 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
16 #include "content/common/service_worker/service_worker_status_code.h" 17 #include "content/common/service_worker/service_worker_status_code.h"
17 #include "content/common/service_worker/service_worker_types.h" 18 #include "content/common/service_worker/service_worker_types.h"
18 #include "content/common/url_loader_factory.mojom.h"
19 #include "content/public/common/request_context_frame_type.h" 19 #include "content/public/common/request_context_frame_type.h"
20 #include "content/public/common/request_context_type.h" 20 #include "content/public/common/request_context_type.h"
21 #include "content/public/common/resource_type.h" 21 #include "content/public/common/resource_type.h"
22 #include "net/url_request/url_request_job_factory.h" 22 #include "net/url_request/url_request_job_factory.h"
23 23
24 namespace net { 24 namespace net {
25 class NetworkDelegate; 25 class NetworkDelegate;
26 class URLRequest; 26 class URLRequest;
27 class URLRequestInterceptor; 27 class URLRequestInterceptor;
28 } 28 }
29 29
30 namespace storage { 30 namespace storage {
31 class BlobStorageContext; 31 class BlobStorageContext;
32 } 32 }
33 33
34 namespace content { 34 namespace content {
35 35
36 class ResourceContext; 36 class ResourceContext;
37 class ResourceRequestBodyImpl; 37 class ResourceRequestBodyImpl;
38 class ServiceWorkerContextCore; 38 class ServiceWorkerContextCore;
39 class ServiceWorkerContextWrapper; 39 class ServiceWorkerContextWrapper;
40 class ServiceWorkerNavigationHandleCore; 40 class ServiceWorkerNavigationHandleCore;
41 class ServiceWorkerProviderHost; 41 class ServiceWorkerProviderHost;
42 class WebContents; 42 class WebContents;
43 43
44 // Abstract base class for routing network requests to ServiceWorkers. 44 // Abstract base class for routing network requests to ServiceWorkers.
45 // Created one per URLRequest and attached to each request. 45 // Created one per URLRequest and attached to each request.
46 class CONTENT_EXPORT ServiceWorkerRequestHandler 46 class CONTENT_EXPORT ServiceWorkerRequestHandler
47 : public base::SupportsUserData::Data { 47 : public base::SupportsUserData::Data,
48 public URLLoaderRequestHandler {
48 public: 49 public:
49 // PlzNavigate 50 // PlzNavigate
50 // Attaches a newly created handler if the given |request| needs to be handled 51 // Attaches a newly created handler if the given |request| needs to be handled
51 // by ServiceWorker. 52 // by ServiceWorker.
52 static void InitializeForNavigation( 53 static void InitializeForNavigation(
53 net::URLRequest* request, 54 net::URLRequest* request,
54 ServiceWorkerNavigationHandleCore* navigation_handle_core, 55 ServiceWorkerNavigationHandleCore* navigation_handle_core,
55 storage::BlobStorageContext* blob_storage_context, 56 storage::BlobStorageContext* blob_storage_context,
56 bool skip_service_worker, 57 bool skip_service_worker,
57 ResourceType resource_type, 58 ResourceType resource_type,
58 RequestContextType request_context_type, 59 RequestContextType request_context_type,
59 RequestContextFrameType frame_type, 60 RequestContextFrameType frame_type,
60 bool is_parent_frame_secure, 61 bool is_parent_frame_secure,
61 scoped_refptr<ResourceRequestBodyImpl> body, 62 scoped_refptr<ResourceRequestBodyImpl> body,
62 const base::Callback<WebContents*(void)>& web_contents_getter); 63 const base::Callback<WebContents*(void)>& web_contents_getter);
63 64
64 // PlzNavigate and --enable-network-service. 65 // PlzNavigate and --enable-network-service.
65 // Same as InitializeForNavigation() but instead of attaching to a URLRequest, 66 // Same as InitializeForNavigation() but instead of attaching to a URLRequest,
66 // returns a URLLoaderFactoryPtrInfo if the request needs to be handled. 67 // just creates a URLLoaderRequestHandler and returns it.
67 static mojom::URLLoaderFactoryPtr InitializeForNavigationNetworkService( 68 static std::unique_ptr<URLLoaderRequestHandler>
69 InitializeForNavigationNetworkService(
68 const ResourceRequest& resource_request, 70 const ResourceRequest& resource_request,
69 ResourceContext* resource_context, 71 ResourceContext* resource_context,
70 ServiceWorkerNavigationHandleCore* navigation_handle_core, 72 ServiceWorkerNavigationHandleCore* navigation_handle_core,
71 storage::BlobStorageContext* blob_storage_context, 73 storage::BlobStorageContext* blob_storage_context,
72 bool skip_service_worker, 74 bool skip_service_worker,
73 ResourceType resource_type, 75 ResourceType resource_type,
74 RequestContextType request_context_type, 76 RequestContextType request_context_type,
75 RequestContextFrameType frame_type, 77 RequestContextFrameType frame_type,
76 bool is_parent_frame_secure, 78 bool is_parent_frame_secure,
77 scoped_refptr<ResourceRequestBodyImpl> body, 79 scoped_refptr<ResourceRequestBodyImpl> body,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const net::URLRequest* request); 121 const net::URLRequest* request);
120 122
121 ~ServiceWorkerRequestHandler() override; 123 ~ServiceWorkerRequestHandler() override;
122 124
123 // Called via custom URLRequestJobFactory. 125 // Called via custom URLRequestJobFactory.
124 virtual net::URLRequestJob* MaybeCreateJob( 126 virtual net::URLRequestJob* MaybeCreateJob(
125 net::URLRequest* request, 127 net::URLRequest* request,
126 net::NetworkDelegate* network_delegate, 128 net::NetworkDelegate* network_delegate,
127 ResourceContext* context) = 0; 129 ResourceContext* context) = 0;
128 130
131 // URLLoaderRequestHandler overrides.
132 void MaybeCreateLoaderFactory(const ResourceRequest& request,
133 ResourceContext* resource_context,
134 LoaderFactoryCallback callback) override;
135
129 // Methods to support cross site navigations. 136 // Methods to support cross site navigations.
130 void PrepareForCrossSiteTransfer(int old_process_id); 137 void PrepareForCrossSiteTransfer(int old_process_id);
131 void CompleteCrossSiteTransfer(int new_process_id, 138 void CompleteCrossSiteTransfer(int new_process_id,
132 int new_provider_id); 139 int new_provider_id);
133 void MaybeCompleteCrossSiteTransferInOldProcess( 140 void MaybeCompleteCrossSiteTransferInOldProcess(
134 int old_process_id); 141 int old_process_id);
135 142
136 // Useful for detecting storage partition mismatches in the context of cross 143 // Useful for detecting storage partition mismatches in the context of cross
137 // site transfer navigations. 144 // site transfer navigations.
138 bool SanityCheckIsSameContext(ServiceWorkerContextWrapper* wrapper); 145 bool SanityCheckIsSameContext(ServiceWorkerContextWrapper* wrapper);
(...skipping 14 matching lines...) Expand all
153 std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; 160 std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_;
154 int old_process_id_; 161 int old_process_id_;
155 int old_provider_id_; 162 int old_provider_id_;
156 163
157 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); 164 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler);
158 }; 165 };
159 166
160 } // namespace content 167 } // namespace content
161 168
162 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ 169 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698