OLD | NEW |
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" |
(...skipping 16 matching lines...) Expand all Loading... |
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 ResourceRequestBody; |
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 URLLoaderRequestHandler { |
49 public: | 49 public: |
50 // PlzNavigate | 50 // PlzNavigate |
51 // 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 |
52 // by ServiceWorker. | 52 // by ServiceWorker. |
53 static void InitializeForNavigation( | 53 static void InitializeForNavigation( |
54 net::URLRequest* request, | 54 net::URLRequest* request, |
55 ServiceWorkerNavigationHandleCore* navigation_handle_core, | 55 ServiceWorkerNavigationHandleCore* navigation_handle_core, |
56 storage::BlobStorageContext* blob_storage_context, | 56 storage::BlobStorageContext* blob_storage_context, |
57 bool skip_service_worker, | 57 bool skip_service_worker, |
58 ResourceType resource_type, | 58 ResourceType resource_type, |
59 RequestContextType request_context_type, | 59 RequestContextType request_context_type, |
60 RequestContextFrameType frame_type, | 60 RequestContextFrameType frame_type, |
61 bool is_parent_frame_secure, | 61 bool is_parent_frame_secure, |
62 scoped_refptr<ResourceRequestBodyImpl> body, | 62 scoped_refptr<ResourceRequestBody> body, |
63 const base::Callback<WebContents*(void)>& web_contents_getter); | 63 const base::Callback<WebContents*(void)>& web_contents_getter); |
64 | 64 |
65 // PlzNavigate and --enable-network-service. | 65 // PlzNavigate and --enable-network-service. |
66 // Same as InitializeForNavigation() but instead of attaching to a URLRequest, | 66 // Same as InitializeForNavigation() but instead of attaching to a URLRequest, |
67 // just creates a URLLoaderRequestHandler and returns it. | 67 // just creates a URLLoaderRequestHandler and returns it. |
68 static std::unique_ptr<URLLoaderRequestHandler> | 68 static std::unique_ptr<URLLoaderRequestHandler> |
69 InitializeForNavigationNetworkService( | 69 InitializeForNavigationNetworkService( |
70 const ResourceRequest& resource_request, | 70 const ResourceRequest& resource_request, |
71 ResourceContext* resource_context, | 71 ResourceContext* resource_context, |
72 ServiceWorkerNavigationHandleCore* navigation_handle_core, | 72 ServiceWorkerNavigationHandleCore* navigation_handle_core, |
73 storage::BlobStorageContext* blob_storage_context, | 73 storage::BlobStorageContext* blob_storage_context, |
74 bool skip_service_worker, | 74 bool skip_service_worker, |
75 ResourceType resource_type, | 75 ResourceType resource_type, |
76 RequestContextType request_context_type, | 76 RequestContextType request_context_type, |
77 RequestContextFrameType frame_type, | 77 RequestContextFrameType frame_type, |
78 bool is_parent_frame_secure, | 78 bool is_parent_frame_secure, |
79 scoped_refptr<ResourceRequestBodyImpl> body, | 79 scoped_refptr<ResourceRequestBody> body, |
80 const base::Callback<WebContents*(void)>& web_contents_getter); | 80 const base::Callback<WebContents*(void)>& web_contents_getter); |
81 | 81 |
82 // Attaches a newly created handler if the given |request| needs to | 82 // Attaches a newly created handler if the given |request| needs to |
83 // be handled by ServiceWorker. | 83 // be handled by ServiceWorker. |
84 // TODO(kinuko): While utilizing UserData to attach data to URLRequest | 84 // TODO(kinuko): While utilizing UserData to attach data to URLRequest |
85 // has some precedence, it might be better to attach this handler in a more | 85 // has some precedence, it might be better to attach this handler in a more |
86 // explicit way within content layer, e.g. have ResourceRequestInfoImpl | 86 // explicit way within content layer, e.g. have ResourceRequestInfoImpl |
87 // own it. | 87 // own it. |
88 static void InitializeHandler( | 88 static void InitializeHandler( |
89 net::URLRequest* request, | 89 net::URLRequest* request, |
90 ServiceWorkerContextWrapper* context_wrapper, | 90 ServiceWorkerContextWrapper* context_wrapper, |
91 storage::BlobStorageContext* blob_storage_context, | 91 storage::BlobStorageContext* blob_storage_context, |
92 int process_id, | 92 int process_id, |
93 int provider_id, | 93 int provider_id, |
94 bool skip_service_worker, | 94 bool skip_service_worker, |
95 FetchRequestMode request_mode, | 95 FetchRequestMode request_mode, |
96 FetchCredentialsMode credentials_mode, | 96 FetchCredentialsMode credentials_mode, |
97 FetchRedirectMode redirect_mode, | 97 FetchRedirectMode redirect_mode, |
98 ResourceType resource_type, | 98 ResourceType resource_type, |
99 RequestContextType request_context_type, | 99 RequestContextType request_context_type, |
100 RequestContextFrameType frame_type, | 100 RequestContextFrameType frame_type, |
101 scoped_refptr<ResourceRequestBodyImpl> body); | 101 scoped_refptr<ResourceRequestBody> body); |
102 | 102 |
103 // Returns the handler attached to |request|. This may return NULL | 103 // Returns the handler attached to |request|. This may return NULL |
104 // if no handler is attached. | 104 // if no handler is attached. |
105 static ServiceWorkerRequestHandler* GetHandler( | 105 static ServiceWorkerRequestHandler* GetHandler( |
106 const net::URLRequest* request); | 106 const net::URLRequest* request); |
107 | 107 |
108 // Creates a protocol interceptor for ServiceWorker. | 108 // Creates a protocol interceptor for ServiceWorker. |
109 static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor( | 109 static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor( |
110 ResourceContext* resource_context); | 110 ResourceContext* resource_context); |
111 | 111 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; | 160 std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; |
161 int old_process_id_; | 161 int old_process_id_; |
162 int old_provider_id_; | 162 int old_provider_id_; |
163 | 163 |
164 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 164 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
165 }; | 165 }; |
166 | 166 |
167 } // namespace content | 167 } // namespace content |
168 | 168 |
169 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 169 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
OLD | NEW |