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 <memory> | 11 #include <memory> |
13 #include <string> | 12 #include <string> |
14 #include <utility> | 13 #include <utility> |
15 #include <vector> | 14 #include <vector> |
16 | 15 |
17 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/files/file_util.h" |
18 #include "base/guid.h" | 18 #include "base/guid.h" |
19 #include "base/location.h" | 19 #include "base/location.h" |
20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/task_runner.h" |
| 23 #include "base/task_runner_util.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
23 #include "base/time/time.h" | 25 #include "base/time/time.h" |
24 #include "content/browser/resource_context_impl.h" | 26 #include "content/browser/resource_context_impl.h" |
25 #include "content/browser/service_worker/embedded_worker_instance.h" | 27 #include "content/browser/service_worker/embedded_worker_instance.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/streams/stream.h" | 31 #include "content/browser/streams/stream.h" |
30 #include "content/browser/streams/stream_context.h" | 32 #include "content/browser/streams/stream_context.h" |
31 #include "content/browser/streams/stream_registry.h" | 33 #include "content/browser/streams/stream_registry.h" |
32 #include "content/common/resource_request_body_impl.h" | 34 #include "content/common/resource_request_body_impl.h" |
33 #include "content/common/service_worker/service_worker_types.h" | 35 #include "content/common/service_worker/service_worker_types.h" |
34 #include "content/common/service_worker/service_worker_utils.h" | 36 #include "content/common/service_worker/service_worker_utils.h" |
35 #include "content/public/browser/blob_handle.h" | 37 #include "content/public/browser/blob_handle.h" |
| 38 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/browser/resource_request_info.h" | 39 #include "content/public/browser/resource_request_info.h" |
37 #include "content/public/browser/service_worker_context.h" | 40 #include "content/public/browser/service_worker_context.h" |
38 #include "content/public/common/referrer.h" | 41 #include "content/public/common/referrer.h" |
39 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
40 #include "net/http/http_request_headers.h" | 43 #include "net/http/http_request_headers.h" |
41 #include "net/http/http_response_headers.h" | 44 #include "net/http/http_response_headers.h" |
42 #include "net/http/http_response_info.h" | 45 #include "net/http/http_response_info.h" |
43 #include "net/http/http_util.h" | 46 #include "net/http/http_util.h" |
44 #include "net/log/net_log.h" | 47 #include "net/log/net_log.h" |
45 #include "storage/browser/blob/blob_data_builder.h" | 48 #include "storage/browser/blob/blob_data_builder.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_BLOB: | 101 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_BLOB: |
99 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_STREAM: | 102 case m::REQUEST_JOB_ERROR_DESTROYED_WITH_STREAM: |
100 // Invalid type. | 103 // Invalid type. |
101 case m::NUM_REQUEST_JOB_RESULT_TYPES: | 104 case m::NUM_REQUEST_JOB_RESULT_TYPES: |
102 NOTREACHED() << result; | 105 NOTREACHED() << result; |
103 } | 106 } |
104 NOTREACHED() << result; | 107 NOTREACHED() << result; |
105 return n::TYPE_FAILED; | 108 return n::TYPE_FAILED; |
106 } | 109 } |
107 | 110 |
| 111 int64_t GetFileSizeOnBlockingPool(const base::FilePath& path) { |
| 112 base::File::Info file_info; |
| 113 if (!base::GetFileInfo(path, &file_info)) |
| 114 return -1; |
| 115 return file_info.size; |
| 116 } |
| 117 |
| 118 bool PopulateUnknownFileLengths( |
| 119 std::vector<ResourceRequestBodyImpl::Element>* elements) { |
| 120 for (ResourceRequestBodyImpl::Element& element : *elements) { |
| 121 if (element.type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
| 122 element.length() == ResourceRequestBodyImpl::Element::kUnknownSize) { |
| 123 base::File::Info file_info; |
| 124 if (!base::GetFileInfo(element.path(), &file_info)) |
| 125 return false; |
| 126 |
| 127 element.SetToFilePathRange(element.path(), element.offset(), |
| 128 file_info.size, |
| 129 element.expected_modification_time()); |
| 130 } |
| 131 } |
| 132 return true; |
| 133 } |
| 134 |
108 } // namespace | 135 } // namespace |
109 | 136 |
110 class ServiceWorkerURLRequestJob::BlobConstructionWaiter { | 137 class ServiceWorkerURLRequestJob::FileSizeResolver { |
111 public: | 138 public: |
112 explicit BlobConstructionWaiter(ServiceWorkerURLRequestJob* owner) | 139 explicit FileSizeResolver(ServiceWorkerURLRequestJob* owner) |
113 : owner_(owner), weak_factory_(this) { | 140 : owner_(owner), weak_factory_(this) { |
114 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "BlobConstructionWaiter", this, | 141 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "BlobFilesWaiter", this, "URL", |
115 "URL", owner_->request()->url().spec()); | 142 owner_->request()->url().spec()); |
116 owner_->request()->net_log().BeginEvent( | 143 owner_->request()->net_log().BeginEvent( |
117 net::NetLog::TYPE_SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_BLOB); | 144 net::NetLog::TYPE_SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_FILES); |
118 } | 145 } |
119 | 146 |
120 ~BlobConstructionWaiter() { | 147 ~FileSizeResolver() { |
121 owner_->request()->net_log().EndEvent( | 148 owner_->request()->net_log().EndEvent( |
122 net::NetLog::TYPE_SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_BLOB, | 149 net::NetLog::TYPE_SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_FILES, |
123 net::NetLog::BoolCallback("success", phase_ == Phase::SUCCESS)); | 150 net::NetLog::BoolCallback("success", phase_ == Phase::SUCCESS)); |
124 TRACE_EVENT_ASYNC_END1("ServiceWorker", "BlobConstructionWaiter", this, | 151 TRACE_EVENT_ASYNC_END1("ServiceWorker", "BlobFilesWaiter", this, "Success", |
125 "Success", phase_ == Phase::SUCCESS); | 152 phase_ == Phase::SUCCESS); |
126 } | 153 } |
127 | 154 |
128 void RunOnComplete(const base::Callback<void(bool)>& callback) { | 155 void RunOnComplete(base::TaskRunner* file_runner, |
| 156 const base::Callback<void(bool)>& callback) { |
129 DCHECK_EQ(static_cast<int>(Phase::INITIAL), static_cast<int>(phase_)); | 157 DCHECK_EQ(static_cast<int>(Phase::INITIAL), static_cast<int>(phase_)); |
130 phase_ = Phase::WAITING; | 158 phase_ = Phase::WAITING; |
131 num_pending_request_body_blobs_ = 0; | 159 body_ = owner_->body_; |
132 callback_ = callback; | 160 callback_ = callback; |
133 | 161 |
134 for (const ResourceRequestBodyImpl::Element& element : | 162 bool needs_file_stats = false; |
135 *(owner_->body_->elements())) { | 163 size_t i = 0; |
136 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) | 164 for (const ResourceRequestBodyImpl::Element& element : *body_->elements()) { |
137 continue; | 165 if (element.type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
| 166 element.length() == ResourceRequestBodyImpl::Element::kUnknownSize) { |
| 167 needs_file_stats = true; |
138 | 168 |
139 std::unique_ptr<storage::BlobDataHandle> handle = | 169 PostTaskAndReplyWithResult( |
140 owner_->blob_storage_context_->GetBlobDataFromUUID( | 170 file_runner, FROM_HERE, |
141 element.blob_uuid()); | 171 base::Bind(&GetFileSizeOnBlockingPool, element.path()), |
142 if (handle->IsBroken()) { | 172 base::Bind(&ServiceWorkerURLRequestJob::FileSizeResolver:: |
143 Complete(false); | 173 OnFileSizeResolved, |
144 return; | 174 weak_factory_.GetWeakPtr(), i)); |
145 } | 175 } |
146 if (handle->IsBeingBuilt()) { | 176 i++; |
147 ++num_pending_request_body_blobs_; | |
148 handle->RunOnConstructionComplete( | |
149 base::Bind(&BlobConstructionWaiter::OneRequestBodyBlobCompleted, | |
150 weak_factory_.GetWeakPtr())); | |
151 } | |
152 } | 177 } |
153 | 178 |
154 if (num_pending_request_body_blobs_ == 0) | 179 if (!needs_file_stats) { |
155 Complete(true); | 180 Complete(true); |
| 181 return; |
| 182 } |
156 } | 183 } |
157 | 184 |
158 private: | 185 private: |
159 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; | 186 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; |
160 | 187 |
161 void OneRequestBodyBlobCompleted( | 188 void OnFileSizeResolved(int element_index, int64_t file_size) { |
162 bool success, | 189 bool success = file_size >= 0; |
163 storage::IPCBlobCreationCancelCode cancel_code) { | 190 if (success) { |
164 DCHECK_GT(num_pending_request_body_blobs_, 0UL); | 191 auto& element = (*body_->elements_mutable())[element_index]; |
| 192 element.SetToFilePathRange(element.path(), element.offset(), |
| 193 static_cast<uint64_t>(file_size), |
| 194 element.expected_modification_time()); |
| 195 --num_pending_file_size_tasks_; |
| 196 } else { |
| 197 num_pending_file_size_tasks_ = 0; |
| 198 } |
165 | 199 |
166 if (success) | 200 if (num_pending_file_size_tasks_) |
167 --num_pending_request_body_blobs_; | |
168 else | |
169 num_pending_request_body_blobs_ = 0; | |
170 | |
171 if (num_pending_request_body_blobs_ == 0) | |
172 Complete(success); | 201 Complete(success); |
173 } | 202 } |
174 | 203 |
175 void Complete(bool success) { | 204 void Complete(bool success) { |
176 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); | 205 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); |
177 phase_ = success ? Phase::SUCCESS : Phase::FAIL; | 206 phase_ = success ? Phase::SUCCESS : Phase::FAIL; |
178 // Destroys |this|. | 207 // Destroys |this|. |
179 callback_.Run(success); | 208 callback_.Run(success); |
180 } | 209 } |
181 | 210 |
182 // Owns and must outlive |this|. | 211 // Owns and must outlive |this|. |
183 ServiceWorkerURLRequestJob* owner_; | 212 ServiceWorkerURLRequestJob* owner_; |
184 | 213 |
185 scoped_refptr<ResourceRequestBodyImpl> body_; | 214 scoped_refptr<ResourceRequestBodyImpl> body_; |
186 base::Callback<void(bool)> callback_; | 215 base::Callback<void(bool)> callback_; |
187 size_t num_pending_request_body_blobs_ = 0; | |
188 Phase phase_ = Phase::INITIAL; | 216 Phase phase_ = Phase::INITIAL; |
189 base::WeakPtrFactory<BlobConstructionWaiter> weak_factory_; | 217 size_t num_pending_file_size_tasks_ = 0; |
| 218 base::WeakPtrFactory<FileSizeResolver> weak_factory_; |
190 | 219 |
191 DISALLOW_COPY_AND_ASSIGN(BlobConstructionWaiter); | 220 DISALLOW_COPY_AND_ASSIGN(FileSizeResolver); |
192 }; | 221 }; |
193 | 222 |
194 bool ServiceWorkerURLRequestJob::Delegate::RequestStillValid( | 223 bool ServiceWorkerURLRequestJob::Delegate::RequestStillValid( |
195 ServiceWorkerMetrics::URLRequestJobResult* result) { | 224 ServiceWorkerMetrics::URLRequestJobResult* result) { |
196 return true; | 225 return true; |
197 } | 226 } |
198 | 227 |
199 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 228 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
200 net::URLRequest* request, | 229 net::URLRequest* request, |
201 net::NetworkDelegate* network_delegate, | 230 net::NetworkDelegate* network_delegate, |
(...skipping 26 matching lines...) Expand all Loading... |
228 frame_type_(frame_type), | 257 frame_type_(frame_type), |
229 fall_back_required_(false), | 258 fall_back_required_(false), |
230 body_(body), | 259 body_(body), |
231 fetch_type_(fetch_type), | 260 fetch_type_(fetch_type), |
232 weak_factory_(this) { | 261 weak_factory_(this) { |
233 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; | 262 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; |
234 } | 263 } |
235 | 264 |
236 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { | 265 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { |
237 ClearStream(); | 266 ClearStream(); |
238 blob_construction_waiter_.reset(); | 267 file_size_resolver_.reset(); |
239 | 268 |
240 if (!ShouldRecordResult()) | 269 if (!ShouldRecordResult()) |
241 return; | 270 return; |
242 ServiceWorkerMetrics::URLRequestJobResult result = | 271 ServiceWorkerMetrics::URLRequestJobResult result = |
243 ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED; | 272 ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED; |
244 if (response_body_type_ == STREAM) | 273 if (response_body_type_ == STREAM) |
245 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM; | 274 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM; |
246 else if (response_body_type_ == BLOB) | 275 else if (response_body_type_ == BLOB) |
247 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB; | 276 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB; |
248 RecordResult(result); | 277 RecordResult(result); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 case FALLBACK_TO_NETWORK: | 544 case FALLBACK_TO_NETWORK: |
516 FinalizeFallbackToNetwork(); | 545 FinalizeFallbackToNetwork(); |
517 return; | 546 return; |
518 | 547 |
519 case FALLBACK_TO_RENDERER: | 548 case FALLBACK_TO_RENDERER: |
520 FinalizeFallbackToRenderer(); | 549 FinalizeFallbackToRenderer(); |
521 return; | 550 return; |
522 | 551 |
523 case FORWARD_TO_SERVICE_WORKER: | 552 case FORWARD_TO_SERVICE_WORKER: |
524 if (HasRequestBody()) { | 553 if (HasRequestBody()) { |
525 DCHECK(!blob_construction_waiter_); | 554 DCHECK(!file_size_resolver_); |
526 blob_construction_waiter_.reset(new BlobConstructionWaiter(this)); | 555 file_size_resolver_.reset(new FileSizeResolver(this)); |
527 blob_construction_waiter_->RunOnComplete( | 556 file_size_resolver_->RunOnComplete( |
| 557 BrowserThread::GetBlockingPool(), |
528 base::Bind(&ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted, | 558 base::Bind(&ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted, |
529 GetWeakPtr())); | 559 GetWeakPtr())); |
530 return; | 560 return; |
531 } | 561 } |
532 | 562 |
533 RequestBodyBlobsCompleted(true); | 563 RequestBodyBlobsCompleted(true); |
534 return; | 564 return; |
535 } | 565 } |
536 | 566 |
537 NOTREACHED(); | 567 NOTREACHED(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 request->referrer = | 605 request->referrer = |
576 Referrer(GURL(request_->referrer()), blink::WebReferrerPolicyDefault); | 606 Referrer(GURL(request_->referrer()), blink::WebReferrerPolicyDefault); |
577 } | 607 } |
578 request->fetch_type = fetch_type_; | 608 request->fetch_type = fetch_type_; |
579 return request; | 609 return request; |
580 } | 610 } |
581 | 611 |
582 void ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, | 612 void ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, |
583 uint64_t* blob_size) { | 613 uint64_t* blob_size) { |
584 DCHECK(HasRequestBody()); | 614 DCHECK(HasRequestBody()); |
585 // To ensure the blobs stick around until the end of the reading. | 615 const std::string uuid(base::GenerateGUID()); |
586 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles; | 616 storage::BlobDataBuilder blob_builder(uuid); |
587 std::vector<std::unique_ptr<storage::BlobDataSnapshot>> snapshots; | |
588 // TODO(dmurph): Allow blobs to be added below, so that the context can | |
589 // efficiently re-use blob items for the new blob. | |
590 std::vector<const ResourceRequestBodyImpl::Element*> resolved_elements; | |
591 for (const ResourceRequestBodyImpl::Element& element : (*body_->elements())) { | 617 for (const ResourceRequestBodyImpl::Element& element : (*body_->elements())) { |
592 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) { | 618 blob_builder.AppendIPCDataElement(element); |
593 resolved_elements.push_back(&element); | |
594 continue; | |
595 } | |
596 std::unique_ptr<storage::BlobDataHandle> handle = | |
597 blob_storage_context_->GetBlobDataFromUUID(element.blob_uuid()); | |
598 std::unique_ptr<storage::BlobDataSnapshot> snapshot = | |
599 handle->CreateSnapshot(); | |
600 if (snapshot->items().empty()) | |
601 continue; | |
602 const auto& items = snapshot->items(); | |
603 for (const auto& item : items) { | |
604 DCHECK_NE(storage::DataElement::TYPE_BLOB, item->type()); | |
605 resolved_elements.push_back(item->data_element_ptr()); | |
606 } | |
607 handles.push_back(std::move(handle)); | |
608 snapshots.push_back(std::move(snapshot)); | |
609 } | |
610 | |
611 const std::string uuid(base::GenerateGUID()); | |
612 uint64_t total_size = 0; | |
613 | |
614 storage::BlobDataBuilder blob_builder(uuid); | |
615 for (size_t i = 0; i < resolved_elements.size(); ++i) { | |
616 const ResourceRequestBodyImpl::Element& element = *resolved_elements[i]; | |
617 if (total_size != std::numeric_limits<uint64_t>::max() && | |
618 element.length() != std::numeric_limits<uint64_t>::max()) | |
619 total_size += element.length(); | |
620 else | |
621 total_size = std::numeric_limits<uint64_t>::max(); | |
622 switch (element.type()) { | |
623 case ResourceRequestBodyImpl::Element::TYPE_BYTES: | |
624 blob_builder.AppendData(element.bytes(), element.length()); | |
625 break; | |
626 case ResourceRequestBodyImpl::Element::TYPE_FILE: | |
627 blob_builder.AppendFile(element.path(), element.offset(), | |
628 element.length(), | |
629 element.expected_modification_time()); | |
630 break; | |
631 case ResourceRequestBodyImpl::Element::TYPE_BLOB: | |
632 // Blob elements should be resolved beforehand. | |
633 NOTREACHED(); | |
634 break; | |
635 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM: | |
636 blob_builder.AppendFileSystemFile(element.filesystem_url(), | |
637 element.offset(), element.length(), | |
638 element.expected_modification_time()); | |
639 break; | |
640 default: | |
641 NOTIMPLEMENTED(); | |
642 } | |
643 } | 619 } |
644 | 620 |
645 request_body_blob_data_handle_ = | 621 request_body_blob_data_handle_ = |
646 blob_storage_context_->AddFinishedBlob(&blob_builder); | 622 blob_storage_context_->AddFinishedBlob(&blob_builder); |
647 *blob_uuid = uuid; | 623 *blob_uuid = blob_builder.uuid(); |
648 *blob_size = total_size; | 624 *blob_size = request_body_blob_data_handle_->size(); |
649 } | 625 } |
650 | 626 |
651 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent( | 627 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent( |
652 scoped_refptr<ServiceWorkerVersion> version) { | 628 scoped_refptr<ServiceWorkerVersion> version) { |
653 worker_ready_time_ = base::TimeTicks::Now(); | 629 worker_ready_time_ = base::TimeTicks::Now(); |
654 load_timing_info_.send_start = worker_ready_time_; | 630 load_timing_info_.send_start = worker_ready_time_; |
655 | 631 |
656 // Record the time taken for the browser to find and possibly start an active | 632 // Record the time taken for the browser to find and possibly start an active |
657 // worker to which to dispatch a FetchEvent for a main frame resource request. | 633 // worker to which to dispatch a FetchEvent for a main frame resource request. |
658 // For context, a FetchEvent can only be dispatched to an ACTIVATED worker | 634 // For context, a FetchEvent can only be dispatched to an ACTIVATED worker |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 return ServiceWorkerUtils::IsMainResourceType(resource_type_); | 976 return ServiceWorkerUtils::IsMainResourceType(resource_type_); |
1001 } | 977 } |
1002 | 978 |
1003 bool ServiceWorkerURLRequestJob::HasRequestBody() { | 979 bool ServiceWorkerURLRequestJob::HasRequestBody() { |
1004 // URLRequest::has_upload() must be checked since its upload data may have | 980 // URLRequest::has_upload() must be checked since its upload data may have |
1005 // been cleared while handling a redirect. | 981 // been cleared while handling a redirect. |
1006 return request_->has_upload() && body_.get() && blob_storage_context_; | 982 return request_->has_upload() && body_.get() && blob_storage_context_; |
1007 } | 983 } |
1008 | 984 |
1009 void ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted(bool success) { | 985 void ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted(bool success) { |
1010 blob_construction_waiter_.reset(); | 986 file_size_resolver_.reset(); |
1011 if (!success) { | 987 if (!success) { |
1012 RecordResult( | 988 RecordResult( |
1013 ServiceWorkerMetrics::REQUEST_JOB_ERROR_REQUEST_BODY_BLOB_FAILED); | 989 ServiceWorkerMetrics::REQUEST_JOB_ERROR_REQUEST_BODY_BLOB_FAILED); |
1014 // TODO(falken): This and below should probably be NotifyStartError, not | 990 // TODO(falken): This and below should probably be NotifyStartError, not |
1015 // DeliverErrorResponse. But changing it causes | 991 // DeliverErrorResponse. But changing it causes |
1016 // ServiceWorkerURLRequestJobTest.DeletedProviderHostBeforeFetchEvent to | 992 // ServiceWorkerURLRequestJobTest.DeletedProviderHostBeforeFetchEvent to |
1017 // fail. | 993 // fail. |
1018 DeliverErrorResponse(); | 994 DeliverErrorResponse(); |
1019 return; | 995 return; |
1020 } | 996 } |
(...skipping 17 matching lines...) Expand all Loading... |
1038 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(), | 1014 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(), |
1039 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | 1015 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, |
1040 weak_factory_.GetWeakPtr(), active_worker), | 1016 weak_factory_.GetWeakPtr(), active_worker), |
1041 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 1017 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
1042 weak_factory_.GetWeakPtr()))); | 1018 weak_factory_.GetWeakPtr()))); |
1043 worker_start_time_ = base::TimeTicks::Now(); | 1019 worker_start_time_ = base::TimeTicks::Now(); |
1044 fetch_dispatcher_->Run(); | 1020 fetch_dispatcher_->Run(); |
1045 } | 1021 } |
1046 | 1022 |
1047 } // namespace content | 1023 } // namespace content |
OLD | NEW |