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 #include "content/browser/service_worker/service_worker_url_request_job.h" | 5 #include "content/browser/service_worker/service_worker_url_request_job.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | |
11 #include <map> | 10 #include <map> |
12 #include <string> | 11 #include <string> |
13 #include <utility> | 12 #include <utility> |
14 #include <vector> | 13 #include <vector> |
15 | 14 |
16 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/files/file_util.h" | |
17 #include "base/guid.h" | 17 #include "base/guid.h" |
18 #include "base/location.h" | 18 #include "base/location.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
21 #include "base/task_runner.h" | |
22 #include "base/task_runner_util.h" | |
21 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/time/time.h" | 24 #include "base/time/time.h" |
23 #include "content/browser/resource_context_impl.h" | 25 #include "content/browser/resource_context_impl.h" |
24 #include "content/browser/service_worker/embedded_worker_instance.h" | 26 #include "content/browser/service_worker/embedded_worker_instance.h" |
25 #include "content/browser/service_worker/service_worker_blob_reader.h" | 27 #include "content/browser/service_worker/service_worker_blob_reader.h" |
26 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 28 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
27 #include "content/browser/service_worker/service_worker_provider_host.h" | 29 #include "content/browser/service_worker/service_worker_provider_host.h" |
28 #include "content/browser/service_worker/service_worker_response_info.h" | 30 #include "content/browser/service_worker/service_worker_response_info.h" |
29 #include "content/browser/service_worker/service_worker_stream_reader.h" | 31 #include "content/browser/service_worker/service_worker_stream_reader.h" |
30 #include "content/common/resource_request_body_impl.h" | 32 #include "content/common/resource_request_body_impl.h" |
31 #include "content/common/service_worker/service_worker_types.h" | 33 #include "content/common/service_worker/service_worker_types.h" |
32 #include "content/common/service_worker/service_worker_utils.h" | 34 #include "content/common/service_worker/service_worker_utils.h" |
33 #include "content/public/browser/blob_handle.h" | 35 #include "content/public/browser/blob_handle.h" |
36 #include "content/public/browser/browser_thread.h" | |
34 #include "content/public/browser/resource_request_info.h" | 37 #include "content/public/browser/resource_request_info.h" |
35 #include "content/public/browser/service_worker_context.h" | 38 #include "content/public/browser/service_worker_context.h" |
36 #include "content/public/common/referrer.h" | 39 #include "content/public/common/referrer.h" |
37 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
38 #include "net/http/http_request_headers.h" | 41 #include "net/http/http_request_headers.h" |
39 #include "net/http/http_response_headers.h" | 42 #include "net/http/http_response_headers.h" |
40 #include "net/http/http_response_info.h" | 43 #include "net/http/http_response_info.h" |
41 #include "net/http/http_util.h" | 44 #include "net/http/http_util.h" |
42 #include "net/log/net_log.h" | 45 #include "net/log/net_log.h" |
43 #include "net/log/net_log_event_type.h" | 46 #include "net/log/net_log_event_type.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_BLOB: | 100 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_BLOB: |
98 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_STREAM: | 101 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_STREAM: |
99 // Invalid type. | 102 // Invalid type. |
100 case m::NUM_REQUEST_JOB_RESULT_TYPES: | 103 case m::NUM_REQUEST_JOB_RESULT_TYPES: |
101 NOTREACHED() << result; | 104 NOTREACHED() << result; |
102 } | 105 } |
103 NOTREACHED() << result; | 106 NOTREACHED() << result; |
104 return n::FAILED; | 107 return n::FAILED; |
105 } | 108 } |
106 | 109 |
110 std::vector<int64_t> GetFileSizesOnBlockingPool( | |
111 std::vector<base::FilePath> file_paths) { | |
112 std::vector<int64_t> sizes; | |
113 sizes.reserve(file_paths.size()); | |
114 for (const base::FilePath& path : file_paths) { | |
115 base::File::Info file_info; | |
116 if (!base::GetFileInfo(path, &file_info) || file_info.is_directory) | |
117 return std::vector<int64_t>(); | |
118 sizes.push_back(file_info.size); | |
119 } | |
120 return sizes; | |
121 } | |
122 | |
107 } // namespace | 123 } // namespace |
108 | 124 |
109 class ServiceWorkerURLRequestJob::BlobConstructionWaiter { | 125 // Sets the size on each DataElement in the request body that is a file with |
126 // unknown size. This ensures ServiceWorkerURLRequestJob::CreateRequestBodyBlob | |
127 // can successfuly create a blob from the data elements, as files with unknown | |
128 // sizes are not supported by the blob storage system. | |
129 class ServiceWorkerURLRequestJob::FileSizeResolver { | |
110 public: | 130 public: |
111 explicit BlobConstructionWaiter(ServiceWorkerURLRequestJob* owner) | 131 explicit FileSizeResolver(ServiceWorkerURLRequestJob* owner) |
112 : owner_(owner), weak_factory_(this) { | 132 : owner_(owner), weak_factory_(this) { |
113 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "BlobConstructionWaiter", this, | 133 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "FileSizeResolver", this, "URL", |
114 "URL", owner_->request()->url().spec()); | 134 owner_->request()->url().spec()); |
115 owner_->request()->net_log().BeginEvent( | 135 owner_->request()->net_log().BeginEvent( |
116 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_BLOB); | 136 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_FILES); |
117 } | 137 } |
118 | 138 |
119 ~BlobConstructionWaiter() { | 139 ~FileSizeResolver() { |
120 owner_->request()->net_log().EndEvent( | 140 owner_->request()->net_log().EndEvent( |
121 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_BLOB, | 141 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_FILES, |
122 net::NetLog::BoolCallback("success", phase_ == Phase::SUCCESS)); | 142 net::NetLog::BoolCallback("success", phase_ == Phase::SUCCESS)); |
123 TRACE_EVENT_ASYNC_END1("ServiceWorker", "BlobConstructionWaiter", this, | 143 TRACE_EVENT_ASYNC_END1("ServiceWorker", "FileSizeResolver", this, "Success", |
124 "Success", phase_ == Phase::SUCCESS); | 144 phase_ == Phase::SUCCESS); |
125 } | 145 } |
126 | 146 |
127 void RunOnComplete(const base::Callback<void(bool)>& callback) { | 147 void Resolve(base::TaskRunner* file_runner, |
148 const base::Callback<void(bool)>& callback) { | |
128 DCHECK_EQ(static_cast<int>(Phase::INITIAL), static_cast<int>(phase_)); | 149 DCHECK_EQ(static_cast<int>(Phase::INITIAL), static_cast<int>(phase_)); |
150 DCHECK(file_elements_.empty()); | |
129 phase_ = Phase::WAITING; | 151 phase_ = Phase::WAITING; |
130 num_pending_request_body_blobs_ = 0; | 152 body_ = owner_->body_; |
131 callback_ = callback; | 153 callback_ = callback; |
132 | 154 |
133 for (const ResourceRequestBodyImpl::Element& element : | 155 std::vector<base::FilePath> file_paths; |
134 *(owner_->body_->elements())) { | 156 for (ResourceRequestBodyImpl::Element& element : |
135 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) | 157 *body_->elements_mutable()) { |
136 continue; | 158 if (element.type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
137 | 159 element.length() == ResourceRequestBodyImpl::Element::kUnknownSize) { |
138 std::unique_ptr<storage::BlobDataHandle> handle = | 160 file_elements_.push_back(&element); |
139 owner_->blob_storage_context_->GetBlobDataFromUUID( | 161 file_paths.push_back(element.path()); |
140 element.blob_uuid()); | |
141 if (handle->IsBroken()) { | |
142 Complete(false); | |
143 return; | |
144 } | |
145 if (handle->IsBeingBuilt()) { | |
146 ++num_pending_request_body_blobs_; | |
147 handle->RunOnConstructionComplete( | |
148 base::Bind(&BlobConstructionWaiter::OneRequestBodyBlobCompleted, | |
149 weak_factory_.GetWeakPtr())); | |
150 } | 162 } |
151 } | 163 } |
164 if (file_elements_.empty()) { | |
165 Complete(true); | |
166 return; | |
167 } | |
152 | 168 |
153 if (num_pending_request_body_blobs_ == 0) | 169 PostTaskAndReplyWithResult( |
154 Complete(true); | 170 file_runner, FROM_HERE, |
171 base::Bind(&GetFileSizesOnBlockingPool, base::Passed(&file_paths)), | |
172 base::Bind( | |
173 &ServiceWorkerURLRequestJob::FileSizeResolver::OnFileSizesResolved, | |
174 weak_factory_.GetWeakPtr())); | |
155 } | 175 } |
156 | 176 |
157 private: | 177 private: |
158 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; | 178 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; |
159 | 179 |
160 void OneRequestBodyBlobCompleted( | 180 void OnFileSizesResolved(std::vector<int64_t> sizes) { |
161 bool success, | 181 bool success = !sizes.empty(); |
162 storage::IPCBlobCreationCancelCode cancel_code) { | 182 if (success) { |
163 DCHECK_GT(num_pending_request_body_blobs_, 0UL); | 183 DCHECK_EQ(sizes.size(), file_elements_.size()); |
164 | 184 size_t num_elements = file_elements_.size(); |
165 if (success) | 185 for (size_t i = 0; i < num_elements; i++) { |
166 --num_pending_request_body_blobs_; | 186 ResourceRequestBodyImpl::Element* element = file_elements_[i]; |
167 else | 187 element->SetToFilePathRange(element->path(), element->offset(), |
168 num_pending_request_body_blobs_ = 0; | 188 base::checked_cast<uint64_t>(sizes[i]), |
falken
2016/11/10 01:25:05
nit: i think you need to #include safe_conversions
dmurph
2016/11/10 19:53:19
Done.
| |
169 | 189 element->expected_modification_time()); |
170 if (num_pending_request_body_blobs_ == 0) | 190 } |
171 Complete(success); | 191 file_elements_.clear(); |
192 } | |
193 Complete(success); | |
172 } | 194 } |
173 | 195 |
174 void Complete(bool success) { | 196 void Complete(bool success) { |
175 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); | 197 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); |
176 phase_ = success ? Phase::SUCCESS : Phase::FAIL; | 198 phase_ = success ? Phase::SUCCESS : Phase::FAIL; |
177 // Destroys |this|. | 199 // Destroys |this|, so we make a copy of the callback. |
178 callback_.Run(success); | 200 base::Callback<void(bool)> callback = callback_; |
201 callback.Run(success); | |
179 } | 202 } |
180 | 203 |
181 // Owns and must outlive |this|. | 204 // Owns and must outlive |this|. |
182 ServiceWorkerURLRequestJob* owner_; | 205 ServiceWorkerURLRequestJob* owner_; |
183 | 206 |
184 scoped_refptr<ResourceRequestBodyImpl> body_; | 207 scoped_refptr<ResourceRequestBodyImpl> body_; |
208 std::vector<ResourceRequestBodyImpl::Element*> file_elements_; | |
185 base::Callback<void(bool)> callback_; | 209 base::Callback<void(bool)> callback_; |
186 size_t num_pending_request_body_blobs_ = 0; | |
187 Phase phase_ = Phase::INITIAL; | 210 Phase phase_ = Phase::INITIAL; |
188 base::WeakPtrFactory<BlobConstructionWaiter> weak_factory_; | 211 base::WeakPtrFactory<FileSizeResolver> weak_factory_; |
189 | 212 |
190 DISALLOW_COPY_AND_ASSIGN(BlobConstructionWaiter); | 213 DISALLOW_COPY_AND_ASSIGN(FileSizeResolver); |
191 }; | 214 }; |
192 | 215 |
193 bool ServiceWorkerURLRequestJob::Delegate::RequestStillValid( | 216 bool ServiceWorkerURLRequestJob::Delegate::RequestStillValid( |
194 ServiceWorkerMetrics::URLRequestJobResult* result) { | 217 ServiceWorkerMetrics::URLRequestJobResult* result) { |
195 return true; | 218 return true; |
196 } | 219 } |
197 | 220 |
198 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 221 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
199 net::URLRequest* request, | 222 net::URLRequest* request, |
200 net::NetworkDelegate* network_delegate, | 223 net::NetworkDelegate* network_delegate, |
(...skipping 25 matching lines...) Expand all Loading... | |
226 frame_type_(frame_type), | 249 frame_type_(frame_type), |
227 fall_back_required_(false), | 250 fall_back_required_(false), |
228 body_(body), | 251 body_(body), |
229 fetch_type_(fetch_type), | 252 fetch_type_(fetch_type), |
230 weak_factory_(this) { | 253 weak_factory_(this) { |
231 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; | 254 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; |
232 } | 255 } |
233 | 256 |
234 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { | 257 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { |
235 stream_reader_.reset(); | 258 stream_reader_.reset(); |
236 blob_construction_waiter_.reset(); | 259 file_size_resolver_.reset(); |
237 | 260 |
238 if (!ShouldRecordResult()) | 261 if (!ShouldRecordResult()) |
239 return; | 262 return; |
240 ServiceWorkerMetrics::URLRequestJobResult result = | 263 ServiceWorkerMetrics::URLRequestJobResult result = |
241 ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED; | 264 ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED; |
242 if (response_body_type_ == STREAM) | 265 if (response_body_type_ == STREAM) |
243 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM; | 266 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM; |
244 else if (response_body_type_ == BLOB) | 267 else if (response_body_type_ == BLOB) |
245 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB; | 268 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB; |
246 RecordResult(result); | 269 RecordResult(result); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 case FALLBACK_TO_NETWORK: | 426 case FALLBACK_TO_NETWORK: |
404 FinalizeFallbackToNetwork(); | 427 FinalizeFallbackToNetwork(); |
405 return; | 428 return; |
406 | 429 |
407 case FALLBACK_TO_RENDERER: | 430 case FALLBACK_TO_RENDERER: |
408 FinalizeFallbackToRenderer(); | 431 FinalizeFallbackToRenderer(); |
409 return; | 432 return; |
410 | 433 |
411 case FORWARD_TO_SERVICE_WORKER: | 434 case FORWARD_TO_SERVICE_WORKER: |
412 if (HasRequestBody()) { | 435 if (HasRequestBody()) { |
413 DCHECK(!blob_construction_waiter_); | 436 DCHECK(!file_size_resolver_); |
414 blob_construction_waiter_.reset(new BlobConstructionWaiter(this)); | 437 file_size_resolver_.reset(new FileSizeResolver(this)); |
415 blob_construction_waiter_->RunOnComplete( | 438 file_size_resolver_->Resolve( |
416 base::Bind(&ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted, | 439 BrowserThread::GetBlockingPool(), |
417 GetWeakPtr())); | 440 base::Bind( |
441 &ServiceWorkerURLRequestJob::RequestBodyFileSizesResolved, | |
442 GetWeakPtr())); | |
418 return; | 443 return; |
419 } | 444 } |
420 | 445 |
421 RequestBodyBlobsCompleted(true); | 446 RequestBodyFileSizesResolved(true); |
422 return; | 447 return; |
423 } | 448 } |
424 | 449 |
425 NOTREACHED(); | 450 NOTREACHED(); |
426 } | 451 } |
427 | 452 |
428 std::unique_ptr<ServiceWorkerFetchRequest> | 453 std::unique_ptr<ServiceWorkerFetchRequest> |
429 ServiceWorkerURLRequestJob::CreateFetchRequest() { | 454 ServiceWorkerURLRequestJob::CreateFetchRequest() { |
430 std::string blob_uuid; | 455 std::string blob_uuid; |
431 uint64_t blob_size = 0; | 456 uint64_t blob_size = 0; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 request->referrer = | 488 request->referrer = |
464 Referrer(GURL(request_->referrer()), blink::WebReferrerPolicyDefault); | 489 Referrer(GURL(request_->referrer()), blink::WebReferrerPolicyDefault); |
465 } | 490 } |
466 request->fetch_type = fetch_type_; | 491 request->fetch_type = fetch_type_; |
467 return request; | 492 return request; |
468 } | 493 } |
469 | 494 |
470 void ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, | 495 void ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, |
471 uint64_t* blob_size) { | 496 uint64_t* blob_size) { |
472 DCHECK(HasRequestBody()); | 497 DCHECK(HasRequestBody()); |
473 // To ensure the blobs stick around until the end of the reading. | 498 storage::BlobDataBuilder blob_builder(base::GenerateGUID()); |
474 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles; | |
475 std::vector<std::unique_ptr<storage::BlobDataSnapshot>> snapshots; | |
476 // TODO(dmurph): Allow blobs to be added below, so that the context can | |
477 // efficiently re-use blob items for the new blob. | |
478 std::vector<const ResourceRequestBodyImpl::Element*> resolved_elements; | |
479 for (const ResourceRequestBodyImpl::Element& element : (*body_->elements())) { | 499 for (const ResourceRequestBodyImpl::Element& element : (*body_->elements())) { |
480 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) { | 500 blob_builder.AppendIPCDataElement(element); |
481 resolved_elements.push_back(&element); | |
482 continue; | |
483 } | |
484 std::unique_ptr<storage::BlobDataHandle> handle = | |
485 blob_storage_context_->GetBlobDataFromUUID(element.blob_uuid()); | |
486 std::unique_ptr<storage::BlobDataSnapshot> snapshot = | |
487 handle->CreateSnapshot(); | |
488 if (snapshot->items().empty()) | |
489 continue; | |
490 const auto& items = snapshot->items(); | |
491 for (const auto& item : items) { | |
492 DCHECK_NE(storage::DataElement::TYPE_BLOB, item->type()); | |
493 resolved_elements.push_back(item->data_element_ptr()); | |
494 } | |
495 handles.push_back(std::move(handle)); | |
496 snapshots.push_back(std::move(snapshot)); | |
497 } | |
498 | |
499 const std::string uuid(base::GenerateGUID()); | |
500 uint64_t total_size = 0; | |
501 | |
502 storage::BlobDataBuilder blob_builder(uuid); | |
503 for (size_t i = 0; i < resolved_elements.size(); ++i) { | |
504 const ResourceRequestBodyImpl::Element& element = *resolved_elements[i]; | |
505 if (total_size != std::numeric_limits<uint64_t>::max() && | |
506 element.length() != std::numeric_limits<uint64_t>::max()) | |
507 total_size += element.length(); | |
508 else | |
509 total_size = std::numeric_limits<uint64_t>::max(); | |
510 switch (element.type()) { | |
511 case ResourceRequestBodyImpl::Element::TYPE_BYTES: | |
512 blob_builder.AppendData(element.bytes(), element.length()); | |
513 break; | |
514 case ResourceRequestBodyImpl::Element::TYPE_FILE: | |
515 blob_builder.AppendFile(element.path(), element.offset(), | |
516 element.length(), | |
517 element.expected_modification_time()); | |
518 break; | |
519 case ResourceRequestBodyImpl::Element::TYPE_BLOB: | |
520 // Blob elements should be resolved beforehand. | |
521 NOTREACHED(); | |
522 break; | |
523 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM: | |
524 blob_builder.AppendFileSystemFile(element.filesystem_url(), | |
525 element.offset(), element.length(), | |
526 element.expected_modification_time()); | |
527 break; | |
528 default: | |
529 NOTIMPLEMENTED(); | |
530 } | |
531 } | 501 } |
532 | 502 |
533 request_body_blob_data_handle_ = | 503 request_body_blob_data_handle_ = |
534 blob_storage_context_->AddFinishedBlob(&blob_builder); | 504 blob_storage_context_->AddFinishedBlob(&blob_builder); |
535 *blob_uuid = uuid; | 505 *blob_uuid = blob_builder.uuid(); |
536 *blob_size = total_size; | 506 *blob_size = request_body_blob_data_handle_->size(); |
537 } | 507 } |
538 | 508 |
539 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent( | 509 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent( |
540 scoped_refptr<ServiceWorkerVersion> version) { | 510 scoped_refptr<ServiceWorkerVersion> version) { |
541 worker_ready_time_ = base::TimeTicks::Now(); | 511 worker_ready_time_ = base::TimeTicks::Now(); |
542 load_timing_info_.send_start = worker_ready_time_; | 512 load_timing_info_.send_start = worker_ready_time_; |
543 | 513 |
544 // Record the time taken for the browser to find and possibly start an active | 514 // Record the time taken for the browser to find and possibly start an active |
545 // worker to which to dispatch a FetchEvent for a main frame resource request. | 515 // worker to which to dispatch a FetchEvent for a main frame resource request. |
546 // For context, a FetchEvent can only be dispatched to an ACTIVATED worker | 516 // For context, a FetchEvent can only be dispatched to an ACTIVATED worker |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 bool ServiceWorkerURLRequestJob::IsMainResourceLoad() const { | 814 bool ServiceWorkerURLRequestJob::IsMainResourceLoad() const { |
845 return ServiceWorkerUtils::IsMainResourceType(resource_type_); | 815 return ServiceWorkerUtils::IsMainResourceType(resource_type_); |
846 } | 816 } |
847 | 817 |
848 bool ServiceWorkerURLRequestJob::HasRequestBody() { | 818 bool ServiceWorkerURLRequestJob::HasRequestBody() { |
849 // URLRequest::has_upload() must be checked since its upload data may have | 819 // URLRequest::has_upload() must be checked since its upload data may have |
850 // been cleared while handling a redirect. | 820 // been cleared while handling a redirect. |
851 return request_->has_upload() && body_.get() && blob_storage_context_; | 821 return request_->has_upload() && body_.get() && blob_storage_context_; |
852 } | 822 } |
853 | 823 |
854 void ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted(bool success) { | 824 void ServiceWorkerURLRequestJob::RequestBodyFileSizesResolved(bool success) { |
855 blob_construction_waiter_.reset(); | 825 file_size_resolver_.reset(); |
856 if (!success) { | 826 if (!success) { |
857 RecordResult( | 827 RecordResult( |
858 ServiceWorkerMetrics::REQUEST_JOB_ERROR_REQUEST_BODY_BLOB_FAILED); | 828 ServiceWorkerMetrics::REQUEST_JOB_ERROR_REQUEST_BODY_BLOB_FAILED); |
859 // TODO(falken): This and below should probably be NotifyStartError, not | 829 // TODO(falken): This and below should probably be NotifyStartError, not |
860 // DeliverErrorResponse. But changing it causes | 830 // DeliverErrorResponse. But changing it causes |
861 // ServiceWorkerURLRequestJobTest.DeletedProviderHostBeforeFetchEvent to | 831 // ServiceWorkerURLRequestJobTest.DeletedProviderHostBeforeFetchEvent to |
862 // fail. | 832 // fail. |
863 DeliverErrorResponse(); | 833 DeliverErrorResponse(); |
864 return; | 834 return; |
865 } | 835 } |
(...skipping 18 matching lines...) Expand all Loading... | |
884 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | 854 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, |
885 weak_factory_.GetWeakPtr(), active_worker), | 855 weak_factory_.GetWeakPtr(), active_worker), |
886 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 856 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
887 weak_factory_.GetWeakPtr()))); | 857 weak_factory_.GetWeakPtr()))); |
888 worker_start_time_ = base::TimeTicks::Now(); | 858 worker_start_time_ = base::TimeTicks::Now(); |
889 fetch_dispatcher_->MaybeStartNavigationPreload(request()); | 859 fetch_dispatcher_->MaybeStartNavigationPreload(request()); |
890 fetch_dispatcher_->Run(); | 860 fetch_dispatcher_->Run(); |
891 } | 861 } |
892 | 862 |
893 } // namespace content | 863 } // namespace content |
OLD | NEW |