summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/ImageDecoding.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-20 10:46:27 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-20 10:56:31 +0100
commite017fe92e6be10a3793232f43973373baf443914 (patch)
tree7e04cd70145477a1a31113a3e3415a63ad57d3f6 /Userland/Libraries/LibWeb/ImageDecoding.cpp
parentb224efe73bf2a47330163368afb90931280ef0b9 (diff)
downloadserenity-e017fe92e6be10a3793232f43973373baf443914.zip
LibWeb: Move ImageDecoder client connection singleton to its own file
This will allow us to use it in more places around LibWeb.
Diffstat (limited to 'Userland/Libraries/LibWeb/ImageDecoding.cpp')
-rw-r--r--Userland/Libraries/LibWeb/ImageDecoding.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/ImageDecoding.cpp b/Userland/Libraries/LibWeb/ImageDecoding.cpp
new file mode 100644
index 0000000000..706c04c97a
--- /dev/null
+++ b/Userland/Libraries/LibWeb/ImageDecoding.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/ImageDecoding.h>
+
+namespace Web {
+
+ImageDecoderClient::Client& image_decoder_client()
+{
+ static RefPtr<ImageDecoderClient::Client> image_decoder_client;
+ if (!image_decoder_client) {
+ image_decoder_client = ImageDecoderClient::Client::construct();
+ image_decoder_client->on_death = [&] {
+ image_decoder_client = nullptr;
+ };
+ }
+ return *image_decoder_client;
+}
+
+}