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