| 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/feature_list.h" | 11 #include "base/feature_list.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/service_worker/embedded_worker_status.h" | 16 #include "content/browser/service_worker/embedded_worker_status.h" |
| 17 #include "content/browser/service_worker/service_worker_version.h" | 17 #include "content/browser/service_worker/service_worker_version.h" |
| 18 #include "content/common/service_worker/fetch_event_dispatcher.mojom.h" | 18 #include "content/common/service_worker/fetch_event_dispatcher.mojom.h" |
| 19 #include "content/common/service_worker/service_worker_messages.h" | 19 #include "content/common/service_worker/service_worker_messages.h" |
| 20 #include "content/common/service_worker/service_worker_status_code.h" | 20 #include "content/common/service_worker/service_worker_status_code.h" |
| 21 #include "content/common/service_worker/service_worker_types.h" | 21 #include "content/common/service_worker/service_worker_types.h" |
| 22 #include "content/common/service_worker/service_worker_utils.h" | 22 #include "content/common/service_worker/service_worker_utils.h" |
| 23 #include "content/common/url_loader.mojom.h" | 23 #include "content/common/url_loader.mojom.h" |
| 24 #include "content/common/url_loader_factory.mojom.h" | 24 #include "content/common/url_loader_factory.mojom.h" |
| 25 #include "content/public/common/browser_side_navigation_policy.h" |
| 25 #include "content/public/common/content_features.h" | 26 #include "content/public/common/content_features.h" |
| 26 #include "net/log/net_log.h" | 27 #include "net/log/net_log.h" |
| 27 #include "net/log/net_log_capture_mode.h" | 28 #include "net/log/net_log_capture_mode.h" |
| 28 #include "net/log/net_log_event_type.h" | 29 #include "net/log/net_log_event_type.h" |
| 29 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 return; | 289 return; |
| 289 // TODO(horo): Currently NavigationPreload doesn't support request body. | 290 // TODO(horo): Currently NavigationPreload doesn't support request body. |
| 290 if (!request_->blob_uuid.empty()) | 291 if (!request_->blob_uuid.empty()) |
| 291 return; | 292 return; |
| 292 if (!base::FeatureList::IsEnabled( | 293 if (!base::FeatureList::IsEnabled( |
| 293 features::kServiceWorkerNavigationPreload)) { | 294 features::kServiceWorkerNavigationPreload)) { |
| 294 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use | 295 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use |
| 295 // Origin-Trial for NavigationPreload. | 296 // Origin-Trial for NavigationPreload. |
| 296 return; | 297 return; |
| 297 } | 298 } |
| 299 if (IsBrowserSideNavigationEnabled()) { |
| 300 // TODO(horo): Support NavigationPreload with PlzNavigate. |
| 301 NOTIMPLEMENTED(); |
| 302 return; |
| 303 } |
| 298 DCHECK(!url_loader_factory_getter.is_null()); | 304 DCHECK(!url_loader_factory_getter.is_null()); |
| 299 mojom::URLLoaderFactoryPtr factory; | 305 mojom::URLLoaderFactoryPtr factory; |
| 300 url_loader_factory_getter.Run(mojo::GetProxy(&factory)); | 306 url_loader_factory_getter.Run(mojo::GetProxy(&factory)); |
| 301 if (url_loader_factory_getter.IsCancelled()) | 307 if (url_loader_factory_getter.IsCancelled()) |
| 302 return; | 308 return; |
| 303 | 309 |
| 304 preload_handle_ = mojom::FetchEventPreloadHandle::New(); | 310 preload_handle_ = mojom::FetchEventPreloadHandle::New(); |
| 305 const ResourceRequestInfoImpl* original_info = | 311 const ResourceRequestInfoImpl* original_info = |
| 306 ResourceRequestInfoImpl::ForRequest(original_request); | 312 ResourceRequestInfoImpl::ForRequest(original_request); |
| 307 | 313 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 334 } | 340 } |
| 335 | 341 |
| 336 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() | 342 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() |
| 337 const { | 343 const { |
| 338 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) | 344 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) |
| 339 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; | 345 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; |
| 340 return ResourceTypeToEventType(resource_type_); | 346 return ResourceTypeToEventType(resource_type_); |
| 341 } | 347 } |
| 342 | 348 |
| 343 } // namespace content | 349 } // namespace content |
| OLD | NEW |