BlobURLStore.h 993 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/HashMap.h>
  8. #include <AK/String.h>
  9. #include <LibJS/Heap/GCPtr.h>
  10. #include <LibJS/Heap/Handle.h>
  11. #include <LibURL/Forward.h>
  12. #include <LibWeb/Forward.h>
  13. namespace Web::FileAPI {
  14. // https://w3c.github.io/FileAPI/#blob-url-entry
  15. struct BlobURLEntry {
  16. JS::Handle<Blob> object; // FIXME: This could also be a MediaSource after we implement MSE.
  17. JS::Handle<HTML::EnvironmentSettingsObject> environment;
  18. };
  19. // https://w3c.github.io/FileAPI/#BlobURLStore
  20. using BlobURLStore = HashMap<String, BlobURLEntry>;
  21. BlobURLStore& blob_url_store();
  22. ErrorOr<String> generate_new_blob_url();
  23. ErrorOr<String> add_entry_to_blob_url_store(JS::NonnullGCPtr<Blob> object);
  24. ErrorOr<void> remove_entry_from_blob_url_store(StringView url);
  25. Optional<BlobURLEntry> resolve_a_blob_url(URL::URL const&);
  26. void run_unloading_cleanup_steps(JS::NonnullGCPtr<DOM::Document>);
  27. }