| 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/command_line.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/content_features.h" |
| 25 #include "net/log/net_log.h" | 26 #include "net/log/net_log.h" |
| 26 #include "net/log/net_log_capture_mode.h" | 27 #include "net/log/net_log_capture_mode.h" |
| 27 #include "net/log/net_log_event_type.h" | 28 #include "net/log/net_log_event_type.h" |
| 28 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 using EventType = ServiceWorkerMetrics::EventType; | 35 using EventType = ServiceWorkerMetrics::EventType; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 const MojoURLLoaderFactoryGetter& url_loader_factory_getter) { | 282 const MojoURLLoaderFactoryGetter& url_loader_factory_getter) { |
| 282 if (resource_type_ != RESOURCE_TYPE_MAIN_FRAME && | 283 if (resource_type_ != RESOURCE_TYPE_MAIN_FRAME && |
| 283 resource_type_ != RESOURCE_TYPE_SUB_FRAME) { | 284 resource_type_ != RESOURCE_TYPE_SUB_FRAME) { |
| 284 return; | 285 return; |
| 285 } | 286 } |
| 286 if (!version_->navigation_preload_enabled()) | 287 if (!version_->navigation_preload_enabled()) |
| 287 return; | 288 return; |
| 288 // TODO(horo): Currently NavigationPreload doesn't support request body. | 289 // TODO(horo): Currently NavigationPreload doesn't support request body. |
| 289 if (!request_->blob_uuid.empty()) | 290 if (!request_->blob_uuid.empty()) |
| 290 return; | 291 return; |
| 291 // TODO(horo): Introduce kEnableServiceWorkerNavigationPreload switch, and use | 292 if (!base::FeatureList::IsEnabled( |
| 292 // it instead of kEnableExperimentalWebPlatformFeatures. | 293 features::kServiceWorkerNavigationPreload)) { |
| 293 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 294 switches::kEnableExperimentalWebPlatformFeatures)) { | |
| 295 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use | 294 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use |
| 296 // Origin-Trial for NavigationPreload. | 295 // Origin-Trial for NavigationPreload. |
| 297 return; | 296 return; |
| 298 } | 297 } |
| 299 DCHECK(!url_loader_factory_getter.is_null()); | 298 DCHECK(!url_loader_factory_getter.is_null()); |
| 300 mojom::URLLoaderFactoryPtr factory; | 299 mojom::URLLoaderFactoryPtr factory; |
| 301 url_loader_factory_getter.Run(mojo::GetProxy(&factory)); | 300 url_loader_factory_getter.Run(mojo::GetProxy(&factory)); |
| 302 if (url_loader_factory_getter.IsCancelled()) | 301 if (url_loader_factory_getter.IsCancelled()) |
| 303 return; | 302 return; |
| 304 | 303 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 335 } | 334 } |
| 336 | 335 |
| 337 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() | 336 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() |
| 338 const { | 337 const { |
| 339 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) | 338 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) |
| 340 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; | 339 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; |
| 341 return ResourceTypeToEventType(resource_type_); | 340 return ResourceTypeToEventType(resource_type_); |
| 342 } | 341 } |
| 343 | 342 |
| 344 } // namespace content | 343 } // namespace content |
| OLD | NEW |