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

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

Issue 1985383002: Logging and check fail crbug/612358 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaned up logging Created 4 years, 7 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 <string> 11 #include <string>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "content/browser/service_worker/service_worker_metrics.h" 17 #include "content/browser/service_worker/service_worker_metrics.h"
18 #include "content/browser/streams/stream_read_observer.h" 18 #include "content/browser/streams/stream_read_observer.h"
19 #include "content/browser/streams/stream_register_observer.h" 19 #include "content/browser/streams/stream_register_observer.h"
20 #include "content/common/content_export.h" 20 #include "content/common/content_export.h"
21 #include "content/common/service_worker/service_worker_status_code.h" 21 #include "content/common/service_worker/service_worker_status_code.h"
22 #include "content/common/service_worker/service_worker_types.h" 22 #include "content/common/service_worker/service_worker_types.h"
23 #include "content/public/common/request_context_frame_type.h" 23 #include "content/public/common/request_context_frame_type.h"
24 #include "content/public/common/request_context_type.h" 24 #include "content/public/common/request_context_type.h"
25 #include "content/public/common/resource_type.h" 25 #include "content/public/common/resource_type.h"
26 #include "net/http/http_byte_range.h" 26 #include "net/http/http_byte_range.h"
27 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
28 #include "net/url_request/url_request_job.h" 28 #include "net/url_request/url_request_job.h"
29 #include "net/url_request/url_request_status.h" 29 #include "net/url_request/url_request_status.h"
30 #include "storage/common/blob_storage/blob_storage_constants.h"
30 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerResponseType.h" 31 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerResponseType.h"
31 #include "url/gurl.h" 32 #include "url/gurl.h"
32 33
33 namespace net { 34 namespace net {
34 class IOBuffer; 35 class IOBuffer;
35 } 36 }
36 37
37 namespace storage { 38 namespace storage {
38 class BlobDataHandle; 39 class BlobDataHandle;
39 class BlobStorageContext; 40 class BlobStorageContext;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 143
143 // StreamObserver override: 144 // StreamObserver override:
144 void OnDataAvailable(Stream* stream) override; 145 void OnDataAvailable(Stream* stream) override;
145 146
146 // StreamRegisterObserver override: 147 // StreamRegisterObserver override:
147 void OnStreamRegistered(Stream* stream) override; 148 void OnStreamRegistered(Stream* stream) override;
148 149
149 base::WeakPtr<ServiceWorkerURLRequestJob> GetWeakPtr(); 150 base::WeakPtr<ServiceWorkerURLRequestJob> GetWeakPtr();
150 151
151 private: 152 private:
153 class BlobConstructionWaiter;
154
152 enum ResponseType { 155 enum ResponseType {
153 NOT_DETERMINED, 156 NOT_DETERMINED,
154 FALLBACK_TO_NETWORK, 157 FALLBACK_TO_NETWORK,
155 FORWARD_TO_SERVICE_WORKER, 158 FORWARD_TO_SERVICE_WORKER,
156 }; 159 };
157 160
158 enum ResponseBodyType { 161 enum ResponseBodyType {
159 UNKNOWN, 162 UNKNOWN,
160 BLOB, 163 BLOB,
161 STREAM, 164 STREAM,
162 }; 165 };
163 166
164 // We start processing the request if Start() is called AND response_type_ 167 // We start processing the request if Start() is called AND response_type_
165 // is determined. 168 // is determined.
166 void MaybeStartRequest(); 169 void MaybeStartRequest();
167 void StartRequest(); 170 void StartRequest();
168 171
169 // Creates ServiceWorkerFetchRequest from |request_| and |body_|. 172 // Creates ServiceWorkerFetchRequest from |request_| and |body_|.
170 std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); 173 std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest();
171 174
172 // Creates BlobDataHandle of the request body from |body_|. This handle 175 // Creates BlobDataHandle of the request body from |body_|. This handle
173 // |request_body_blob_data_handle_| will be deleted when 176 // |request_body_blob_data_handle_| will be deleted when
174 // ServiceWorkerURLRequestJob is deleted. 177 // ServiceWorkerURLRequestJob is deleted.
175 bool CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); 178 // This must not be called until all blobs in |body_| finished construction.
179 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size);
176 180
177 // For FORWARD_TO_SERVICE_WORKER case. 181 // For FORWARD_TO_SERVICE_WORKER case.
178 void DidPrepareFetchEvent(); 182 void DidPrepareFetchEvent();
179 void DidDispatchFetchEvent( 183 void DidDispatchFetchEvent(
180 ServiceWorkerStatusCode status, 184 ServiceWorkerStatusCode status,
181 ServiceWorkerFetchEventResult fetch_result, 185 ServiceWorkerFetchEventResult fetch_result,
182 const ServiceWorkerResponse& response, 186 const ServiceWorkerResponse& response,
183 const scoped_refptr<ServiceWorkerVersion>& version); 187 const scoped_refptr<ServiceWorkerVersion>& version);
184 188
185 // Populates |http_response_headers_|. 189 // Populates |http_response_headers_|.
(...skipping 24 matching lines...) Expand all
210 void NotifyHeadersComplete(); 214 void NotifyHeadersComplete();
211 void NotifyStartError(net::URLRequestStatus status); 215 void NotifyStartError(net::URLRequestStatus status);
212 void NotifyRestartRequired(); 216 void NotifyRestartRequired();
213 217
214 // Wrapper that gathers parameters to |on_start_completed_callback_| and then 218 // Wrapper that gathers parameters to |on_start_completed_callback_| and then
215 // calls it. 219 // calls it.
216 void OnStartCompleted() const; 220 void OnStartCompleted() const;
217 221
218 bool IsMainResourceLoad() const; 222 bool IsMainResourceLoad() const;
219 223
224 // For waiting for request body blobs to finish construction.
225 bool HasRequestBody();
226 void RequestBodyBlobsCompleted(bool success);
227
220 // Not owned. 228 // Not owned.
221 Delegate* delegate_; 229 Delegate* delegate_;
222 230
223 // Timing info to show on the popup in Devtools' Network tab. 231 // Timing info to show on the popup in Devtools' Network tab.
224 net::LoadTimingInfo load_timing_info_; 232 net::LoadTimingInfo load_timing_info_;
225 base::TimeTicks worker_start_time_; 233 base::TimeTicks worker_start_time_;
226 base::TimeTicks worker_ready_time_; 234 base::TimeTicks worker_ready_time_;
227 base::Time response_time_; 235 base::Time response_time_;
228 236
229 ResponseType response_type_; 237 ResponseType response_type_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 std::unique_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; 269 std::unique_ptr<storage::BlobDataHandle> request_body_blob_data_handle_;
262 scoped_refptr<ServiceWorkerVersion> streaming_version_; 270 scoped_refptr<ServiceWorkerVersion> streaming_version_;
263 ServiceWorkerFetchType fetch_type_; 271 ServiceWorkerFetchType fetch_type_;
264 272
265 ResponseBodyType response_body_type_ = UNKNOWN; 273 ResponseBodyType response_body_type_ = UNKNOWN;
266 bool did_record_result_ = false; 274 bool did_record_result_ = false;
267 275
268 bool response_is_in_cache_storage_ = false; 276 bool response_is_in_cache_storage_ = false;
269 std::string response_cache_storage_cache_name_; 277 std::string response_cache_storage_cache_name_;
270 278
279 std::unique_ptr<BlobConstructionWaiter> blob_construction_waiter_;
280
271 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; 281 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_;
272 282
273 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); 283 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob);
274 }; 284 };
275 285
276 } // namespace content 286 } // namespace content
277 287
278 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 288 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698