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

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

Issue 2862303002: Don't lower priority for scripts inserted by doc.write (Closed)
Patch Set: 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 Context().PopulateResourceRequest( 505 Context().PopulateResourceRequest(
504 factory.GetType(), params.GetClientHintsPreferences(), 506 factory.GetType(), params.GetClientHintsPreferences(),
505 params.GetResourceWidth(), resource_request); 507 params.GetResourceWidth(), resource_request);
506 508
507 if (!params.Url().IsValid()) 509 if (!params.Url().IsValid())
508 return kAbort; 510 return kAbort;
509 511
510 resource_request.SetPriority(ComputeLoadPriority( 512 resource_request.SetPriority(ComputeLoadPriority(
511 factory.GetType(), params.GetResourceRequest(), 513 factory.GetType(), params.GetResourceRequest(),
512 ResourcePriority::kNotVisible, params.Defer(), 514 ResourcePriority::kNotVisible, params.Defer(),
513 params.IsSpeculativePreload(), params.IsLinkPreload())); 515 params.GetSpeculativePreloadType(), params.IsLinkPreload()));
514 InitializeResourceRequest(resource_request, factory.GetType(), 516 InitializeResourceRequest(resource_request, factory.GetType(),
515 params.Defer()); 517 params.Defer());
516 network_instrumentation::resourcePrioritySet(identifier, 518 network_instrumentation::resourcePrioritySet(identifier,
517 resource_request.Priority()); 519 resource_request.Priority());
518 520
519 blocked_reason = Context().CanRequest( 521 blocked_reason = Context().CanRequest(
520 factory.GetType(), resource_request, 522 factory.GetType(), resource_request,
521 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()), 523 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()),
522 params.Options(), 524 params.Options(),
523 /* Don't send security violation reports for speculative preloads */ 525 /* Don't send security violation reports for speculative preloads */
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 visitor->Trace(context_); 1579 visitor->Trace(context_);
1578 visitor->Trace(archive_); 1580 visitor->Trace(archive_);
1579 visitor->Trace(loaders_); 1581 visitor->Trace(loaders_);
1580 visitor->Trace(non_blocking_loaders_); 1582 visitor->Trace(non_blocking_loaders_);
1581 visitor->Trace(document_resources_); 1583 visitor->Trace(document_resources_);
1582 visitor->Trace(preloads_); 1584 visitor->Trace(preloads_);
1583 visitor->Trace(resource_timing_info_map_); 1585 visitor->Trace(resource_timing_info_map_);
1584 } 1586 }
1585 1587
1586 } // namespace blink 1588 } // 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