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

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: Added 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
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 bool is_speculative_document_preload,
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 (is_speculative_document_preload && image_fetched_) {
193 // Speculative preload is used as a signal for scripts at the bottom of 193 // Speculative preload is used as a signal for scripts at the bottom of
194 // the document. 194 // the document.
195 priority = kResourceLoadPriorityMedium; 195 priority = kResourceLoadPriorityMedium;
196 } 196 }
197 } else if (FetchParameters::kLazyLoad == defer_option) { 197 } else if (FetchParameters::kLazyLoad == defer_option) {
198 priority = kResourceLoadPriorityVeryLow; 198 priority = kResourceLoadPriorityVeryLow;
199 } 199 }
200 200
201 // A manually set priority acts as a floor. This is used to ensure that 201 // 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 202 // 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(), 509 factory.GetType(), params.GetClientHintsPreferences(),
510 params.GetResourceWidth(), params.Options(), reporting_policy, 510 params.GetResourceWidth(), params.Options(), reporting_policy,
511 resource_request); 511 resource_request);
512 512
513 if (!params.Url().IsValid()) 513 if (!params.Url().IsValid())
514 return kAbort; 514 return kAbort;
515 515
516 resource_request.SetPriority(ComputeLoadPriority( 516 resource_request.SetPriority(ComputeLoadPriority(
517 factory.GetType(), params.GetResourceRequest(), 517 factory.GetType(), params.GetResourceRequest(),
518 ResourcePriority::kNotVisible, params.Defer(), 518 ResourcePriority::kNotVisible, params.Defer(),
519 params.IsSpeculativePreload(), params.IsLinkPreload())); 519 params.IsSpeculativeDocumentPreload(), params.IsLinkPreload()));
520 InitializeResourceRequest(resource_request, factory.GetType(), 520 InitializeResourceRequest(resource_request, factory.GetType(),
521 params.Defer()); 521 params.Defer());
522 network_instrumentation::resourcePrioritySet(identifier, 522 network_instrumentation::resourcePrioritySet(identifier,
523 resource_request.Priority()); 523 resource_request.Priority());
524 524
525 blocked_reason = Context().CanRequest( 525 blocked_reason = Context().CanRequest(
526 factory.GetType(), resource_request, 526 factory.GetType(), resource_request,
527 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()), 527 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()),
528 params.Options(), 528 params.Options(),
529 /* Don't send security violation reports for speculative preloads */ 529 /* 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_); 1576 visitor->Trace(context_);
1577 visitor->Trace(archive_); 1577 visitor->Trace(archive_);
1578 visitor->Trace(loaders_); 1578 visitor->Trace(loaders_);
1579 visitor->Trace(non_blocking_loaders_); 1579 visitor->Trace(non_blocking_loaders_);
1580 visitor->Trace(document_resources_); 1580 visitor->Trace(document_resources_);
1581 visitor->Trace(preloads_); 1581 visitor->Trace(preloads_);
1582 visitor->Trace(resource_timing_info_map_); 1582 visitor->Trace(resource_timing_info_map_);
1583 } 1583 }
1584 1584
1585 } // namespace blink 1585 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698