| 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_fetch_dispatcher.h" | 5 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 14 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 15 #include "content/browser/loader/resource_request_info_impl.h" | 15 #include "content/browser/loader/resource_request_info_impl.h" |
| 16 #include "content/browser/loader/resource_requester_info.h" | 16 #include "content/browser/loader/resource_requester_info.h" |
| 17 #include "content/browser/loader/url_loader_factory_impl.h" | 17 #include "content/browser/loader/url_loader_factory_impl.h" |
| 18 #include "content/browser/service_worker/embedded_worker_status.h" | 18 #include "content/browser/service_worker/embedded_worker_status.h" |
| 19 #include "content/browser/service_worker/service_worker_metrics.h" | 19 #include "content/browser/service_worker/service_worker_metrics.h" |
| 20 #include "content/browser/service_worker/service_worker_version.h" | 20 #include "content/browser/service_worker/service_worker_version.h" |
| 21 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" | 21 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" |
| 22 #include "content/common/service_worker/service_worker_messages.h" | 22 #include "content/common/service_worker/service_worker_messages.h" |
| 23 #include "content/common/service_worker/service_worker_status_code.h" | 23 #include "content/common/service_worker/service_worker_status_code.h" |
| 24 #include "content/common/service_worker/service_worker_types.h" | 24 #include "content/common/service_worker/service_worker_types.h" |
| 25 #include "content/common/service_worker/service_worker_utils.h" | 25 #include "content/common/service_worker/service_worker_utils.h" |
| 26 #include "content/public/common/browser_side_navigation_policy.h" | 26 #include "content/public/common/browser_side_navigation_policy.h" |
| 27 #include "mojo/public/cpp/bindings/associated_binding.h" | 27 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 28 #include "mojo/public/cpp/bindings/binding.h" | 28 #include "mojo/public/cpp/bindings/binding.h" |
| 29 #include "net/base/request_priority.h" |
| 29 #include "net/http/http_util.h" | 30 #include "net/http/http_util.h" |
| 30 #include "net/log/net_log.h" | 31 #include "net/log/net_log.h" |
| 31 #include "net/log/net_log_capture_mode.h" | 32 #include "net/log/net_log_capture_mode.h" |
| 32 #include "net/log/net_log_event_type.h" | 33 #include "net/log/net_log_event_type.h" |
| 33 #include "net/url_request/url_request.h" | 34 #include "net/url_request/url_request.h" |
| 34 | 35 |
| 35 namespace content { | 36 namespace content { |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 // This class wraps a mojo::AssociatedInterfacePtr<URLLoader>. It also is a | 40 // This class wraps a mojo::AssociatedInterfacePtr<URLLoader>. It also is a |
| 40 // URLLoader implementation and delegates URLLoader calls to the wrapped loader. | 41 // URLLoader implementation and delegates URLLoader calls to the wrapped loader. |
| 41 class DelegatingURLLoader final : public mojom::URLLoader { | 42 class DelegatingURLLoader final : public mojom::URLLoader { |
| 42 public: | 43 public: |
| 43 explicit DelegatingURLLoader(mojom::URLLoaderAssociatedPtr loader) | 44 explicit DelegatingURLLoader(mojom::URLLoaderAssociatedPtr loader) |
| 44 : binding_(this), loader_(std::move(loader)) {} | 45 : binding_(this), loader_(std::move(loader)) {} |
| 45 ~DelegatingURLLoader() override {} | 46 ~DelegatingURLLoader() override {} |
| 46 | 47 |
| 47 void FollowRedirect() override { loader_->FollowRedirect(); } | 48 void FollowRedirect() override { loader_->FollowRedirect(); } |
| 48 | 49 |
| 50 void SetPriority(net::RequestPriority priority, |
| 51 int intra_priority_value) override { |
| 52 loader_->SetPriority(priority, intra_priority_value); |
| 53 } |
| 54 |
| 49 mojom::URLLoaderPtr CreateInterfacePtrAndBind() { | 55 mojom::URLLoaderPtr CreateInterfacePtrAndBind() { |
| 50 auto p = binding_.CreateInterfacePtrAndBind(); | 56 auto p = binding_.CreateInterfacePtrAndBind(); |
| 51 // This unretained pointer is safe, because |binding_| is owned by |this| | 57 // This unretained pointer is safe, because |binding_| is owned by |this| |
| 52 // and the callback will never be called after |this| is destroyed. | 58 // and the callback will never be called after |this| is destroyed. |
| 53 binding_.set_connection_error_handler( | 59 binding_.set_connection_error_handler( |
| 54 base::Bind(&DelegatingURLLoader::Cancel, base::Unretained(this))); | 60 base::Bind(&DelegatingURLLoader::Cancel, base::Unretained(this))); |
| 55 return p; | 61 return p; |
| 56 } | 62 } |
| 57 | 63 |
| 58 private: | 64 private: |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 ServiceWorkerVersion* version, | 529 ServiceWorkerVersion* version, |
| 524 int event_finish_id, | 530 int event_finish_id, |
| 525 scoped_refptr<URLLoaderAssets> url_loader_assets, | 531 scoped_refptr<URLLoaderAssets> url_loader_assets, |
| 526 ServiceWorkerStatusCode status, | 532 ServiceWorkerStatusCode status, |
| 527 base::Time dispatch_event_time) { | 533 base::Time dispatch_event_time) { |
| 528 version->FinishRequest(event_finish_id, status != SERVICE_WORKER_ERROR_ABORT, | 534 version->FinishRequest(event_finish_id, status != SERVICE_WORKER_ERROR_ABORT, |
| 529 dispatch_event_time); | 535 dispatch_event_time); |
| 530 } | 536 } |
| 531 | 537 |
| 532 } // namespace content | 538 } // namespace content |
| OLD | NEW |