| 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 <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/guid.h" | 12 #include "base/guid.h" |
| 13 #include "base/location.h" | |
| 14 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 15 #include "base/single_thread_task_runner.h" | |
| 16 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 17 #include "base/thread_task_runner_handle.h" | |
| 18 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 19 #include "content/browser/resource_context_impl.h" | 16 #include "content/browser/resource_context_impl.h" |
| 20 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 17 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
| 21 #include "content/browser/service_worker/service_worker_provider_host.h" | 18 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 22 #include "content/browser/streams/stream.h" | 19 #include "content/browser/streams/stream.h" |
| 23 #include "content/browser/streams/stream_context.h" | 20 #include "content/browser/streams/stream_context.h" |
| 24 #include "content/browser/streams/stream_registry.h" | 21 #include "content/browser/streams/stream_registry.h" |
| 25 #include "content/common/resource_request_body.h" | 22 #include "content/common/resource_request_body.h" |
| 26 #include "content/common/service_worker/service_worker_types.h" | 23 #include "content/common/service_worker/service_worker_types.h" |
| 27 #include "content/public/browser/blob_handle.h" | 24 #include "content/public/browser/blob_handle.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 313 } |
| 317 | 314 |
| 318 | 315 |
| 319 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { | 316 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { |
| 320 ClearStream(); | 317 ClearStream(); |
| 321 } | 318 } |
| 322 | 319 |
| 323 void ServiceWorkerURLRequestJob::MaybeStartRequest() { | 320 void ServiceWorkerURLRequestJob::MaybeStartRequest() { |
| 324 if (is_started_ && response_type_ != NOT_DETERMINED) { | 321 if (is_started_ && response_type_ != NOT_DETERMINED) { |
| 325 // Start asynchronously. | 322 // Start asynchronously. |
| 326 base::ThreadTaskRunnerHandle::Get()->PostTask( | 323 base::MessageLoop::current()->PostTask( |
| 327 FROM_HERE, base::Bind(&ServiceWorkerURLRequestJob::StartRequest, | 324 FROM_HERE, |
| 328 weak_factory_.GetWeakPtr())); | 325 base::Bind(&ServiceWorkerURLRequestJob::StartRequest, |
| 326 weak_factory_.GetWeakPtr())); |
| 329 } | 327 } |
| 330 } | 328 } |
| 331 | 329 |
| 332 void ServiceWorkerURLRequestJob::StartRequest() { | 330 void ServiceWorkerURLRequestJob::StartRequest() { |
| 333 switch (response_type_) { | 331 switch (response_type_) { |
| 334 case NOT_DETERMINED: | 332 case NOT_DETERMINED: |
| 335 NOTREACHED(); | 333 NOTREACHED(); |
| 336 return; | 334 return; |
| 337 | 335 |
| 338 case FALLBACK_TO_NETWORK: | 336 case FALLBACK_TO_NETWORK: |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 } | 644 } |
| 647 if (!waiting_stream_url_.is_empty()) { | 645 if (!waiting_stream_url_.is_empty()) { |
| 648 StreamRegistry* stream_registry = | 646 StreamRegistry* stream_registry = |
| 649 GetStreamContextForResourceContext(resource_context_)->registry(); | 647 GetStreamContextForResourceContext(resource_context_)->registry(); |
| 650 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 648 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
| 651 stream_registry->AbortPendingStream(waiting_stream_url_); | 649 stream_registry->AbortPendingStream(waiting_stream_url_); |
| 652 } | 650 } |
| 653 } | 651 } |
| 654 | 652 |
| 655 } // namespace content | 653 } // namespace content |
| OLD | NEW |