Title: [233839] trunk/Source/WebCore
Revision
233839
Author
[email protected]
Date
2018-07-14 19:13:40 -0700 (Sat, 14 Jul 2018)

Log Message

Shrink CachedResource and subclasses
https://bugs.webkit.org/show_bug.cgi?id=187546

Reviewed by Daniel Bates.

Shrink CachedResource down from 1384 to 1336 bytes, CachedImage from 1480 to
1424 bytes, and CachedFont a little.

This saves about 23KB on cnn.com.

* loader/ResourceLoaderOptions.h:
* loader/cache/CachedFont.h:
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
* loader/cache/CachedResource.h:
* platform/network/CacheValidation.h:
(WebCore::RedirectChainCacheStatus::RedirectChainCacheStatus):
* platform/network/NetworkLoadMetrics.h:
* platform/network/ParsedContentRange.h:
* platform/network/ResourceRequestBase.h:
* platform/network/ResourceResponseBase.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233838 => 233839)


--- trunk/Source/WebCore/ChangeLog	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/ChangeLog	2018-07-15 02:13:40 UTC (rev 233839)
@@ -1,5 +1,30 @@
 2018-07-14  Simon Fraser  <[email protected]>
 
+        Shrink CachedResource and subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=187546
+
+        Reviewed by Daniel Bates.
+
+        Shrink CachedResource down from 1384 to 1336 bytes, CachedImage from 1480 to
+        1424 bytes, and CachedFont a little.
+        
+        This saves about 23KB on cnn.com.
+
+        * loader/ResourceLoaderOptions.h:
+        * loader/cache/CachedFont.h:
+        * loader/cache/CachedImage.h:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::CachedResource):
+        * loader/cache/CachedResource.h:
+        * platform/network/CacheValidation.h:
+        (WebCore::RedirectChainCacheStatus::RedirectChainCacheStatus):
+        * platform/network/NetworkLoadMetrics.h:
+        * platform/network/ParsedContentRange.h:
+        * platform/network/ResourceRequestBase.h:
+        * platform/network/ResourceResponseBase.h:
+
+2018-07-14  Simon Fraser  <[email protected]>
+
         Shrink some style-related classes and enums
         https://bugs.webkit.org/show_bug.cgi?id=187680
 

Modified: trunk/Source/WebCore/loader/ResourceLoaderOptions.h (233838 => 233839)


--- trunk/Source/WebCore/loader/ResourceLoaderOptions.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/loader/ResourceLoaderOptions.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -139,6 +139,14 @@
         this->mode = mode;
     }
 
+#if ENABLE(SERVICE_WORKER)
+    std::optional<ServiceWorkerRegistrationIdentifier> serviceWorkerRegistrationIdentifier;
+#endif
+    HashSet<HTTPHeaderName, WTF::IntHash<HTTPHeaderName>, WTF::StrongEnumHashTraits<HTTPHeaderName>> httpHeadersToKeep;
+    Vector<String> derivedCachedDataTypesToRetrieve;
+    std::optional<ContentSecurityPolicyResponseHeaders> cspResponseHeaders;
+    unsigned maxRedirectCount { 20 };
+
     SendCallbackPolicy sendLoadCallbacks { SendCallbackPolicy::DoNotSendCallbacks };
     ContentSniffingPolicy sniffContent { ContentSniffingPolicy::DoNotSniffContent };
     ContentEncodingSniffingPolicy sniffContentEncoding { ContentEncodingSniffingPolicy::Sniff };
@@ -153,18 +161,8 @@
     InitiatorContext initiatorContext { InitiatorContext::Document };
     ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All };
     ApplicationCacheMode applicationCacheMode { ApplicationCacheMode::Use };
-#if ENABLE(SERVICE_WORKER)
-    std::optional<ServiceWorkerRegistrationIdentifier> serviceWorkerRegistrationIdentifier;
-#endif
-    HashSet<HTTPHeaderName, WTF::IntHash<HTTPHeaderName>, WTF::StrongEnumHashTraits<HTTPHeaderName>> httpHeadersToKeep;
-
     ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials };
-    unsigned maxRedirectCount { 20 };
-
-    Vector<String> derivedCachedDataTypesToRetrieve;
-
     PreflightPolicy preflightPolicy { PreflightPolicy::Consider };
