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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2826213003: Don't lower priority for scripts inserted by doc.write (Closed)
Patch Set: Fixed duplicate URLs in Layout test Created 3 years, 8 months 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 | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h ('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 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 rights reserved. 6 rights reserved.
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return kResourceLoadPriorityUnresolved; 151 return kResourceLoadPriorityUnresolved;
152 } 152 }
153 153
154 } // namespace 154 } // namespace
155 155
156 ResourceLoadPriority ResourceFetcher::ComputeLoadPriority( 156 ResourceLoadPriority ResourceFetcher::ComputeLoadPriority(
157 Resource::Type type, 157 Resource::Type type,
158 const ResourceRequest& resource_request, 158 const ResourceRequest& resource_request,
159 ResourcePriority::VisibilityStatus visibility, 159 ResourcePriority::VisibilityStatus visibility,
160 FetchParameters::DeferOption defer_option, 160 FetchParameters::DeferOption defer_option,
161 bool is_speculative_preload, 161 FetchParameters::SpeculativePreloadType speculative_preload_type,
162 bool is_link_preload) { 162 bool is_link_preload) {
163 ResourceLoadPriority priority = TypeToPriority(type); 163 ResourceLoadPriority priority = TypeToPriority(type);
164 164
165 // Visible resources (images in practice) get a boost to High priority. 165 // Visible resources (images in practice) get a boost to High priority.
166 if (visibility == ResourcePriority::kVisible) 166 if (visibility == ResourcePriority::kVisible)
167 priority = kResourceLoadPriorityHigh; 167 priority = kResourceLoadPriorityHigh;
168 168
169 // Resources before the first image are considered "early" in the document and 169 // Resources before the first image are considered "early" in the document and
170 // resources after the first image are "late" in the document. Important to 170 // resources after the first image are "late" in the document. Important to
171 // note that this is based on when the preload scanner discovers a resource 171 // note that this is based on when the preload scanner discovers a resource
(...skipping 10 matching lines...) Expand all
182 if (FetchParameters::kIdleLoad == defer_option) { 182 if (FetchParameters::kIdleLoad == defer_option) {
183 priority = kResourceLoadPriorityVeryLow; 183 priority = kResourceLoadPriorityVeryLow;
184 } else if (type == Resource::kScript) { 184 } else if (type == Resource::kScript) {
185 // Special handling for scripts. 185 // Special handling for scripts.
186 // Default/Parser-Blocking/Preload early in document: High (set in 186 // Default/Parser-Blocking/Preload early in document: High (set in
187 // typeToPriority) 187 // typeToPriority)
188 // Async/Defer: Low Priority (applies to both preload and parser-inserted) 188 // Async/Defer: Low Priority (applies to both preload and parser-inserted)
189 // Preload late in document: Medium 189 // Preload late in document: Medium
190 if (FetchParameters::kLazyLoad == defer_option) { 190 if (FetchParameters::kLazyLoad == defer_option) {
191 priority = kResourceLoadPriorityLow; 191 priority = kResourceLoadPriorityLow;
192 } else if (is_speculative_preload && image_fetched_) { 192 } else if (speculative_preload_type ==
193 FetchParameters::SpeculativePreloadType::kInDocument &&
194 image_fetched_) {
193 // Speculative preload is used as a signal for scripts at the bottom of 195 // Speculative preload is used as a signal for scripts at the bottom of
194 // the document. 196 // the document.
195 priority = kResourceLoadPriorityMedium; 197 priority = kResourceLoadPriorityMedium;
196 } 198 }
197 } else if (FetchParameters::kLazyLoad == defer_option) { 199 } else if (FetchParameters::kLazyLoad == defer_option) {
198 priority = kResourceLoadPriorityVeryLow; 200 priority = kResourceLoadPriorityVeryLow;
199 } 201 }
200 202
201 // A manually set priority acts as a floor. This is used to ensure that 203 // A manually set priority acts as a floor. This is used to ensure that
202 // synchronous requests are always given the highest possible priority, as 204 // synchronous requests are always given the highest possible priority, as
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 factory.GetType(), params.GetClientHintsPreferences(), 511 factory.GetType(), params.GetClientHintsPreferences(),
510 params.GetResourceWidth(), params.Options(), reporting_policy, 512 params.GetResourceWidth(), params.Options(), reporting_policy,
511 resource_request); 513 resource_request);
512 514
513 if (!params.Url().IsValid()) 515 if (!params.Url().IsValid())
514 return kAbort; 516 return kAbort;
515 517
516 resource_request.SetPriority(ComputeLoadPriority( 518 resource_request.SetPriority(ComputeLoadPriority(
517 factory.GetType(), params.GetResourceRequest(), 519 factory.GetType(), params.GetResourceRequest(),
518 ResourcePriority::kNotVisible, params.Defer(), 520 ResourcePriority::kNotVisible, params.Defer(),
519 params.IsSpeculativePreload(), params.IsLinkPreload())); 521 params.GetSpeculativePreloadType(), params.IsLinkPreload()));
520 InitializeResourceRequest(resource_request, factory.GetType(), 522 InitializeResourceRequest(resource_request, factory.GetType(),
521 params.Defer()); 523 params.Defer());
522 network_instrumentation::resourcePrioritySet(identifier, 524 network_instrumentation::resourcePrioritySet(identifier,
523 resource_request.Priority()); 525 resource_request.Priority());
524 526
525 blocked_reason = Context().CanRequest( 527 blocked_reason = Context().CanRequest(
526 factory.GetType(), resource_request, 528 factory.GetType(), resource_request,
527 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()), 529 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()),
528 params.Options(), 530 params.Options(),
529 /* Don't send security violation reports for speculative preloads */ 531 /* Don't send security violation reports for speculative preloads */
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 visitor->Trace(context_); 1578 visitor->Trace(context_);
1577 visitor->Trace(archive_); 1579 visitor->Trace(archive_);
1578 visitor->Trace(loaders_); 1580 visitor->Trace(loaders_);
1579 visitor->Trace(non_blocking_loaders_); 1581 visitor->Trace(non_blocking_loaders_);
1580 visitor->Trace(document_resources_); 1582 visitor->Trace(document_resources_);
1581 visitor->Trace(preloads_); 1583 visitor->Trace(preloads_);
1582 visitor->Trace(resource_timing_info_map_); 1584 visitor->Trace(resource_timing_info_map_);
1583 } 1585 }
1584 1586
1585 } // namespace blink 1587 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698