OLD | NEW |
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 Loading... |
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 FetchParameters::SpeculativePreloadType speculative_preload_type, | 161 bool is_speculative_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 Loading... |
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 (speculative_preload_type == | 192 } else if (is_speculative_preload && image_fetched_) { |
193 FetchParameters::SpeculativePreloadType::kInDocument && | |
194 image_fetched_) { | |
195 // 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 |
196 // the document. | 194 // the document. |
197 priority = kResourceLoadPriorityMedium; | 195 priority = kResourceLoadPriorityMedium; |
198 } | 196 } |
199 } else if (FetchParameters::kLazyLoad == defer_option) { | 197 } else if (FetchParameters::kLazyLoad == defer_option) { |
200 priority = kResourceLoadPriorityVeryLow; | 198 priority = kResourceLoadPriorityVeryLow; |
201 } | 199 } |
202 | 200 |
203 // 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 |
204 // 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 Loading... |
511 factory.GetType(), params.GetClientHintsPreferences(), | 509 factory.GetType(), params.GetClientHintsPreferences(), |
512 params.GetResourceWidth(), params.Options(), reporting_policy, | 510 params.GetResourceWidth(), params.Options(), reporting_policy, |
513 resource_request); | 511 resource_request); |
514 | 512 |
515 if (!params.Url().IsValid()) | 513 if (!params.Url().IsValid()) |
516 return kAbort; | 514 return kAbort; |
517 | 515 |
518 resource_request.SetPriority(ComputeLoadPriority( | 516 resource_request.SetPriority(ComputeLoadPriority( |
519 factory.GetType(), params.GetResourceRequest(), | 517 factory.GetType(), params.GetResourceRequest(), |
520 ResourcePriority::kNotVisible, params.Defer(), | 518 ResourcePriority::kNotVisible, params.Defer(), |
521 params.GetSpeculativePreloadType(), params.IsLinkPreload())); | 519 params.IsSpeculativePreload(), params.IsLinkPreload())); |
522 InitializeResourceRequest(resource_request, factory.GetType(), | 520 InitializeResourceRequest(resource_request, factory.GetType(), |
523 params.Defer()); | 521 params.Defer()); |
524 network_instrumentation::resourcePrioritySet(identifier, | 522 network_instrumentation::resourcePrioritySet(identifier, |
525 resource_request.Priority()); | 523 resource_request.Priority()); |
526 | 524 |
527 blocked_reason = Context().CanRequest( | 525 blocked_reason = Context().CanRequest( |
528 factory.GetType(), resource_request, | 526 factory.GetType(), resource_request, |
529 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()), | 527 MemoryCache::RemoveFragmentIdentifierIfNeeded(params.Url()), |
530 params.Options(), | 528 params.Options(), |
531 /* 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 Loading... |
1578 visitor->Trace(context_); | 1576 visitor->Trace(context_); |
1579 visitor->Trace(archive_); | 1577 visitor->Trace(archive_); |
1580 visitor->Trace(loaders_); | 1578 visitor->Trace(loaders_); |
1581 visitor->Trace(non_blocking_loaders_); | 1579 visitor->Trace(non_blocking_loaders_); |
1582 visitor->Trace(document_resources_); | 1580 visitor->Trace(document_resources_); |
1583 visitor->Trace(preloads_); | 1581 visitor->Trace(preloads_); |
1584 visitor->Trace(resource_timing_info_map_); | 1582 visitor->Trace(resource_timing_info_map_); |
1585 } | 1583 } |
1586 | 1584 |
1587 } // namespace blink | 1585 } // namespace blink |
OLD | NEW |