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" | |
12 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
13 #include "base/time/time.h" | 12 #include "base/time/time.h" |
14 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 14 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
16 #include "content/browser/loader/resource_request_info_impl.h" | 15 #include "content/browser/loader/resource_request_info_impl.h" |
17 #include "content/browser/loader/resource_requester_info.h" | 16 #include "content/browser/loader/resource_requester_info.h" |
18 #include "content/browser/loader/url_loader_factory_impl.h" | 17 #include "content/browser/loader/url_loader_factory_impl.h" |
19 #include "content/browser/service_worker/embedded_worker_status.h" | 18 #include "content/browser/service_worker/embedded_worker_status.h" |
20 #include "content/browser/service_worker/service_worker_metrics.h" | 19 #include "content/browser/service_worker/service_worker_metrics.h" |
21 #include "content/browser/service_worker/service_worker_version.h" | 20 #include "content/browser/service_worker/service_worker_version.h" |
22 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" | 21 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" |
23 #include "content/common/service_worker/service_worker_messages.h" | 22 #include "content/common/service_worker/service_worker_messages.h" |
24 #include "content/common/service_worker/service_worker_status_code.h" | 23 #include "content/common/service_worker/service_worker_status_code.h" |
25 #include "content/common/service_worker/service_worker_types.h" | 24 #include "content/common/service_worker/service_worker_types.h" |
26 #include "content/common/service_worker/service_worker_utils.h" | 25 #include "content/common/service_worker/service_worker_utils.h" |
27 #include "content/public/common/browser_side_navigation_policy.h" | 26 #include "content/public/common/browser_side_navigation_policy.h" |
28 #include "content/public/common/content_features.h" | |
29 #include "mojo/public/cpp/bindings/associated_binding.h" | 27 #include "mojo/public/cpp/bindings/associated_binding.h" |
30 #include "mojo/public/cpp/bindings/binding.h" | 28 #include "mojo/public/cpp/bindings/binding.h" |
31 #include "net/http/http_util.h" | 29 #include "net/http/http_util.h" |
32 #include "net/log/net_log.h" | 30 #include "net/log/net_log.h" |
33 #include "net/log/net_log_capture_mode.h" | 31 #include "net/log/net_log_capture_mode.h" |
34 #include "net/log/net_log_event_type.h" | 32 #include "net/log/net_log_event_type.h" |
35 #include "net/url_request/url_request.h" | 33 #include "net/url_request/url_request.h" |
36 | 34 |
37 namespace content { | 35 namespace content { |
38 | 36 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 net::URLRequest* original_request) { | 391 net::URLRequest* original_request) { |
394 if (resource_type_ != RESOURCE_TYPE_MAIN_FRAME && | 392 if (resource_type_ != RESOURCE_TYPE_MAIN_FRAME && |
395 resource_type_ != RESOURCE_TYPE_SUB_FRAME) { | 393 resource_type_ != RESOURCE_TYPE_SUB_FRAME) { |
396 return; | 394 return; |
397 } | 395 } |
398 if (!version_->navigation_preload_state().enabled) | 396 if (!version_->navigation_preload_state().enabled) |
399 return; | 397 return; |
400 // TODO(horo): Currently NavigationPreload doesn't support request body. | 398 // TODO(horo): Currently NavigationPreload doesn't support request body. |
401 if (!request_->blob_uuid.empty()) | 399 if (!request_->blob_uuid.empty()) |
402 return; | 400 return; |
403 if (!base::FeatureList::IsEnabled( | 401 |
404 features::kServiceWorkerNavigationPreload)) { | 402 if (!version_->IsNavigationPreloadSupported()) |
405 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use | |
406 // Origin-Trial for NavigationPreload. | |
407 return; | 403 return; |
408 } | |
409 | 404 |
410 ResourceRequestInfoImpl* original_info = | 405 ResourceRequestInfoImpl* original_info = |
411 ResourceRequestInfoImpl::ForRequest(original_request); | 406 ResourceRequestInfoImpl::ForRequest(original_request); |
412 ResourceRequesterInfo* requester_info = original_info->requester_info(); | 407 ResourceRequesterInfo* requester_info = original_info->requester_info(); |
413 if (IsBrowserSideNavigationEnabled()) { | 408 if (IsBrowserSideNavigationEnabled()) { |
414 DCHECK(requester_info->IsBrowserSideNavigation()); | 409 DCHECK(requester_info->IsBrowserSideNavigation()); |
415 } else { | 410 } else { |
416 DCHECK(requester_info->IsRenderer()); | 411 DCHECK(requester_info->IsRenderer()); |
417 if (!requester_info->filter()) | 412 if (!requester_info->filter()) |
418 return; | 413 return; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 } | 477 } |
483 | 478 |
484 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() | 479 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() |
485 const { | 480 const { |
486 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) | 481 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) |
487 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; | 482 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; |
488 return ResourceTypeToEventType(resource_type_); | 483 return ResourceTypeToEventType(resource_type_); |
489 } | 484 } |
490 | 485 |
491 } // namespace content | 486 } // namespace content |
OLD | NEW |