Chromium Code Reviews| 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)) | |
|
falken
2016/11/09 02:06:19
maybe paranoid but should we check file_info.is_di
dmurph
2016/11/09 19:13:27
Good idea. Done.
| |
| 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 class ServiceWorkerURLRequestJob::FileSizeResolver { |
|
falken
2016/11/09 02:06:19
Can we add a lightweight comment about what this c
dmurph
2016/11/09 19:13:27
Done.
| |
| 110 public: | 126 public: |
| 111 explicit BlobConstructionWaiter(ServiceWorkerURLRequestJob* owner) | 127 explicit FileSizeResolver(ServiceWorkerURLRequestJob* owner) |
| 112 : owner_(owner), weak_factory_(this) { | 128 : owner_(owner), weak_factory_(this) { |
| 113 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "BlobConstructionWaiter", this, | 129 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "BlobFilesWaiter", this, "URL", |
|
Marijn Kruisselbrink
2016/11/09 18:39:39
Is it intentional that you renamed the class to Fi
dmurph
2016/11/09 19:13:27
Done.
| |
| 114 "URL", owner_->request()->url().spec()); | 130 owner_->request()->url().spec()); |
| 115 owner_->request()->net_log().BeginEvent( | 131 owner_->request()->net_log().BeginEvent( |
| 116 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_BLOB); | 132 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_FILES); |
| 117 } | 133 } |
| 118 | 134 |
| 119 ~BlobConstructionWaiter() { | 135 ~FileSizeResolver() { |
| 120 owner_->request()->net_log().EndEvent( | 136 owner_->request()->net_log().EndEvent( |
| 121 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_BLOB, | 137 net::NetLogEventType::SERVICE_WORKER_WAITING_FOR_REQUEST_BODY_FILES, |
| 122 net::NetLog::BoolCallback("success", phase_ == Phase::SUCCESS)); | 138 net::NetLog::BoolCallback("success", phase_ == Phase::SUCCESS)); |
| 123 TRACE_EVENT_ASYNC_END1("ServiceWorker", "BlobConstructionWaiter", this, | 139 TRACE_EVENT_ASYNC_END1("ServiceWorker", "BlobFilesWaiter", this, "Success", |
| 124 "Success", phase_ == Phase::SUCCESS); | 140 phase_ == Phase::SUCCESS); |
| 125 } | 141 } |
| 126 | 142 |
| 127 void RunOnComplete(const base::Callback<void(bool)>& callback) { | 143 void RunOnComplete(base::TaskRunner* file_runner, |
|
falken
2016/11/09 02:06:19
This almost looks like the callback is run on the
dmurph
2016/11/09 19:13:26
Done.
| |
| 144 const base::Callback<void(bool)>& callback) { | |
| 128 DCHECK_EQ(static_cast<int>(Phase::INITIAL), static_cast<int>(phase_)); | 145 DCHECK_EQ(static_cast<int>(Phase::INITIAL), static_cast<int>(phase_)); |
| 146 DCHECK(file_elements_.empty()); | |
| 129 phase_ = Phase::WAITING; | 147 phase_ = Phase::WAITING; |
| 130 num_pending_request_body_blobs_ = 0; | 148 body_ = owner_->body_; |
| 131 callback_ = callback; | 149 callback_ = callback; |
| 132 | 150 |
| 133 for (const ResourceRequestBodyImpl::Element& element : | 151 std::vector<base::FilePath> file_paths; |
| 134 *(owner_->body_->elements())) { | 152 for (ResourceRequestBodyImpl::Element& element : |
| 135 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) | 153 *body_->elements_mutable()) { |
| 136 continue; | 154 if (element.type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
| 137 | 155 element.length() == ResourceRequestBodyImpl::Element::kUnknownSize) { |
| 138 std::unique_ptr<storage::BlobDataHandle> handle = | 156 file_elements_.push_back(&element); |
| 139 owner_->blob_storage_context_->GetBlobDataFromUUID( | 157 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 } | 158 } |
| 151 } | 159 } |
| 160 if (file_elements_.empty()) { | |
| 161 Complete(true); | |
| 162 return; | |
| 163 } | |
| 152 | 164 |
| 153 if (num_pending_request_body_blobs_ == 0) | 165 PostTaskAndReplyWithResult( |
| 154 Complete(true); | 166 file_runner, FROM_HERE, |
| 167 base::Bind(&GetFileSizesOnBlockingPool, base::Passed(&file_paths)), | |
| 168 base::Bind( | |
| 169 &ServiceWorkerURLRequestJob::FileSizeResolver::OnFileSizesResolved, | |
| 170 weak_factory_.GetWeakPtr())); | |
| 155 } | 171 } |
| 156 | 172 |
| 157 private: | 173 private: |
| 158 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; | 174 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; |
| 159 | 175 |
| 160 void OneRequestBodyBlobCompleted( | 176 void OnFileSizesResolved(std::vector<int64_t> sizes) { |
| 161 bool success, | 177 bool success = !sizes.empty(); |
| 162 storage::IPCBlobCreationCancelCode cancel_code) { | 178 if (success) { |
| 163 DCHECK_GT(num_pending_request_body_blobs_, 0UL); | 179 DCHECK_EQ(sizes.size(), file_elements_.size()); |
| 164 | 180 size_t num_elements = file_elements_.size(); |
| 165 if (success) | 181 for (size_t i = 0; i < num_elements; i++) { |
| 166 --num_pending_request_body_blobs_; | 182 auto* element = file_elements_[i]; |
|
falken
2016/11/09 02:06:19
nit: I prefer writing out ResourceRequestBodyImpl:
dmurph
2016/11/09 19:13:27
Done.
| |
| 167 else | 183 element->SetToFilePathRange(element->path(), element->offset(), |
| 168 num_pending_request_body_blobs_ = 0; | 184 static_cast<uint64_t>(sizes[i]), |
|
falken
2016/11/09 02:06:19
is it always ok to static_cast this? maybe paranoi
dmurph
2016/11/09 19:13:26
Done.
| |
| 169 | 185 element->expected_modification_time()); |
| 170 if (num_pending_request_body_blobs_ == 0) | 186 } |
| 171 Complete(success); | 187 file_elements_.clear(); |
| 188 } | |
| 189 Complete(success); | |
| 172 } | 190 } |
| 173 | 191 |
| 174 void Complete(bool success) { | 192 void Complete(bool success) { |
| 175 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); | 193 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); |
| 176 phase_ = success ? Phase::SUCCESS : Phase::FAIL; | 194 phase_ = success ? Phase::SUCCESS : Phase::FAIL; |
| 177 // Destroys |this|. | 195 // Destroys |this|. |
| 178 callback_.Run(success); | 196 callback_.Run(success); |
|
Marijn Kruisselbrink
2016/11/09 18:39:39
nit: if the callback can/does destroy |this|, it p
dmurph
2016/11/09 19:13:27
Ah good catch. I'll make a copy.
falken
2016/11/10 01:25:04
Good idea, thanks for pointing out this issue in t
| |
| 179 } | 197 } |
| 180 | 198 |
| 181 // Owns and must outlive |this|. | 199 // Owns and must outlive |this|. |
| 182 ServiceWorkerURLRequestJob* owner_; | 200 ServiceWorkerURLRequestJob* owner_; |
| 183 | 201 |
| 184 scoped_refptr<ResourceRequestBodyImpl> body_; | 202 scoped_refptr<ResourceRequestBodyImpl> body_; |
| 203 std::vector<ResourceRequestBodyImpl::Element*> file_elements_; | |
| 185 base::Callback<void(bool)> callback_; | 204 base::Callback<void(bool)> callback_; |
| 186 size_t num_pending_request_body_blobs_ = 0; | |
| 187 Phase phase_ = Phase::INITIAL; | 205 Phase phase_ = Phase::INITIAL; |
| 188 base::WeakPtrFactory<BlobConstructionWaiter> weak_factory_; | 206 base::WeakPtrFactory<FileSizeResolver> weak_factory_; |
| 189 | 207 |
| 190 DISALLOW_COPY_AND_ASSIGN(BlobConstructionWaiter); | 208 DISALLOW_COPY_AND_ASSIGN(FileSizeResolver); |
| 191 }; | 209 }; |
| 192 | 210 |
| 193 bool ServiceWorkerURLRequestJob::Delegate::RequestStillValid( | 211 bool ServiceWorkerURLRequestJob::Delegate::RequestStillValid( |
| 194 ServiceWorkerMetrics::URLRequestJobResult* result) { | 212 ServiceWorkerMetrics::URLRequestJobResult* result) { |
| 195 return true; | 213 return true; |
| 196 } | 214 } |
| 197 | 215 |
| 198 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 216 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
| 199 net::URLRequest* request, | 217 net::URLRequest* request, |
| 200 net::NetworkDelegate* network_delegate, | 218 net::NetworkDelegate* network_delegate, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 226 frame_type_(frame_type), | 244 frame_type_(frame_type), |
| 227 fall_back_required_(false), | 245 fall_back_required_(false), |
| 228 body_(body), | 246 body_(body), |
| 229 fetch_type_(fetch_type), | 247 fetch_type_(fetch_type), |
| 230 weak_factory_(this) { | 248 weak_factory_(this) { |
| 231 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; | 249 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; |
| 232 } | 250 } |
| 233 | 251 |
| 234 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { | 252 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { |
| 235 stream_reader_.reset(); | 253 stream_reader_.reset(); |
| 236 blob_construction_waiter_.reset(); | 254 file_size_resolver_.reset(); |
| 237 | 255 |
| 238 if (!ShouldRecordResult()) | 256 if (!ShouldRecordResult()) |
| 239 return; | 257 return; |
| 240 ServiceWorkerMetrics::URLRequestJobResult result = | 258 ServiceWorkerMetrics::URLRequestJobResult result = |
| 241 ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED; | 259 ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED; |
| 242 if (response_body_type_ == STREAM) | 260 if (response_body_type_ == STREAM) |
| 243 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM; | 261 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM; |
| 244 else if (response_body_type_ == BLOB) | 262 else if (response_body_type_ == BLOB) |
| 245 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB; | 263 result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB; |
| 246 RecordResult(result); | 264 RecordResult(result); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 case FALLBACK_TO_NETWORK: | 421 case FALLBACK_TO_NETWORK: |
| 404 FinalizeFallbackToNetwork(); | 422 FinalizeFallbackToNetwork(); |
| 405 return; | 423 return; |
| 406 | 424 |
| 407 case FALLBACK_TO_RENDERER: | 425 case FALLBACK_TO_RENDERER: |
| 408 FinalizeFallbackToRenderer(); | 426 FinalizeFallbackToRenderer(); |
| 409 return; | 427 return; |
| 410 | 428 |
| 411 case FORWARD_TO_SERVICE_WORKER: | 429 case FORWARD_TO_SERVICE_WORKER: |
| 412 if (HasRequestBody()) { | 430 if (HasRequestBody()) { |
| 413 DCHECK(!blob_construction_waiter_); | 431 DCHECK(!file_size_resolver_); |
| 414 blob_construction_waiter_.reset(new BlobConstructionWaiter(this)); | 432 file_size_resolver_.reset(new FileSizeResolver(this)); |
| 415 blob_construction_waiter_->RunOnComplete( | 433 file_size_resolver_->RunOnComplete( |
| 434 BrowserThread::GetBlockingPool(), | |
| 416 base::Bind(&ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted, | 435 base::Bind(&ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted, |
| 417 GetWeakPtr())); | 436 GetWeakPtr())); |
| 418 return; | 437 return; |
| 419 } | 438 } |
| 420 | 439 |
| 421 RequestBodyBlobsCompleted(true); | 440 RequestBodyBlobsCompleted(true); |
| 422 return; | 441 return; |
| 423 } | 442 } |
| 424 | 443 |
| 425 NOTREACHED(); | 444 NOTREACHED(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 request->referrer = | 482 request->referrer = |
| 464 Referrer(GURL(request_->referrer()), blink::WebReferrerPolicyDefault); | 483 Referrer(GURL(request_->referrer()), blink::WebReferrerPolicyDefault); |
| 465 } | 484 } |
| 466 request->fetch_type = fetch_type_; | 485 request->fetch_type = fetch_type_; |
| 467 return request; | 486 return request; |
| 468 } | 487 } |
| 469 | 488 |
| 470 void ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, | 489 void ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, |
| 471 uint64_t* blob_size) { | 490 uint64_t* blob_size) { |
| 472 DCHECK(HasRequestBody()); | 491 DCHECK(HasRequestBody()); |
| 473 // To ensure the blobs stick around until the end of the reading. | 492 const std::string uuid(base::GenerateGUID()); |
|
falken
2016/11/09 02:06:19
nit: we don't seem to use |uuid| later, and call b
dmurph
2016/11/09 19:13:27
Done.
| |
| 474 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles; | 493 storage::BlobDataBuilder blob_builder(uuid); |
| 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())) { | 494 for (const ResourceRequestBodyImpl::Element& element : (*body_->elements())) { |
| 480 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) { | 495 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 } | |
|
falken
2016/11/09 02:06:19
So happy about this deletion!
dmurph
2016/11/09 19:13:26
Eliminating this code was one of my goals for the
| |
| 531 } | 496 } |
| 532 | 497 |
| 533 request_body_blob_data_handle_ = | 498 request_body_blob_data_handle_ = |
| 534 blob_storage_context_->AddFinishedBlob(&blob_builder); | 499 blob_storage_context_->AddFinishedBlob(&blob_builder); |
| 535 *blob_uuid = uuid; | 500 *blob_uuid = blob_builder.uuid(); |
| 536 *blob_size = total_size; | 501 *blob_size = request_body_blob_data_handle_->size(); |
| 537 } | 502 } |
| 538 | 503 |
| 539 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent( | 504 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent( |
| 540 scoped_refptr<ServiceWorkerVersion> version) { | 505 scoped_refptr<ServiceWorkerVersion> version) { |
| 541 worker_ready_time_ = base::TimeTicks::Now(); | 506 worker_ready_time_ = base::TimeTicks::Now(); |
| 542 load_timing_info_.send_start = worker_ready_time_; | 507 load_timing_info_.send_start = worker_ready_time_; |
| 543 | 508 |
| 544 // Record the time taken for the browser to find and possibly start an active | 509 // 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. | 510 // 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 | 511 // For context, a FetchEvent can only be dispatched to an ACTIVATED worker |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 return ServiceWorkerUtils::IsMainResourceType(resource_type_); | 810 return ServiceWorkerUtils::IsMainResourceType(resource_type_); |
| 846 } | 811 } |
| 847 | 812 |
| 848 bool ServiceWorkerURLRequestJob::HasRequestBody() { | 813 bool ServiceWorkerURLRequestJob::HasRequestBody() { |
| 849 // URLRequest::has_upload() must be checked since its upload data may have | 814 // URLRequest::has_upload() must be checked since its upload data may have |
| 850 // been cleared while handling a redirect. | 815 // been cleared while handling a redirect. |
| 851 return request_->has_upload() && body_.get() && blob_storage_context_; | 816 return request_->has_upload() && body_.get() && blob_storage_context_; |
| 852 } | 817 } |
| 853 | 818 |
| 854 void ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted(bool success) { | 819 void ServiceWorkerURLRequestJob::RequestBodyBlobsCompleted(bool success) { |
| 855 blob_construction_waiter_.reset(); | 820 file_size_resolver_.reset(); |
| 856 if (!success) { | 821 if (!success) { |
| 857 RecordResult( | 822 RecordResult( |
| 858 ServiceWorkerMetrics::REQUEST_JOB_ERROR_REQUEST_BODY_BLOB_FAILED); | 823 ServiceWorkerMetrics::REQUEST_JOB_ERROR_REQUEST_BODY_BLOB_FAILED); |
| 859 // TODO(falken): This and below should probably be NotifyStartError, not | 824 // TODO(falken): This and below should probably be NotifyStartError, not |
| 860 // DeliverErrorResponse. But changing it causes | 825 // DeliverErrorResponse. But changing it causes |
| 861 // ServiceWorkerURLRequestJobTest.DeletedProviderHostBeforeFetchEvent to | 826 // ServiceWorkerURLRequestJobTest.DeletedProviderHostBeforeFetchEvent to |
| 862 // fail. | 827 // fail. |
| 863 DeliverErrorResponse(); | 828 DeliverErrorResponse(); |
| 864 return; | 829 return; |
| 865 } | 830 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 884 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | 849 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, |
| 885 weak_factory_.GetWeakPtr(), active_worker), | 850 weak_factory_.GetWeakPtr(), active_worker), |
| 886 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 851 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
| 887 weak_factory_.GetWeakPtr()))); | 852 weak_factory_.GetWeakPtr()))); |
| 888 worker_start_time_ = base::TimeTicks::Now(); | 853 worker_start_time_ = base::TimeTicks::Now(); |
| 889 fetch_dispatcher_->MaybeStartNavigationPreload(request()); | 854 fetch_dispatcher_->MaybeStartNavigationPreload(request()); |
| 890 fetch_dispatcher_->Run(); | 855 fetch_dispatcher_->Run(); |
| 891 } | 856 } |
| 892 | 857 |
| 893 } // namespace content | 858 } // namespace content |
| OLD | NEW |