Shrink various loading-related enums to shrink CachedResource
[WebKit-https.git] / Source / WebCore / loader / SubresourceLoader.cpp
index 365cf5b..2cf70fa 100644 (file)
@@ -94,7 +94,7 @@ SubresourceLoader::SubresourceLoader(Frame& frame, CachedResource& resource, con
 #if ENABLE(CONTENT_EXTENSIONS)
     m_resourceType = toResourceType(resource.type());
 #endif
-    m_canCrossOriginRequestsAskUserForCredentials = resource.type() == CachedResource::MainResource || frame.settings().allowCrossOriginSubresourcesToAskForCredentials();
+    m_canCrossOriginRequestsAskUserForCredentials = resource.type() == CachedResource::Type::MainResource || frame.settings().allowCrossOriginSubresourcesToAskForCredentials();
 }
 
 SubresourceLoader::~SubresourceLoader()
@@ -199,7 +199,7 @@ void SubresourceLoader::willSendRequestInternal(ResourceRequest&& newRequest, co
                 return completionHandler(WTFMove(request));
             }
 
-            if (m_resource->type() == CachedResource::MainResource && !redirectResponse.isNull())
+            if (m_resource->type() == CachedResource::Type::MainResource && !redirectResponse.isNull())
                 m_documentLoader->willContinueMainResourceLoadAfterRedirect(request);
             completionHandler(WTFMove(request));
         });
@@ -283,7 +283,7 @@ void SubresourceLoader::didSendData(unsigned long long bytesSent, unsigned long
 
 bool SubresourceLoader::shouldCreatePreviewLoaderForResponse(const ResourceResponse& response) const
 {
-    if (m_resource->type() != CachedResource::MainResource)
+    if (m_resource->type() != CachedResource::Type::MainResource)
         return false;
 
     if (m_previewLoader)
@@ -373,7 +373,7 @@ void SubresourceLoader::didReceiveResponse(const ResourceResponse& response, Com
 
         // FIXME: Main resources have a different set of rules for multipart than images do.
         // Hopefully we can merge those 2 paths.
-        if (isResponseMultipart && m_resource->type() != CachedResource::MainResource) {
+        if (isResponseMultipart && m_resource->type() != CachedResource::Type::MainResource) {
             m_loadingMultipartContent = true;
 
             // We don't count multiParts in a CachedResourceLoader's request count
@@ -476,46 +476,46 @@ static void logResourceLoaded(Frame* frame, CachedResource::Type type)
 
     String resourceType;
     switch (type) {
-    case CachedResource::MainResource:
+    case CachedResource::Type::MainResource:
         resourceType = DiagnosticLoggingKeys::mainResourceKey();
         break;
-    case CachedResource::ImageResource:
+    case CachedResource::Type::ImageResource:
         resourceType = DiagnosticLoggingKeys::imageKey();
         break;
 #if ENABLE(XSLT)
-    case CachedResource::XSLStyleSheet:
+    case CachedResource::Type::XSLStyleSheet:
 #endif
-    case CachedResource::CSSStyleSheet:
+    case CachedResource::Type::CSSStyleSheet:
         resourceType = DiagnosticLoggingKeys::styleSheetKey();
         break;
-    case CachedResource::Script:
+    case CachedResource::Type::Script:
         resourceType = DiagnosticLoggingKeys::scriptKey();
         break;
-    case CachedResource::FontResource:
+    case CachedResource::Type::FontResource:
 #if ENABLE(SVG_FONTS)
-    case CachedResource::SVGFontResource:
+    case CachedResource::Type::SVGFontResource:
 #endif
         resourceType = DiagnosticLoggingKeys::fontKey();
         break;
-    case CachedResource::Beacon:
+    case CachedResource::Type::Beacon:
         ASSERT_NOT_REACHED();
         break;
-    case CachedResource::MediaResource:
-    case CachedResource::Icon:
-    case CachedResource::RawResource:
+    case CachedResource::Type::MediaResource:
+    case CachedResource::Type::Icon:
+    case CachedResource::Type::RawResource:
         resourceType = DiagnosticLoggingKeys::rawKey();
         break;
-    case CachedResource::SVGDocumentResource:
+    case CachedResource::Type::SVGDocumentResource:
         resourceType = DiagnosticLoggingKeys::svgDocumentKey();
         break;
 #if ENABLE(APPLICATION_MANIFEST)
-    case CachedResource::ApplicationManifest:
+    case CachedResource::Type::ApplicationManifest:
         resourceType = DiagnosticLoggingKeys::applicationManifestKey();
         break;
 #endif
-    case CachedResource::LinkPrefetch:
+    case CachedResource::Type::LinkPrefetch:
 #if ENABLE(VIDEO_TRACK)
-    case CachedResource::TextTrackResource:
+    case CachedResource::Type::TextTrackResource:
 #endif
         resourceType = DiagnosticLoggingKeys::otherKey();
         break;
@@ -627,7 +627,7 @@ void SubresourceLoader::didFinishLoading(const NetworkLoadMetrics& networkLoadMe
         reportResourceTiming(m_resource->response().deprecatedNetworkLoadMetrics());
     }
 
-    if (m_resource->type() != CachedResource::MainResource)
+    if (m_resource->type() != CachedResource::Type::MainResource)
         tracePoint(SubresourceLoadDidEnd);
 
     m_state = Finishing;
@@ -666,7 +666,7 @@ void SubresourceLoader::didFail(const ResourceError& error)
     CachedResourceHandle<CachedResource> protectResource(m_resource);
     m_state = Finishing;
 
-    if (m_resource->type() != CachedResource::MainResource)
+    if (m_resource->type() != CachedResource::Type::MainResource)
         tracePoint(SubresourceLoadDidEnd);
 
     if (m_resource->resourceToRevalidate())
@@ -714,7 +714,7 @@ void SubresourceLoader::didCancel(const ResourceError&)
     if (m_state == Uninitialized)
         return;
 
-    if (m_resource->type() != CachedResource::MainResource)
+    if (m_resource->type() != CachedResource::Type::MainResource)
         tracePoint(SubresourceLoadDidEnd);
 
     m_resource->cancelLoad();