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

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

Issue 2703343002: ServiceWorker: Use mojo's data pipe for respondWith(stream) (Closed)
Patch Set: Rebase Created 3 years, 8 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_URL_REQUEST_JOB_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/optional.h" 18 #include "base/optional.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "content/browser/service_worker/embedded_worker_status.h" 20 #include "content/browser/service_worker/embedded_worker_status.h"
21 #include "content/browser/service_worker/service_worker_metrics.h" 21 #include "content/browser/service_worker/service_worker_metrics.h"
22 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
23 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
23 #include "content/common/service_worker/service_worker_status_code.h" 24 #include "content/common/service_worker/service_worker_status_code.h"
24 #include "content/common/service_worker/service_worker_types.h" 25 #include "content/common/service_worker/service_worker_types.h"
25 #include "content/public/common/request_context_frame_type.h" 26 #include "content/public/common/request_context_frame_type.h"
26 #include "content/public/common/request_context_type.h" 27 #include "content/public/common/request_context_type.h"
27 #include "content/public/common/resource_type.h" 28 #include "content/public/common/resource_type.h"
29 #include "mojo/public/cpp/system/data_pipe.h"
28 #include "net/http/http_byte_range.h" 30 #include "net/http/http_byte_range.h"
29 #include "net/url_request/url_request.h" 31 #include "net/url_request/url_request.h"
30 #include "net/url_request/url_request_job.h" 32 #include "net/url_request/url_request_job.h"
31 #include "net/url_request/url_request_status.h" 33 #include "net/url_request/url_request_status.h"
32 #include "storage/common/blob_storage/blob_storage_constants.h" 34 #include "storage/common/blob_storage/blob_storage_constants.h"
33 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerResponseType.h" 35 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerResponseType.h"
34 #include "url/gurl.h" 36 #include "url/gurl.h"
35 37
36 namespace net { 38 namespace net {
37 class IOBuffer; 39 class IOBuffer;
38 } // namespace net 40 } // namespace net
39 41
40 namespace storage { 42 namespace storage {
41 class BlobDataHandle; 43 class BlobDataHandle;
42 class BlobStorageContext; 44 class BlobStorageContext;
43 } // namespace storage 45 } // namespace storage
44 46
45 namespace content { 47 namespace content {
46 48
47 class ResourceContext; 49 class ResourceContext;
48 class ResourceRequestBodyImpl; 50 class ResourceRequestBodyImpl;
49 class ServiceWorkerBlobReader; 51 class ServiceWorkerBlobReader;
50 class ServiceWorkerStreamReader; 52 class ServiceWorkerDataPipeReader;
51 class ServiceWorkerFetchDispatcher; 53 class ServiceWorkerFetchDispatcher;
52 class ServiceWorkerVersion; 54 class ServiceWorkerVersion;
53 class Stream; 55 class Stream;
54 56
55 class CONTENT_EXPORT ServiceWorkerURLRequestJob : public net::URLRequestJob { 57 class CONTENT_EXPORT ServiceWorkerURLRequestJob : public net::URLRequestJob {
56 public: 58 public:
57 class CONTENT_EXPORT Delegate { 59 class CONTENT_EXPORT Delegate {
58 public: 60 public:
59 virtual ~Delegate() {} 61 virtual ~Delegate() {}
60 62
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // This must not be called until all files in |body_| with unknown size have 182 // This must not be called until all files in |body_| with unknown size have
181 // their sizes populated. 183 // their sizes populated.
182 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); 184 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size);
183 185
184 // For FORWARD_TO_SERVICE_WORKER case. 186 // For FORWARD_TO_SERVICE_WORKER case.
185 void DidPrepareFetchEvent(scoped_refptr<ServiceWorkerVersion> version); 187 void DidPrepareFetchEvent(scoped_refptr<ServiceWorkerVersion> version);
186 void DidDispatchFetchEvent( 188 void DidDispatchFetchEvent(
187 ServiceWorkerStatusCode status, 189 ServiceWorkerStatusCode status,
188 ServiceWorkerFetchEventResult fetch_result, 190 ServiceWorkerFetchEventResult fetch_result,
189 const ServiceWorkerResponse& response, 191 const ServiceWorkerResponse& response,
192 blink::mojom::ServiceWorkerStreamHandlePtr stream_handle,
190 const scoped_refptr<ServiceWorkerVersion>& version); 193 const scoped_refptr<ServiceWorkerVersion>& version);
191 void SetResponse(const ServiceWorkerResponse& response); 194 void SetResponse(const ServiceWorkerResponse& response);
192 195
193 // Populates |http_response_headers_|. 196 // Populates |http_response_headers_|.
194 void CreateResponseHeader(int status_code, 197 void CreateResponseHeader(int status_code,
195 const std::string& status_text, 198 const std::string& status_text,
196 const ServiceWorkerHeaderMap& headers); 199 const ServiceWorkerHeaderMap& headers);
197 200
198 // Creates |http_response_info_| using |http_response_headers_| and calls 201 // Creates |http_response_info_| using |http_response_headers_| and calls
199 // NotifyHeadersComplete. 202 // NotifyHeadersComplete.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Headers that have not yet been committed to |http_response_info_|. 298 // Headers that have not yet been committed to |http_response_info_|.
296 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; 299 scoped_refptr<net::HttpResponseHeaders> http_response_headers_;
297 std::vector<GURL> response_url_list_; 300 std::vector<GURL> response_url_list_;
298 blink::WebServiceWorkerResponseType service_worker_response_type_; 301 blink::WebServiceWorkerResponseType service_worker_response_type_;
299 302
300 // Used when response type is FORWARD_TO_SERVICE_WORKER. 303 // Used when response type is FORWARD_TO_SERVICE_WORKER.
301 std::unique_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; 304 std::unique_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_;
302 std::string client_id_; 305 std::string client_id_;
303 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; 306 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_;
304 const ResourceContext* resource_context_; 307 const ResourceContext* resource_context_;
305 // Only one of |blob_reader_| and |stream_reader_| can be non-null. 308 // Only one of |blob_reader_| and |data_pipe_reader_| can be non-null.
306 std::unique_ptr<ServiceWorkerBlobReader> blob_reader_; 309 std::unique_ptr<ServiceWorkerBlobReader> blob_reader_;
307 std::unique_ptr<ServiceWorkerStreamReader> stream_reader_; 310 std::unique_ptr<ServiceWorkerDataPipeReader> data_pipe_reader_;
308 311
309 FetchRequestMode request_mode_; 312 FetchRequestMode request_mode_;
310 FetchCredentialsMode credentials_mode_; 313 FetchCredentialsMode credentials_mode_;
311 FetchRedirectMode redirect_mode_; 314 FetchRedirectMode redirect_mode_;
312 const ResourceType resource_type_; 315 const ResourceType resource_type_;
313 RequestContextType request_context_type_; 316 RequestContextType request_context_type_;
314 RequestContextFrameType frame_type_; 317 RequestContextFrameType frame_type_;
315 bool fall_back_required_; 318 bool fall_back_required_;
316 // ResourceRequestBody has a collection of BlobDataHandles attached to it 319 // ResourceRequestBody has a collection of BlobDataHandles attached to it
317 // using the userdata mechanism. So we have to keep it not to free the blobs. 320 // using the userdata mechanism. So we have to keep it not to free the blobs.
(...skipping 13 matching lines...) Expand all
331 std::unique_ptr<FileSizeResolver> file_size_resolver_; 334 std::unique_ptr<FileSizeResolver> file_size_resolver_;
332 335
333 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; 336 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_;
334 337
335 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); 338 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob);
336 }; 339 };
337 340
338 } // namespace content 341 } // namespace content
339 342
340 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 343 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698