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

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

Issue 759203002: [ServiceWorker] Make Stream support in ServiceWorkerURLRequestJob (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated tyoshino and nhiroki's comment Created 6 years 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
tyoshino (SeeGerritForStatus) 2014/12/08 09:36:56 ref_counted.h
horo 2014/12/09 04:23:55 Done.
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "content/browser/streams/stream_read_observer.h"
14 #include "content/browser/streams/stream_register_observer.h"
13 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
14 #include "content/common/service_worker/service_worker_status_code.h" 16 #include "content/common/service_worker/service_worker_status_code.h"
15 #include "content/common/service_worker/service_worker_types.h" 17 #include "content/common/service_worker/service_worker_types.h"
16 #include "content/public/common/request_context_frame_type.h" 18 #include "content/public/common/request_context_frame_type.h"
17 #include "content/public/common/request_context_type.h" 19 #include "content/public/common/request_context_type.h"
18 #include "content/public/common/resource_type.h" 20 #include "content/public/common/resource_type.h"
19 #include "net/http/http_byte_range.h" 21 #include "net/http/http_byte_range.h"
20 #include "net/url_request/url_request.h" 22 #include "net/url_request/url_request.h"
21 #include "net/url_request/url_request_job.h" 23 #include "net/url_request/url_request_job.h"
22 #include "third_party/WebKit/public/platform/WebServiceWorkerResponseType.h" 24 #include "third_party/WebKit/public/platform/WebServiceWorkerResponseType.h"
tyoshino (SeeGerritForStatus) 2014/12/08 09:36:56 gurl.h
horo 2014/12/09 04:23:55 Done.
23 25
24 namespace storage { 26 namespace storage {
25 class BlobDataHandle; 27 class BlobDataHandle;
26 class BlobStorageContext; 28 class BlobStorageContext;
27 } 29 }
28 30
29 namespace content { 31 namespace content {
30 32
33 class ResourceContext;
31 class ResourceRequestBody; 34 class ResourceRequestBody;
32 class ServiceWorkerContextCore; 35 class ServiceWorkerContextCore;
33 class ServiceWorkerFetchDispatcher; 36 class ServiceWorkerFetchDispatcher;
34 class ServiceWorkerProviderHost; 37 class ServiceWorkerProviderHost;
38 class Stream;
35 39
36 class CONTENT_EXPORT ServiceWorkerURLRequestJob 40 class CONTENT_EXPORT ServiceWorkerURLRequestJob
37 : public net::URLRequestJob, 41 : public net::URLRequestJob,
38 public net::URLRequest::Delegate { 42 public net::URLRequest::Delegate,
43 public StreamReadObserver,
44 public StreamRegisterObserver {
39 public: 45 public:
40 ServiceWorkerURLRequestJob( 46 ServiceWorkerURLRequestJob(
41 net::URLRequest* request, 47 net::URLRequest* request,
42 net::NetworkDelegate* network_delegate, 48 net::NetworkDelegate* network_delegate,
43 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 49 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
44 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 50 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
51 const ResourceContext* resource_context,
45 FetchRequestMode request_mode, 52 FetchRequestMode request_mode,
46 FetchCredentialsMode credentials_mode, 53 FetchCredentialsMode credentials_mode,
47 RequestContextType request_context_type, 54 RequestContextType request_context_type,
48 RequestContextFrameType frame_type, 55 RequestContextFrameType frame_type,
49 scoped_refptr<ResourceRequestBody> body); 56 scoped_refptr<ResourceRequestBody> body);
50 57
51 // Sets the response type. 58 // Sets the response type.
52 void FallbackToNetwork(); 59 void FallbackToNetwork();
53 void ForwardToServiceWorker(); 60 void ForwardToServiceWorker();
54 61
(...skipping 26 matching lines...) Expand all
81 void OnCertificateRequested( 88 void OnCertificateRequested(
82 net::URLRequest* request, 89 net::URLRequest* request,
83 net::SSLCertRequestInfo* cert_request_info) override; 90 net::SSLCertRequestInfo* cert_request_info) override;
84 void OnSSLCertificateError(net::URLRequest* request, 91 void OnSSLCertificateError(net::URLRequest* request,
85 const net::SSLInfo& ssl_info, 92 const net::SSLInfo& ssl_info,
86 bool fatal) override; 93 bool fatal) override;
87 void OnBeforeNetworkStart(net::URLRequest* request, bool* defer) override; 94 void OnBeforeNetworkStart(net::URLRequest* request, bool* defer) override;
88 void OnResponseStarted(net::URLRequest* request) override; 95 void OnResponseStarted(net::URLRequest* request) override;
89 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; 96 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
90 97
98 // StreamObserver override:
99 void OnDataAvailable(Stream* stream) override;
100
101 // StreamRegisterObserver override:
102 void OnStreamRegistered(Stream* stream) override;
103
91 const net::HttpResponseInfo* http_info() const; 104 const net::HttpResponseInfo* http_info() const;
92 105
93 void GetExtraResponseInfo( 106 void GetExtraResponseInfo(
94 bool* was_fetched_via_service_worker, 107 bool* was_fetched_via_service_worker,
95 bool* was_fallback_required_by_service_worker, 108 bool* was_fallback_required_by_service_worker,
96 GURL* original_url_via_service_worker, 109 GURL* original_url_via_service_worker,
97 blink::WebServiceWorkerResponseType* response_type_via_service_worker, 110 blink::WebServiceWorkerResponseType* response_type_via_service_worker,
98 base::TimeTicks* fetch_start_time, 111 base::TimeTicks* fetch_start_time,
99 base::TimeTicks* fetch_ready_time, 112 base::TimeTicks* fetch_ready_time,
100 base::TimeTicks* fetch_end_time) const; 113 base::TimeTicks* fetch_end_time) const;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 scoped_ptr<net::HttpResponseInfo> range_response_info_; 169 scoped_ptr<net::HttpResponseInfo> range_response_info_;
157 scoped_ptr<net::HttpResponseInfo> http_response_info_; 170 scoped_ptr<net::HttpResponseInfo> http_response_info_;
158 // Headers that have not yet been committed to |http_response_info_|. 171 // Headers that have not yet been committed to |http_response_info_|.
159 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; 172 scoped_refptr<net::HttpResponseHeaders> http_response_headers_;
160 GURL response_url_; 173 GURL response_url_;
161 blink::WebServiceWorkerResponseType service_worker_response_type_; 174 blink::WebServiceWorkerResponseType service_worker_response_type_;
162 175
163 // Used when response type is FORWARD_TO_SERVICE_WORKER. 176 // Used when response type is FORWARD_TO_SERVICE_WORKER.
164 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; 177 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_;
165 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; 178 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_;
179 const ResourceContext* resource_context_;
166 scoped_ptr<net::URLRequest> blob_request_; 180 scoped_ptr<net::URLRequest> blob_request_;
181 scoped_refptr<Stream> stream_;
182 GURL waiting_stream_url_;
183 scoped_refptr<net::IOBuffer> stream_pending_buffer_;
tyoshino (SeeGerritForStatus) 2014/12/08 09:36:56 declare IOBuffer
horo 2014/12/09 04:23:55 Done.
184 int stream_pending_buffer_size_;
185
167 FetchRequestMode request_mode_; 186 FetchRequestMode request_mode_;
168 FetchCredentialsMode credentials_mode_; 187 FetchCredentialsMode credentials_mode_;
169 RequestContextType request_context_type_; 188 RequestContextType request_context_type_;
170 RequestContextFrameType frame_type_; 189 RequestContextFrameType frame_type_;
171 bool fall_back_required_; 190 bool fall_back_required_;
172 // ResourceRequestBody has a collection of BlobDataHandles attached to it 191 // ResourceRequestBody has a collection of BlobDataHandles attached to it
173 // using the userdata mechanism. So we have to keep it not to free the blobs. 192 // using the userdata mechanism. So we have to keep it not to free the blobs.
174 scoped_refptr<ResourceRequestBody> body_; 193 scoped_refptr<ResourceRequestBody> body_;
175 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; 194 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_;
176 195
177 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; 196 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_;
178 197
179 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); 198 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob);
180 }; 199 };
181 200
182 } // namespace content 201 } // namespace content
183 202
184 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 203 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698