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

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

Issue 2841363002: Don't lower priority for scripts inserted by doc.write (Closed)
Patch Set: Fixed layout test Created 3 years, 7 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 factory.GetType(), params.GetClientHintsPreferences(), 510 factory.GetType(), params.GetClientHintsPreferences(),
509 params.GetResourceWidth(), params.Options(), reporting_policy, 511 params.GetResourceWidth(), params.Options(), reporting_policy,
510 resource_request); 512 resource_request);
511 513
512 if (!params.Url().IsValid()) 514 if (!params.Url().IsValid())
513 return kAbort; 515 return kAbort;
514 516
515 resource_request.SetPriority(ComputeLoadPriority( 517 resource_request.SetPriority(ComputeLoadPriority(
516 factory.GetType(), params.GetResourceRequest(), 518 factory.GetType(), params.GetResourceRequest(),
517 ResourcePriority::kNotVisible, params.Defer(), 519 ResourcePriority::kNotVisible, params.Defer(),
518 params.IsSpeculativePreload(), params.IsLinkPreload())); 520 params.GetSpeculativePreloadType(), params.IsLinkPreload()));
519 InitializeResourceRequest(resource_request, factory.GetType(), 521 InitializeResourceRequest(resource_request, factory.GetType(),
520 params.Defer()); 522 params.Defer());
521 network_instrumentation::resourcePrioritySet(identifier, 523 network_instrumentation::resourcePrioritySet(identifier,
522 resource_request.Priority()); 524 resource_request.Priority());
523 525
524 blocked_reason = Context().CanRequest( 526 blocked_reason = Context().CanRequest(
525 factory.GetType(), resource_request, 527 factory.GetType(), resource_request,
526 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()), 528 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()),
527 params.Options(), 529 params.Options(),
528 /* Don't send security violation reports for speculative preloads */ 530 /* Don't send security violation reports for speculative preloads */
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 visitor->Trace(context_); 1527 visitor->Trace(context_);
1526 visitor->Trace(archive_); 1528 visitor->Trace(archive_);
1527 visitor->Trace(loaders_); 1529 visitor->Trace(loaders_);
1528 visitor->Trace(non_blocking_loaders_); 1530 visitor->Trace(non_blocking_loaders_);
1529 visitor->Trace(document_resources_); 1531 visitor->Trace(document_resources_);
1530 visitor->Trace(preloads_); 1532 visitor->Trace(preloads_);
1531 visitor->Trace(resource_timing_info_map_); 1533 visitor->Trace(resource_timing_info_map_);
1532 } 1534 }
1533 1535
1534 } // namespace blink 1536 } // 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