Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: content/browser/service_worker/service_worker_fetch_dispatcher.cc

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: fix URLLoaderFactoryImplTest/URLLoaderFactoryImplTest.GetFailedResponse2 Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/link_header_support.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" 15 #include "content/browser/loader/resource_dispatcher_host_impl.h"
16 #include "content/browser/loader/resource_message_filter.h"
17 #include "content/browser/loader/resource_request_info_impl.h" 16 #include "content/browser/loader/resource_request_info_impl.h"
17 #include "content/browser/loader/resource_requester_info.h"
18 #include "content/browser/loader/url_loader_factory_impl.h" 18 #include "content/browser/loader/url_loader_factory_impl.h"
19 #include "content/browser/service_worker/embedded_worker_status.h" 19 #include "content/browser/service_worker/embedded_worker_status.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 "content/public/common/content_features.h" 27 #include "content/public/common/content_features.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return; 370 return;
371 // TODO(horo): Currently NavigationPreload doesn't support request body. 371 // TODO(horo): Currently NavigationPreload doesn't support request body.
372 if (!request_->blob_uuid.empty()) 372 if (!request_->blob_uuid.empty())
373 return; 373 return;
374 if (!base::FeatureList::IsEnabled( 374 if (!base::FeatureList::IsEnabled(
375 features::kServiceWorkerNavigationPreload)) { 375 features::kServiceWorkerNavigationPreload)) {
376 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use 376 // TODO(horo): Check |version_|'s origin_trial_tokens() here if we use
377 // Origin-Trial for NavigationPreload. 377 // Origin-Trial for NavigationPreload.
378 return; 378 return;
379 } 379 }
380
381 ResourceRequestInfoImpl* original_info =
382 ResourceRequestInfoImpl::ForRequest(original_request);
380 if (IsBrowserSideNavigationEnabled()) { 383 if (IsBrowserSideNavigationEnabled()) {
381 // TODO(horo): Support NavigationPreload with PlzNavigate. 384 // TODO(horo): Support NavigationPreload with PlzNavigate.
385 DCHECK(original_info->requester_info()->IsBrowserSideNavigation());
382 NOTIMPLEMENTED(); 386 NOTIMPLEMENTED();
383 return; 387 return;
384 } 388 }
389 DCHECK(original_info->requester_info()->IsRenderer());
390 if (!original_info->requester_info()->filter())
391 return;
385 392
386 DCHECK(!url_loader_factory_); 393 DCHECK(!url_loader_factory_);
387 const ResourceRequestInfoImpl* original_info =
388 ResourceRequestInfoImpl::ForRequest(original_request);
389 if (!original_info->filter())
390 return;
391 mojom::URLLoaderFactoryPtr factory; 394 mojom::URLLoaderFactoryPtr factory;
392 URLLoaderFactoryImpl::Create(original_info->filter(), 395 URLLoaderFactoryImpl::Create(original_info->requester_info(),
393 mojo::GetProxy(&url_loader_factory_)); 396 mojo::GetProxy(&url_loader_factory_));
394 397
395 preload_handle_ = mojom::FetchEventPreloadHandle::New(); 398 preload_handle_ = mojom::FetchEventPreloadHandle::New();
396 399
397 ResourceRequest request; 400 ResourceRequest request;
398 request.method = original_request->method(); 401 request.method = original_request->method();
399 request.url = original_request->url(); 402 request.url = original_request->url();
400 request.request_initiator = original_request->initiator(); 403 request.request_initiator = original_request->initiator();
401 request.referrer = GURL(original_request->referrer()); 404 request.referrer = GURL(original_request->referrer());
402 request.referrer_policy = original_info->GetReferrerPolicy(); 405 request.referrer_policy = original_info->GetReferrerPolicy();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 448 }
446 449
447 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() 450 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType()
448 const { 451 const {
449 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) 452 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH)
450 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; 453 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH;
451 return ResourceTypeToEventType(resource_type_); 454 return ResourceTypeToEventType(resource_type_);
452 } 455 }
453 456
454 } // namespace content 457 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/link_header_support.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698