summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Loader/Resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibWeb/Loader/Resource.cpp')
-rw-r--r--Libraries/LibWeb/Loader/Resource.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Loader/Resource.cpp b/Libraries/LibWeb/Loader/Resource.cpp
index e261220b82..2b4e0d61a7 100644
--- a/Libraries/LibWeb/Loader/Resource.cpp
+++ b/Libraries/LibWeb/Loader/Resource.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Function.h>
#include <LibWeb/DOM/HTMLImageElement.h>
#include <LibWeb/Loader/Resource.h>
@@ -43,6 +44,18 @@ Resource::~Resource()
{
}
+void Resource::for_each_client(Function<void(ResourceClient&)> callback)
+{
+ Vector<WeakPtr<ResourceClient>, 16> clients_copy;
+ clients_copy.ensure_capacity(m_clients.size());
+ for (auto* client : m_clients)
+ clients_copy.append(client->make_weak_ptr());
+ for (auto client : clients_copy) {
+ if (client)
+ callback(*client);
+ }
+}
+
void Resource::did_load(Badge<ResourceLoader>, const ByteBuffer& data, const HashMap<String, String, CaseInsensitiveStringTraits>& headers)
{
ASSERT(!m_loaded);