| File: | Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore/loader/LinkPreloadResourceClients.h |
| Warning: | line 61, column 9 Call argument for 'this' parameter is uncounted and unsafe |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 | * Copyright (C) 2016 Akamai Technologies Inc. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 18 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include "CachedCSSStyleSheet.h" |
| 30 | #include "CachedFont.h" |
| 31 | #include "CachedFontClient.h" |
| 32 | #include <WebCore/CachedImage.h> |
| 33 | #include <WebCore/CachedImageClient.h> |
| 34 | #include <WebCore/CachedRawResource.h> |
| 35 | #include <WebCore/CachedRawResourceClient.h> |
| 36 | #include <WebCore/CachedResourceHandle.h> |
| 37 | #include "CachedScript.h" |
| 38 | #include <WebCore/CachedStyleSheetClient.h> |
| 39 | #include "CachedTextTrack.h" |
| 40 | #include <wtf/AbstractRefCounted.h> |
| 41 | #include <wtf/RefCounted.h> |
| 42 | #include <wtf/WeakPtr.h> |
| 43 | |
| 44 | namespace WebCore { |
| 45 | |
| 46 | class LinkLoader; |
| 47 | |
| 48 | class LinkPreloadResourceClient : public AbstractRefCounted { |
| 49 | public: |
| 50 | virtual ~LinkPreloadResourceClient() = default; |
| 51 | |
| 52 | void triggerEvents(const CachedResource&); |
| 53 | |
| 54 | virtual void clear() = 0; |
| 55 | |
| 56 | protected: |
| 57 | LinkPreloadResourceClient(LinkLoader&, CachedResource&); |
| 58 | |
| 59 | void addResource(CachedResourceClient& client) |
| 60 | { |
| 61 | m_resource->addClient(client); |
Call argument for 'this' parameter is uncounted and unsafe | |
| 62 | } |
| 63 | |
| 64 | void clearResource(CachedResourceClient& client) |
| 65 | { |
| 66 | if (!m_resource) |
| 67 | return; |
| 68 | |
| 69 | m_resource->removeClient(client); |
| 70 | m_resource = nullptr; |
| 71 | } |
| 72 | |
| 73 | CachedResource* ownedResource() { return m_resource.get(); } |
| 74 | |
| 75 | private: |
| 76 | SingleThreadWeakPtr<LinkLoader> m_loader; |
| 77 | CachedResourceHandle<CachedResource> m_resource; |
| 78 | }; |
| 79 | |
| 80 | class LinkPreloadDefaultResourceClient : public LinkPreloadResourceClient, CachedResourceClient, public RefCounted<LinkPreloadDefaultResourceClient> { |
| 81 | WTF_DEPRECATED_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(LinkPreloadDefaultResourceClient, Loader)public: static_assert(!WTF::usesTZoneHeap<LinkPreloadDefaultResourceClient >(), "Decendents of TZONE_ALLOCATED classes must also be TZONE_ALLOCATED" ); void* operator new(size_t, void* p) { return p; } void* operator new[](size_t, void* p) { return p; } void* operator new(size_t size) { return ::WTF::fastMalloc(size); } void operator delete (void* p) { ::WTF::fastFree(p); } void* operator new[](size_t size) { return ::WTF::fastMalloc(size); } void operator delete [](void* p) { ::WTF::fastFree(p); } void* operator new(size_t , NotNullTag, void* location) { ((void)0); return location; } static void freeAfterDestruction(void* p) { ::WTF::fastFree( p); } using WTFIsFastMallocAllocated = int; private: using __thisIsHereToForceASemicolonAfterThisMacro __attribute__((unused)) = int; |
| 82 | public: |
| 83 | static Ref<LinkPreloadDefaultResourceClient> create(LinkLoader& loader, CachedResource& resource) |
| 84 | { |
| 85 | return adoptRef(*new LinkPreloadDefaultResourceClient(loader, resource)); |
| 86 | } |
| 87 | |
| 88 | // LinkPreloadResourceClient. |
| 89 | void ref() const final { RefCounted::ref(); } |
| 90 | void deref() const final { RefCounted::deref(); } |
| 91 | |
| 92 | private: |
| 93 | LinkPreloadDefaultResourceClient(LinkLoader& loader, CachedResource& resource) |
| 94 | : LinkPreloadResourceClient(loader, resource) |
| 95 | { |
| 96 | addResource(*this); |
| 97 | } |
| 98 | |
| 99 | void notifyFinished(CachedResource& resource, const NetworkLoadMetrics&, LoadWillContinueInAnotherProcess) final { triggerEvents(resource); } |
| 100 | void clear() final { clearResource(*this); } |
| 101 | bool shouldMarkAsReferenced() const final { return false; } |
| 102 | }; |
| 103 | |
| 104 | class LinkPreloadStyleResourceClient : public LinkPreloadResourceClient, public CachedStyleSheetClient, public RefCounted<LinkPreloadStyleResourceClient> { |
| 105 | WTF_DEPRECATED_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(LinkPreloadStyleResourceClient, Loader)public: static_assert(!WTF::usesTZoneHeap<LinkPreloadStyleResourceClient >(), "Decendents of TZONE_ALLOCATED classes must also be TZONE_ALLOCATED" ); void* operator new(size_t, void* p) { return p; } void* operator new[](size_t, void* p) { return p; } void* operator new(size_t size) { return ::WTF::fastMalloc(size); } void operator delete (void* p) { ::WTF::fastFree(p); } void* operator new[](size_t size) { return ::WTF::fastMalloc(size); } void operator delete [](void* p) { ::WTF::fastFree(p); } void* operator new(size_t , NotNullTag, void* location) { ((void)0); return location; } static void freeAfterDestruction(void* p) { ::WTF::fastFree( p); } using WTFIsFastMallocAllocated = int; private: using __thisIsHereToForceASemicolonAfterThisMacro __attribute__((unused)) = int; |
| 106 | public: |
| 107 | static Ref<LinkPreloadStyleResourceClient> create(LinkLoader& loader, CachedCSSStyleSheet& resource) |
| 108 | { |
| 109 | return adoptRef(*new LinkPreloadStyleResourceClient(loader, resource)); |
| 110 | } |
| 111 | |
| 112 | // LinkPreloadResourceClient. |
| 113 | void ref() const final { RefCounted::ref(); } |
| 114 | void deref() const final { RefCounted::deref(); } |
| 115 | |
| 116 | private: |
| 117 | LinkPreloadStyleResourceClient(LinkLoader& loader, CachedCSSStyleSheet& resource) |
| 118 | : LinkPreloadResourceClient(loader, resource) |
| 119 | { |
| 120 | addResource(*this); |
| 121 | } |
| 122 | |
| 123 | void setCSSStyleSheet(const String&, const URL&, ASCIILiteral, const CachedCSSStyleSheet* resource) final |
| 124 | { |
| 125 | ASSERT(resource)((void)0); |
| 126 | ASSERT(ownedResource() == resource)((void)0); |
| 127 | triggerEvents(*resource); |
| 128 | } |
| 129 | |
| 130 | void clear() final { clearResource(*this); } |
| 131 | bool shouldMarkAsReferenced() const final { return false; } |
| 132 | }; |
| 133 | |
| 134 | class LinkPreloadImageResourceClient : public LinkPreloadResourceClient, public CachedImageClient, public RefCounted<LinkPreloadImageResourceClient> { |
| 135 | WTF_DEPRECATED_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(LinkPreloadImageResourceClient, Loader)public: static_assert(!WTF::usesTZoneHeap<LinkPreloadImageResourceClient >(), "Decendents of TZONE_ALLOCATED classes must also be TZONE_ALLOCATED" ); void* operator new(size_t, void* p) { return p; } void* operator new[](size_t, void* p) { return p; } void* operator new(size_t size) { return ::WTF::fastMalloc(size); } void operator delete (void* p) { ::WTF::fastFree(p); } void* operator new[](size_t size) { return ::WTF::fastMalloc(size); } void operator delete [](void* p) { ::WTF::fastFree(p); } void* operator new(size_t , NotNullTag, void* location) { ((void)0); return location; } static void freeAfterDestruction(void* p) { ::WTF::fastFree( p); } using WTFIsFastMallocAllocated = int; private: using __thisIsHereToForceASemicolonAfterThisMacro __attribute__((unused)) = int; |
| 136 | public: |
| 137 | static Ref<LinkPreloadImageResourceClient> create(LinkLoader& loader, CachedImage& resource) |
| 138 | { |
| 139 | return adoptRef(*new LinkPreloadImageResourceClient(loader, resource)); |
| 140 | } |
| 141 | |
| 142 | // LinkPreloadResourceClient. |
| 143 | void ref() const final { RefCounted::ref(); } |
| 144 | void deref() const final { RefCounted::deref(); } |
| 145 | |
| 146 | private: |
| 147 | LinkPreloadImageResourceClient(LinkLoader& loader, CachedImage& resource) |
| 148 | : LinkPreloadResourceClient(loader, resource) |
| 149 | { |
| 150 | addResource(*this); |
| 151 | } |
| 152 | |
| 153 | void notifyFinished(CachedResource& resource, const NetworkLoadMetrics&, LoadWillContinueInAnotherProcess) final { triggerEvents(resource); } |
| 154 | void clear() final { clearResource(*this); } |
| 155 | bool shouldMarkAsReferenced() const final { return false; } |
| 156 | }; |
| 157 | |
| 158 | class LinkPreloadFontResourceClient : public LinkPreloadResourceClient, public CachedFontClient, public RefCounted<LinkPreloadFontResourceClient> { |
| 159 | WTF_DEPRECATED_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(LinkPreloadFontResourceClient, Loader)public: static_assert(!WTF::usesTZoneHeap<LinkPreloadFontResourceClient >(), "Decendents of TZONE_ALLOCATED classes must also be TZONE_ALLOCATED" ); void* operator new(size_t, void* p) { return p; } void* operator new[](size_t, void* p) { return p; } void* operator new(size_t size) { return ::WTF::fastMalloc(size); } void operator delete (void* p) { ::WTF::fastFree(p); } void* operator new[](size_t size) { return ::WTF::fastMalloc(size); } void operator delete [](void* p) { ::WTF::fastFree(p); } void* operator new(size_t , NotNullTag, void* location) { ((void)0); return location; } static void freeAfterDestruction(void* p) { ::WTF::fastFree( p); } using WTFIsFastMallocAllocated = int; private: using __thisIsHereToForceASemicolonAfterThisMacro __attribute__((unused)) = int; |
| 160 | public: |
| 161 | static Ref<LinkPreloadFontResourceClient> create(LinkLoader& loader, CachedFont& resource) |
| 162 | { |
| 163 | return adoptRef(*new LinkPreloadFontResourceClient(loader, resource)); |
| 164 | } |
| 165 | |
| 166 | // LinkPreloadResourceClient. |
| 167 | void ref() const final { RefCounted::ref(); } |
| 168 | void deref() const final { RefCounted::deref(); } |
| 169 | |
| 170 | private: |
| 171 | LinkPreloadFontResourceClient(LinkLoader& loader, CachedFont& resource) |
| 172 | : LinkPreloadResourceClient(loader, resource) |
| 173 | { |
| 174 | addResource(*this); |
| 175 | } |
| 176 | |
| 177 | void fontLoaded(CachedFont& resource) final |
| 178 | { |
| 179 | ASSERT(ownedResource() == &resource)((void)0); |
| 180 | triggerEvents(resource); |
| 181 | } |
| 182 | |
| 183 | void clear() final { clearResource(*this); } |
| 184 | bool shouldMarkAsReferenced() const final { return false; } |
| 185 | }; |
| 186 | |
| 187 | class LinkPreloadRawResourceClient : public LinkPreloadResourceClient, public CachedRawResourceClient, public RefCounted<LinkPreloadRawResourceClient> { |
| 188 | WTF_DEPRECATED_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(LinkPreloadRawResourceClient, Loader)public: static_assert(!WTF::usesTZoneHeap<LinkPreloadRawResourceClient >(), "Decendents of TZONE_ALLOCATED classes must also be TZONE_ALLOCATED" ); void* operator new(size_t, void* p) { return p; } void* operator new[](size_t, void* p) { return p; } void* operator new(size_t size) { return ::WTF::fastMalloc(size); } void operator delete (void* p) { ::WTF::fastFree(p); } void* operator new[](size_t size) { return ::WTF::fastMalloc(size); } void operator delete [](void* p) { ::WTF::fastFree(p); } void* operator new(size_t , NotNullTag, void* location) { ((void)0); return location; } static void freeAfterDestruction(void* p) { ::WTF::fastFree( p); } using WTFIsFastMallocAllocated = int; private: using __thisIsHereToForceASemicolonAfterThisMacro __attribute__((unused)) = int; |
| 189 | public: |
| 190 | static Ref<LinkPreloadRawResourceClient> create(LinkLoader& loader, CachedRawResource& resource) |
| 191 | { |
| 192 | return adoptRef(*new LinkPreloadRawResourceClient(loader, resource)); |
| 193 | } |
| 194 | |
| 195 | // LinkPreloadResourceClient. |
| 196 | void ref() const final { RefCounted::ref(); } |
| 197 | void deref() const final { RefCounted::deref(); } |
| 198 | |
| 199 | private: |
| 200 | LinkPreloadRawResourceClient(LinkLoader& loader, CachedRawResource& resource) |
| 201 | : LinkPreloadResourceClient(loader, resource) |
| 202 | { |
| 203 | addResource(*this); |
| 204 | } |
| 205 | |
| 206 | void notifyFinished(CachedResource& resource, const NetworkLoadMetrics&, LoadWillContinueInAnotherProcess) final { triggerEvents(resource); } |
| 207 | void clear() final { clearResource(*this); } |
| 208 | bool shouldMarkAsReferenced() const final { return false; } |
| 209 | }; |
| 210 | |
| 211 | } |