-    std::optional<ContentSecurityPolicyResponseHeaders> cspResponseHeaders;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/cache/CachedFont.h (233838 => 233839)


--- trunk/Source/WebCore/loader/cache/CachedFont.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/loader/cache/CachedFont.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -76,10 +76,11 @@
 
     void allClientsRemoved() override;
 
-    std::unique_ptr<FontCustomPlatformData> m_fontCustomPlatformData;
     bool m_loadInitiated;
     bool m_hasCreatedFontDataWrappingResource;
 
+    std::unique_ptr<FontCustomPlatformData> m_fontCustomPlatformData;
+
     friend class MemoryCache;
 };
 

Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (233838 => 233839)


--- trunk/Source/WebCore/loader/cache/CachedImage.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -174,10 +174,11 @@
 
     RefPtr<CachedImageObserver> m_imageObserver;
     RefPtr<Image> m_image;
+    std::unique_ptr<SVGImageCache> m_svgImageCache;
+
     MonotonicTime m_lastUpdateImageDataTime;
+
     unsigned m_updateImageDataCount { 0 };
-
-    std::unique_ptr<SVGImageCache> m_svgImageCache;
     bool m_isManuallyCached { false };
     bool m_shouldPaintBrokenImage { true };
     bool m_forceUpdateImageDataEnabledForTesting { false };

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (233838 => 233839)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2018-07-15 02:13:40 UTC (rev 233839)
@@ -117,18 +117,18 @@
 DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, ("CachedResource"));
 
 CachedResource::CachedResource(CachedResourceRequest&& request, Type type, PAL::SessionID sessionID)
-    : m_resourceRequest(request.releaseResourceRequest())
-    , m_options(request.options())
+    : m_options(request.options())
+    , m_resourceRequest(request.releaseResourceRequest())
     , m_decodedDataDeletionTimer(*this, &CachedResource::destroyDecodedData, deadDecodedDataDeletionIntervalForResourceType(type))
     , m_sessionID(sessionID)
-    , m_loadPriority(defaultPriorityForResourceType(type))
     , m_responseTimestamp(WallTime::now())
     , m_fragmentIdentifierForRequest(request.releaseFragmentIdentifier())
     , m_origin(request.releaseOrigin())
     , m_initiatorName(request.initiatorName())
+    , m_loadPriority(defaultPriorityForResourceType(type))
+    , m_type(type)
     , m_isLinkPreload(request.isLinkPreload())
     , m_hasUnknownEncoding(request.isLinkPreload())
