| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_job_wrapper.h" | 5 #include "content/browser/service_worker/service_worker_url_job_wrapper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/service_worker/service_worker_response_type.h" | 8 #include "content/browser/service_worker/service_worker_response_type.h" |
| 9 #include "content/browser/service_worker/service_worker_version.h" | 9 #include "content/browser/service_worker/service_worker_version.h" |
| 10 #include "content/common/service_worker/service_worker_utils.h" | 10 #include "content/common/service_worker/service_worker_utils.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/resource_request_info.h" | 12 #include "content/public/browser/resource_request_info.h" |
| 13 #include "content/public/common/browser_side_navigation_policy.h" | 13 #include "content/public/common/browser_side_navigation_policy.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "mojo/public/cpp/bindings/strong_associated_binding.h" | 15 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 17 #include "storage/browser/blob/blob_storage_context.h" | 17 #include "storage/browser/blob/blob_storage_context.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class URLLoaderImpl : public mojom::URLLoader { | 23 class URLLoaderImpl : public mojom::URLLoader { |
| 24 public: | 24 public: |
| 25 static void Start( | 25 static void Start( |
| 26 const ServiceWorkerResponse& response, | 26 const ServiceWorkerResponse& response, |
| 27 blink::mojom::ServiceWorkerStreamHandlePtr body_as_stream, | 27 blink::mojom::ServiceWorkerStreamHandlePtr body_as_stream, |
| 28 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 28 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 29 mojom::URLLoaderAssociatedRequest request, | 29 mojom::URLLoaderRequest request, |
| 30 mojom::URLLoaderClientPtr client) { | 30 mojom::URLLoaderClientPtr client) { |
| 31 mojo::MakeStrongAssociatedBinding( | 31 mojo::MakeStrongBinding(base::MakeUnique<URLLoaderImpl>( |
| 32 base::MakeUnique<URLLoaderImpl>(response, std::move(body_as_stream), | 32 response, std::move(body_as_stream), |
| 33 blob_storage_context, | 33 blob_storage_context, std::move(client)), |
| 34 std::move(client)), | 34 std::move(request)); |
| 35 std::move(request)); | |
| 36 } | 35 } |
| 37 | 36 |
| 38 URLLoaderImpl(const ServiceWorkerResponse& response, | 37 URLLoaderImpl(const ServiceWorkerResponse& response, |
| 39 blink::mojom::ServiceWorkerStreamHandlePtr body_as_stream, | 38 blink::mojom::ServiceWorkerStreamHandlePtr body_as_stream, |
| 40 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 39 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 41 mojom::URLLoaderClientPtr url_loader_client) | 40 mojom::URLLoaderClientPtr url_loader_client) |
| 42 : blob_storage_context_(blob_storage_context), | 41 : blob_storage_context_(blob_storage_context), |
| 43 url_loader_client_(std::move(url_loader_client)), | 42 url_loader_client_(std::move(url_loader_client)), |
| 44 weak_factory_(this) { | 43 weak_factory_(this) { |
| 45 ResourceResponseHead head; | 44 ResourceResponseHead head; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 return; | 278 return; |
| 280 } | 279 } |
| 281 DCHECK_EQ(fetch_result, SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE); | 280 DCHECK_EQ(fetch_result, SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE); |
| 282 std::move(loader_callback_) | 281 std::move(loader_callback_) |
| 283 .Run(base::Bind(&URLLoaderImpl::Start, response, | 282 .Run(base::Bind(&URLLoaderImpl::Start, response, |
| 284 base::Passed(std::move(body_as_stream)), | 283 base::Passed(std::move(body_as_stream)), |
| 285 blob_storage_context_)); | 284 blob_storage_context_)); |
| 286 } | 285 } |
| 287 | 286 |
| 288 } // namespace content | 287 } // namespace content |
| OLD | NEW |