source: webkit/trunk/Source/WebCore/loader/DefaultResourceLoadPriority.cpp

Last change on this file was 276003, checked in by Antti Koivisto, 4 years ago

Preloaded async scripts should use the same priority as the normally loaded ones
https://bugs.webkit.org/show_bug.cgi?id=224537

Reviewed by Sam Weinig.

Use the same priority (medium instead of low) when preloading.

Factor default priorities to a separate type making it easier to keep them in sync.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/LoadableClassicScript.cpp:

(WebCore::LoadableClassicScript::load):

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::process):

  • html/parser/HTMLResourcePreloader.cpp:

(WebCore::PreloadRequest::resourceRequest):

  • loader/DefaultResourceLoadPriority.cpp: Added.

(WebCore::DefaultResourceLoadPriority::forResourceType):

  • loader/DefaultResourceLoadPriority.h: Added.
  • loader/LinkLoader.cpp:

(WebCore::LinkLoader::preloadIfNeeded):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::setLoadPriority):
(WebCore::CachedResource::defaultPriorityForResourceType): Deleted.

  • loader/cache/CachedResource.h:

(WebCore::CachedResource::identifierForLoadWithoutResourceLoader const):

File size: 2.9 KB
Line 
1/*
2 * Copyright (C) 2021 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "config.h"
26#include "DefaultResourceLoadPriority.h"
27
28namespace WebCore {
29
30ResourceLoadPriority DefaultResourceLoadPriority::forResourceType(CachedResource::Type type)
31{
32 switch (type) {
33 case CachedResource::Type::MainResource:
34 return ResourceLoadPriority::VeryHigh;
35 case CachedResource::Type::CSSStyleSheet:
36 case CachedResource::Type::Script:
37 return ResourceLoadPriority::High;
38 case CachedResource::Type::SVGFontResource:
39 case CachedResource::Type::MediaResource:
40 case CachedResource::Type::FontResource:
41 case CachedResource::Type::RawResource:
42 case CachedResource::Type::Icon:
43 return ResourceLoadPriority::Medium;
44 case CachedResource::Type::ImageResource:
45 return ResourceLoadPriority::Low;
46#if ENABLE(XSLT)
47 case CachedResource::Type::XSLStyleSheet:
48 return ResourceLoadPriority::High;
49#endif
50 case CachedResource::Type::SVGDocumentResource:
51 return ResourceLoadPriority::Low;
52 case CachedResource::Type::Beacon:
53 case CachedResource::Type::Ping:
54 return ResourceLoadPriority::VeryLow;
55 case CachedResource::Type::LinkPrefetch:
56 return ResourceLoadPriority::VeryLow;
57#if ENABLE(VIDEO)
58 case CachedResource::Type::TextTrackResource:
59 return ResourceLoadPriority::Low;
60#endif
61#if ENABLE(MODEL_ELEMENT)
62 case CachedResource::Type::ModelResource:
63 return ResourceLoadPriority::Medium;
64#endif
65#if ENABLE(APPLICATION_MANIFEST)
66 case CachedResource::Type::ApplicationManifest:
67 return ResourceLoadPriority::Low;
68#endif
69 }
70 ASSERT_NOT_REACHED();
71 return ResourceLoadPriority::Low;
72}
73
74}
Note: See TracBrowser for help on using the repository browser.