-    , m_type(type)
     , m_ignoreForRequestCount(request.ignoreForRequestCount())
 {
     ASSERT(sessionID.isValid());
@@ -152,8 +152,8 @@
     , m_sessionID(sessionID)
     , m_responseTimestamp(WallTime::now())
     , m_fragmentIdentifierForRequest(CachedResourceRequest::splitFragmentIdentifierFromRequestURL(m_resourceRequest))
+    , m_status(Cached)
     , m_type(type)
-    , m_status(Cached)
 {
     ASSERT(sessionID.isValid());
 #ifndef NDEBUG

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (233838 => 233839)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -291,17 +291,6 @@
 
     virtual void setBodyDataFrom(const CachedResource&);
 
-    // FIXME: Make the rest of these data members private and use functions in derived classes instead.
-    HashCountedSet<CachedResourceClient*> m_clients;
-    ResourceRequest m_resourceRequest;
-    std::unique_ptr<ResourceRequest> m_originalRequest; // Needed by Ping loads.
-    RefPtr<SubresourceLoader> m_loader;
-    ResourceLoaderOptions m_options;
-    ResourceResponse m_response;
-    ResourceResponse::Tainting m_responseTainting { ResourceResponse::Tainting::Basic };
-    RefPtr<SharedBuffer> m_data;
-    DeferrableOneShotTimer m_decodedDataDeletionTimer;
-
 private:
     class Callback;
 
@@ -317,11 +306,43 @@
     void addAdditionalRequestHeaders(CachedResourceLoader&);
     void failBeforeStarting();
 
-    HashMap<CachedResourceClient*, std::unique_ptr<Callback>> m_clientsAwaitingCallback;
+protected:
+    ResourceLoaderOptions m_options;
+    ResourceRequest m_resourceRequest;
+    ResourceResponse m_response;
+
+    DeferrableOneShotTimer m_decodedDataDeletionTimer;
+
+    // FIXME: Make the rest of these data members private and use functions in derived classes instead.
+    HashCountedSet<CachedResourceClient*> m_clients;
+    std::unique_ptr<ResourceRequest> m_originalRequest; // Needed by Ping loads.
+    RefPtr<SubresourceLoader> m_loader;
+    RefPtr<SharedBuffer> m_data;
+
+private:
+    MonotonicTime m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache
     PAL::SessionID m_sessionID;
-    ResourceLoadPriority m_loadPriority;
     WallTime m_responseTimestamp;
+    unsigned long m_identifierForLoadWithoutResourceLoader { 0 };
 
+    HashMap<CachedResourceClient*, std::unique_ptr<Callback>> m_clientsAwaitingCallback;
+
+    // These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
+    HashSet<CachedResourceHandleBase*> m_handlesToRevalidate;
+
+    Vector<std::pair<String, String>> m_varyingHeaderValues;
+
+    CachedResourceLoader* m_owningCachedResourceLoader { nullptr }; // only non-null for resources that are not in the cache
+
+    // If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
+    // using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
+    // to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
+    // resources becomes normal resource load.
+    CachedResource* m_resourceToRevalidate { nullptr };
+
+    // If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
+    CachedResource* m_proxyResource { nullptr };
+
     String m_fragmentIdentifierForRequest;
 
     ResourceError m_error;
@@ -328,7 +349,7 @@
     RefPtr<SecurityOrigin> m_origin;
     AtomicString m_initiatorName;
 
-    MonotonicTime m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache
+    RedirectChainCacheStatus m_redirectChainCacheStatus;
 
     unsigned m_encodedSize { 0 };
     unsigned m_decodedSize { 0 };
@@ -336,45 +357,27 @@
     unsigned m_handleCount { 0 };
     unsigned m_preloadCount { 0 };
 
+    unsigned m_status { Pending }; // Status
+
     PreloadResult m_preloadResult { PreloadResult::PreloadNotReferenced };
 
+    ResourceResponse::Tainting m_responseTainting { ResourceResponse::Tainting::Basic };
+    ResourceLoadPriority m_loadPriority;
+
+    Type m_type; // Type
+
     bool m_requestedFromNetworkingLayer { false };
-
     bool m_inCache { false };
     bool m_loading { false };
     bool m_isLinkPreload { false };
     bool m_hasUnknownEncoding { false };
-
     bool m_switchingClientsToRevalidatedResource { false };
+    bool m_ignoreForRequestCount { false };
 
-    Type m_type; // Type
-    unsigned m_status { Pending }; // Status
-
 #ifndef NDEBUG
     bool m_deleted { false };
     unsigned m_lruIndex { 0 };
 #endif
-
-    CachedResourceLoader* m_owningCachedResourceLoader { nullptr }; // only non-null for resources that are not in the cache
-
-    // If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
-    // using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
-    // to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
-    // resources becomes normal resource load.
-    CachedResource* m_resourceToRevalidate { nullptr };
-
-    // If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
-    CachedResource* m_proxyResource { nullptr };
-
-    // These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
-    HashSet<CachedResourceHandleBase*> m_handlesToRevalidate;
-
-    RedirectChainCacheStatus m_redirectChainCacheStatus;
-
-    Vector<std::pair<String, String>> m_varyingHeaderValues;
-
-    unsigned long m_identifierForLoadWithoutResourceLoader { 0 };
-    bool m_ignoreForRequestCount { false };
 };
 
 class CachedResource::Callback {

Modified: trunk/Source/WebCore/platform/network/CacheValidation.h (233838 => 233839)


--- trunk/Source/WebCore/platform/network/CacheValidation.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/platform/network/CacheValidation.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -44,11 +44,11 @@
         CachedRedirection
     };
     RedirectChainCacheStatus()
-        : status(Status::NoRedirection)
-        , endOfValidity(WallTime::infinity())
+        : endOfValidity(WallTime::infinity())
+        , status(Status::NoRedirection)
     { }
+    WallTime endOfValidity;
     Status status;
-    WallTime endOfValidity;
 };
 
 WEBCORE_EXPORT Seconds computeCurrentAge(const ResourceResponse&, WallTime responseTimestamp);

Modified: trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h (233838 => 233839)


--- trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -39,7 +39,7 @@
 
 namespace WebCore {
 
-enum class NetworkLoadPriority {
+enum class NetworkLoadPriority : uint8_t {
     Low,
     Medium,
     High,
@@ -166,9 +166,6 @@
     Seconds responseStart;
     Seconds responseEnd;
 
-    // Whether or not all of the properties (0 or otherwise) have been set.
-    bool complete { false };
-
     // ALPN Protocol ID: https://w3c.github.io/resource-timing/#bib-RFC7301
     String protocol;
 
@@ -175,6 +172,10 @@
     std::optional<String> remoteAddress;
     std::optional<String> connectionIdentifier;
     std::optional<NetworkLoadPriority> priority;
+
+    // Whether or not all of the properties (0 or otherwise) have been set.
+    bool complete { false };
+
     std::optional<HTTPHeaderMap> requestHeaders;
 
     std::optional<uint64_t> requestHeaderBytesSent;

Modified: trunk/Source/WebCore/platform/network/ParsedContentRange.h (233838 => 233839)


--- trunk/Source/WebCore/platform/network/ParsedContentRange.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/platform/network/ParsedContentRange.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -48,10 +48,10 @@
 private:
     template<typename T> static bool isPositive(T);
 
-    bool m_isValid { false };
     int64_t m_firstBytePosition { 0 };
     int64_t m_lastBytePosition { 0 };
     int64_t m_instanceLength { UnknownLength };
+    bool m_isValid { false };
 };
 
 }

Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (233838 => 233839)


--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -83,7 +83,7 @@
     // and <https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-5.2>.
     // FIXME: For some reason the main resource request may be updated more than once. We start off as Unspecified
     // to detect if we need to compute the same-site and top-site state or not. See FIXME in DocumentLoader::startLoadingMainResource().
-    enum class SameSiteDisposition { Unspecified, SameSite, CrossSite };
+    enum class SameSiteDisposition : uint8_t { Unspecified, SameSite, CrossSite };
     bool isSameSiteUnspecified() const { return m_sameSiteDisposition == SameSiteDisposition::Unspecified; }
     WEBCORE_EXPORT bool isSameSite() const; // Whether this request's registrable domain matches the request's initiator's "site for cookies".
     WEBCORE_EXPORT void setIsSameSite(bool);
@@ -164,7 +164,7 @@
     bool hiddenFromInspector() const { return m_hiddenFromInspector; }
     void setHiddenFromInspector(bool hiddenFromInspector) { m_hiddenFromInspector = hiddenFromInspector; }
 
-    enum class Requester { Unspecified, Main, XHR, Fetch, Media, ImportScripts };
+    enum class Requester : uint8_t { Unspecified, Main, XHR, Fetch, Media, ImportScripts };
     Requester requester() const { return m_requester; }
     void setRequester(Requester requester) { m_requester = requester; }
 

Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (233838 => 233839)


--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h	2018-07-15 00:29:28 UTC (rev 233838)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h	2018-07-15 02:13:40 UTC (rev 233839)
@@ -226,15 +226,6 @@
     mutable CacheControlDirectives m_cacheControlDirectives;
     std::optional<SHA1::Digest> m_cacheBodyKey;
 
-    Source m_source { Source::Unknown };
-    Type m_type { Type::Default };
-    Tainting m_tainting { Tainting::Basic };
-
-protected:
-    int m_httpStatusCode { 0 };
-    bool m_isNull { true };
-
-private:
     mutable bool m_haveParsedCacheControlHeader { false };
     mutable bool m_haveParsedAgeHeader { false };
     mutable bool m_haveParsedDateHeader { false };
@@ -242,6 +233,14 @@
     mutable bool m_haveParsedLastModifiedHeader { false };
     mutable bool m_haveParsedContentRangeHeader { false };
     bool m_isRedirected { false };
+
+    Source m_source { Source::Unknown };
+    Type m_type { Type::Default };
+    Tainting m_tainting { Tainting::Basic };
+
+protected:
+    bool m_isNull { true };
+    int m_httpStatusCode { 0 };
 };
 
 inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { return ResourceResponseBase::compare(a, b); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to