Changeset 280824 in webkit


Ignore:
Timestamp:
Aug 9, 2021 8:33:03 PM (11 months ago)
Author:
Chris Dumez
Message:

Blob URL changes after loading it
https://bugs.webkit.org/show_bug.cgi?id=228923

Reviewed by Geoff Garen.

Source/WebCore:

Blob URL changes after loading it. This is because we use URLWithBlobURLLifetimeExtension to
extend the lifetime of the Blob URL during the load and URLWithBlobURLLifetimeExtension ends
up creating a new public Blob URL. This is Web-observable so we need a way to extend the
lifetime of a Blob URL without actually generating a new Blob URL.

This patch replaces URLWithBlobURLLifetimeExtension with a new BlobURLHandle class which
extends the lifetime of a Blob URL as long as there are BlobURLHandle objects referring
to it. BlobURLHandle works with both private and public Blob URLs so it replaces
Blob::Handle as well (which I recently introduced via r280547). The Blob URL no longer
changes when we extend its lifetime. Instead, the Blob registry now keeps track of
references to a given Blob and only removes a Blob URL once there are no longer any
references to it.

Test: fast/files/blob-as-frame-url.html

  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::serialize):
(WebCore::CloneSerializer::CloneSerializer):
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::SerializedScriptValue::SerializedScriptValue):
(WebCore::SerializedScriptValue::create):

  • bindings/js/SerializedScriptValue.h:

(WebCore::SerializedScriptValue::blobHandles const):
(WebCore::SerializedScriptValue::SerializedScriptValue):

  • fileapi/Blob.cpp:

(WebCore::Blob::Blob):
(WebCore::Blob::slice const):
(WebCore::Blob::size const):
(WebCore::Blob::handle const):

  • fileapi/Blob.h:

(WebCore::Blob::url const):

  • fileapi/BlobURL.cpp:

(WebCore::BlobURLHandle::BlobURLHandle):
(WebCore::BlobURLHandle::~BlobURLHandle):
(WebCore::BlobURLHandle::registerBlobURLHandleIfNecessary):
(WebCore::BlobURLHandle::unregisterBlobURLHandleIfNecessary):
(WebCore::BlobURLHandle::operator=):
(WebCore::BlobURLHandle::clear):

  • fileapi/BlobURL.h:

(WebCore::BlobURLHandle::BlobURLHandle):
(WebCore::BlobURLHandle::url const):

  • fileapi/ThreadableBlobRegistry.cpp:

(WebCore::ThreadableBlobRegistry::registerBlobURLHandle):
(WebCore::ThreadableBlobRegistry::unregisterBlobURLHandle):

  • fileapi/ThreadableBlobRegistry.h:
  • loader/PolicyChecker.cpp:

(WebCore::FrameLoader::PolicyChecker::extendBlobURLLifetimeIfNecessary const):
(WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy):
(WebCore::FrameLoader::PolicyChecker::checkNewWindowPolicy):

  • loader/PolicyChecker.h:
  • platform/network/BlobRegistry.h:
  • platform/network/BlobRegistryImpl.cpp:

(WebCore::BlobRegistryImpl::registerFileBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURLOptionallyFileBacked):
(WebCore::BlobRegistryImpl::registerBlobURLForSlice):
(WebCore::BlobRegistryImpl::unregisterBlobURL):
(WebCore::BlobRegistryImpl::addBlobData):
(WebCore::BlobRegistryImpl::registerBlobURLHandle):
(WebCore::BlobRegistryImpl::unregisterBlobURLHandle):

  • platform/network/BlobRegistryImpl.h:
  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::setResponseType):
(WebCore::XMLHttpRequest::open):
(WebCore::XMLHttpRequest::prepareToSend):
(WebCore::XMLHttpRequest::send):
(WebCore::XMLHttpRequest::createRequest):
(WebCore::XMLHttpRequest::clearRequest):
(WebCore::XMLHttpRequest::didFinishLoading):

  • xml/XMLHttpRequest.h:

Source/WebKit:

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::registerBlobURLHandle):
(WebKit::NetworkConnectionToWebProcess::unregisterBlobURLHandle):

  • NetworkProcess/NetworkConnectionToWebProcess.h:
  • NetworkProcess/NetworkConnectionToWebProcess.messages.in:
  • NetworkProcess/NetworkProcessPlatformStrategies.cpp:

(WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):

  • WebProcess/FileAPI/BlobRegistryProxy.cpp:

(WebKit::BlobRegistryProxy::registerBlobURLHandle):
(WebKit::BlobRegistryProxy::unregisterBlobURLHandle):

  • WebProcess/FileAPI/BlobRegistryProxy.h:

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebPlatformStrategies.mm:

Source/WebKitLegacy/win:

  • WebCoreSupport/WebPlatformStrategies.cpp:

LayoutTests:

Add layout test coverage.

  • fast/files/blob-as-frame-url-expected.txt: Added.
  • fast/files/blob-as-frame-url.html: Added.
Location:
trunk
Files:
2 added
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280822 r280824  
     12021-08-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob URL changes after loading it
     4        https://bugs.webkit.org/show_bug.cgi?id=228923
     5
     6        Reviewed by Geoff Garen.
     7
     8        Add layout test coverage.
     9
     10        * fast/files/blob-as-frame-url-expected.txt: Added.
     11        * fast/files/blob-as-frame-url.html: Added.
     12
    1132021-08-09  Lauro Moura  <lmoura@igalia.com>
    214
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-then-revoke-expected.txt

    r259900 r280824  
    1 CONSOLE MESSAGE: PASS: URL was revoked
    21Download started.
    32Downloading URL with suggested filename "foo.txt"
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-then-revoke.html

    r231714 r280824  
    2424    // Revoke the URL right away.
    2525    window.URL.revokeObjectURL(link.href);
    26 
    27     // Make sure the URL was revoked.
    28     xhr = new XMLHttpRequest();
    29     xhr.open("GET", link.href, false);
    30     try {
    31         xhr.send(null);
    32     } catch (e) {
    33     }
    34     if (xhr.status == 200)
    35         console.log("FAIL: URL was not revoked");
    36     else
    37         console.log("PASS: URL was revoked");
    3826}
    3927runTest();
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/url-in-tags.window-expected.txt

    r267651 r280824  
    1 
    2 Harness Error (TIMEOUT), message = null
    31
    42PASS Blob URLs can be used in <script> tags
    53PASS Blob URLs can be used in iframes, and are treated same origin
    6 TIMEOUT Blob URL fragment is implemented. Test timed out
     4PASS Blob URL fragment is implemented.
    75
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/url/url-reload.window-expected.txt

    r263059 r280824  
    22Harness Error (TIMEOUT), message = null
    33
    4 TIMEOUT Reloading a blob URL succeeds. Test timed out
     4PASS Reloading a blob URL succeeds.
    55TIMEOUT Reloading a blob URL succeeds even if the URL was revoked. Test timed out
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/inheritance/history.sub-expected.txt

    r279838 r280824  
    22PASS History navigation: "about:blank" document is navigated back from history same-origin.
    33PASS History navigation: "about:blank" document is navigated back from history cross-origin.
    4 FAIL History navigation: blob URL document is navigated back from history same-origin. step_wait_func: Wait for the popup to navigate. Timed out waiting on condition
    5 FAIL History navigation: blob URL document is navigated back from history cross-origin. step_wait_func: Wait for the popup to navigate. Timed out waiting on condition
    6 FAIL History navigation: blob URL document is navigated back from history (without bfcache on Firefox) same-origin. step_wait_func: Wait for the popup to navigate. Timed out waiting on condition
    7 FAIL History navigation: blob URL document is navigated back from history (without bfcache on Firefox) cross-origin. step_wait_func: Wait for the popup to navigate. Timed out waiting on condition
     4FAIL History navigation: blob URL document is navigated back from history same-origin. assert_equals: Image should be blocked by CSP inherited from navigation initiator. expected "img blocked" but got "img loaded"
     5FAIL History navigation: blob URL document is navigated back from history cross-origin. assert_equals: Image should be blocked by CSP inherited from navigation initiator. expected "img blocked" but got "img loaded"
     6FAIL History navigation: blob URL document is navigated back from history (without bfcache on Firefox) same-origin. assert_equals: Image should be blocked by CSP inherited from navigation initiator. expected "img blocked" but got "img loaded"
     7FAIL History navigation: blob URL document is navigated back from history (without bfcache on Firefox) cross-origin. assert_equals: Image should be blocked by CSP inherited from navigation initiator. expected "img blocked" but got "img loaded"
    88
  • trunk/Source/WebCore/ChangeLog

    r280807 r280824  
     12021-08-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob URL changes after loading it
     4        https://bugs.webkit.org/show_bug.cgi?id=228923
     5
     6        Reviewed by Geoff Garen.
     7
     8        Blob URL changes after loading it. This is because we use URLWithBlobURLLifetimeExtension to
     9        extend the lifetime of the Blob URL during the load and URLWithBlobURLLifetimeExtension ends
     10        up creating a new public Blob URL. This is Web-observable so we need a way to extend the
     11        lifetime of a Blob URL without actually generating a new Blob URL.
     12
     13        This patch replaces URLWithBlobURLLifetimeExtension with a new BlobURLHandle class which
     14        extends the lifetime of a Blob URL as long as there are BlobURLHandle objects referring
     15        to it. BlobURLHandle works with both private and public Blob URLs so it replaces
     16        Blob::Handle as well (which I recently introduced via r280547). The Blob URL no longer
     17        changes when we extend its lifetime. Instead, the Blob registry now keeps track of
     18        references to a given Blob and only removes a Blob URL once there are no longer any
     19        references to it.
     20
     21        Test: fast/files/blob-as-frame-url.html
     22
     23        * Headers.cmake:
     24        * WebCore.xcodeproj/project.pbxproj:
     25        * bindings/js/SerializedScriptValue.cpp:
     26        (WebCore::CloneSerializer::serialize):
     27        (WebCore::CloneSerializer::CloneSerializer):
     28        (WebCore::CloneSerializer::dumpIfTerminal):
     29        (WebCore::SerializedScriptValue::SerializedScriptValue):
     30        (WebCore::SerializedScriptValue::create):
     31        * bindings/js/SerializedScriptValue.h:
     32        (WebCore::SerializedScriptValue::blobHandles const):
     33        (WebCore::SerializedScriptValue::SerializedScriptValue):
     34        * fileapi/Blob.cpp:
     35        (WebCore::Blob::Blob):
     36        (WebCore::Blob::slice const):
     37        (WebCore::Blob::size const):
     38        (WebCore::Blob::handle const):
     39        * fileapi/Blob.h:
     40        (WebCore::Blob::url const):
     41        * fileapi/BlobURL.cpp:
     42        (WebCore::BlobURLHandle::BlobURLHandle):
     43        (WebCore::BlobURLHandle::~BlobURLHandle):
     44        (WebCore::BlobURLHandle::registerBlobURLHandleIfNecessary):
     45        (WebCore::BlobURLHandle::unregisterBlobURLHandleIfNecessary):
     46        (WebCore::BlobURLHandle::operator=):
     47        (WebCore::BlobURLHandle::clear):
     48        * fileapi/BlobURL.h:
     49        (WebCore::BlobURLHandle::BlobURLHandle):
     50        (WebCore::BlobURLHandle::url const):
     51        * fileapi/ThreadableBlobRegistry.cpp:
     52        (WebCore::ThreadableBlobRegistry::registerBlobURLHandle):
     53        (WebCore::ThreadableBlobRegistry::unregisterBlobURLHandle):
     54        * fileapi/ThreadableBlobRegistry.h:
     55        * loader/PolicyChecker.cpp:
     56        (WebCore::FrameLoader::PolicyChecker::extendBlobURLLifetimeIfNecessary const):
     57        (WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy):
     58        (WebCore::FrameLoader::PolicyChecker::checkNewWindowPolicy):
     59        * loader/PolicyChecker.h:
     60        * platform/network/BlobRegistry.h:
     61        * platform/network/BlobRegistryImpl.cpp:
     62        (WebCore::BlobRegistryImpl::registerFileBlobURL):
     63        (WebCore::BlobRegistryImpl::registerBlobURL):
     64        (WebCore::BlobRegistryImpl::registerBlobURLOptionallyFileBacked):
     65        (WebCore::BlobRegistryImpl::registerBlobURLForSlice):
     66        (WebCore::BlobRegistryImpl::unregisterBlobURL):
     67        (WebCore::BlobRegistryImpl::addBlobData):
     68        (WebCore::BlobRegistryImpl::registerBlobURLHandle):
     69        (WebCore::BlobRegistryImpl::unregisterBlobURLHandle):
     70        * platform/network/BlobRegistryImpl.h:
     71        * xml/XMLHttpRequest.cpp:
     72        (WebCore::XMLHttpRequest::setResponseType):
     73        (WebCore::XMLHttpRequest::open):
     74        (WebCore::XMLHttpRequest::prepareToSend):
     75        (WebCore::XMLHttpRequest::send):
     76        (WebCore::XMLHttpRequest::createRequest):
     77        (WebCore::XMLHttpRequest::clearRequest):
     78        (WebCore::XMLHttpRequest::didFinishLoading):
     79        * xml/XMLHttpRequest.h:
     80
    1812021-08-09  Simon Fraser  <simon.fraser@apple.com>
    282
  • trunk/Source/WebCore/Headers.cmake

    r280504 r280824  
    599599    fileapi/Blob.h
    600600    fileapi/BlobPropertyBag.h
     601    fileapi/BlobURL.h
    601602    fileapi/EndingType.h
    602603    fileapi/File.h
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r280758 r280824  
    30383038                976D6C79122B8A3D001FD1F7 /* Blob.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5A122B8A3D001FD1F7 /* Blob.h */; settings = {ATTRIBUTES = (Private, ); }; };
    30393039                976D6C7C122B8A3D001FD1F7 /* BlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5D122B8A3D001FD1F7 /* BlobBuilder.h */; };
    3040                 976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C60122B8A3D001FD1F7 /* BlobURL.h */; };
     3040                976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C60122B8A3D001FD1F7 /* BlobURL.h */; settings = {ATTRIBUTES = (Private, ); }; };
    30413041                976D6C81122B8A3D001FD1F7 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C62122B8A3D001FD1F7 /* File.h */; settings = {ATTRIBUTES = (Private, ); }; };
    30423042                976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C67122B8A3D001FD1F7 /* FileList.h */; settings = {ATTRIBUTES = (Private, ); }; };
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r280547 r280824  
    601601            WasmMemoryHandleArray& wasmMemoryHandles,
    602602#endif
    603         Vector<Blob::Handle>& blobHandles, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers)
     603        Vector<BlobURLHandle>& blobHandles, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers)
    604604    {
    605605        CloneSerializer serializer(lexicalGlobalObject, messagePorts, arrayBuffers, imageBitmaps,
     
    648648            WasmMemoryHandleArray& wasmMemoryHandles,
    649649#endif
    650         Vector<Blob::Handle>& blobHandles, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers)
     650        Vector<BlobURLHandle>& blobHandles, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers)
    651651        : CloneBase(lexicalGlobalObject)
    652652        , m_buffer(out)
     
    12981298                write(CryptoKeyTag);
    12991299                Vector<uint8_t> serializedKey;
    1300                 Vector<Blob::Handle> dummyBlobHandles;
     1300                Vector<BlobURLHandle> dummyBlobHandles;
    13011301                Vector<RefPtr<MessagePort>> dummyMessagePorts;
    13021302                Vector<RefPtr<JSC::ArrayBuffer>> dummyArrayBuffers;
     
    17611761
    17621762    Vector<uint8_t>& m_buffer;
    1763     Vector<Blob::Handle>& m_blobHandles;
     1763    Vector<BlobURLHandle>& m_blobHandles;
    17641764    ObjectPool m_objectPool;
    17651765    ObjectPool m_transferredMessagePorts;
     
    39163916}
    39173917
    3918 SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, const Vector<Blob::Handle>& blobHandles, std::unique_ptr<ArrayBufferContentsArray> arrayBufferContentsArray, std::unique_ptr<ArrayBufferContentsArray> sharedBufferContentsArray, Vector<std::optional<ImageBitmapBacking>>&& backingStores
     3918SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>&& buffer, const Vector<BlobURLHandle>& blobHandles, std::unique_ptr<ArrayBufferContentsArray> arrayBufferContentsArray, std::unique_ptr<ArrayBufferContentsArray> sharedBufferContentsArray, Vector<std::optional<ImageBitmapBacking>>&& backingStores
    39193919#if ENABLE(OFFSCREEN_CANVAS_IN_WORKERS)
    39203920        , Vector<std::unique_ptr<DetachedOffscreenCanvas>>&& detachedOffscreenCanvases
     
    40664066{
    40674067    Vector<uint8_t> buffer;
    4068     Vector<Blob::Handle> blobHandles;
     4068    Vector<BlobURLHandle> blobHandles;
    40694069    Vector<RefPtr<MessagePort>> dummyMessagePorts;
    40704070    Vector<RefPtr<ImageBitmap>> dummyImageBitmaps;
     
    42184218
    42194219    Vector<uint8_t> buffer;
    4220     Vector<Blob::Handle> blobHandles;
     4220    Vector<BlobURLHandle> blobHandles;
    42214221#if ENABLE(WEBASSEMBLY)
    42224222    WasmModuleArray wasmModules;
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.h

    r280547 r280824  
    100100
    101101    Vector<String> blobURLs() const;
    102     const Vector<Blob::Handle>& blobHandles() const { return m_blobHandles; }
     102    const Vector<BlobURLHandle>& blobHandles() const { return m_blobHandles; }
    103103    void writeBlobsToDiskForIndexedDB(CompletionHandler<void(IDBValue&&)>&&);
    104104    IDBValue writeBlobsToDiskForIndexedDBSynchronously();
     
    124124        );
    125125
    126     SerializedScriptValue(Vector<unsigned char>&&, const Vector<Blob::Handle>& blobHandles, std::unique_ptr<ArrayBufferContentsArray>, std::unique_ptr<ArrayBufferContentsArray> sharedBuffers, Vector<std::optional<ImageBitmapBacking>>&& backingStores
     126    SerializedScriptValue(Vector<unsigned char>&&, const Vector<BlobURLHandle>& blobHandles, std::unique_ptr<ArrayBufferContentsArray>, std::unique_ptr<ArrayBufferContentsArray> sharedBuffers, Vector<std::optional<ImageBitmapBacking>>&& backingStores
    127127#if ENABLE(OFFSCREEN_CANVAS_IN_WORKERS)
    128128        , Vector<std::unique_ptr<DetachedOffscreenCanvas>>&& = { }
     
    153153    std::unique_ptr<WasmMemoryHandleArray> m_wasmMemoryHandlesArray;
    154154#endif
    155     Vector<Blob::Handle> m_blobHandles;
     155    Vector<BlobURLHandle> m_blobHandles;
    156156    size_t m_memoryCost { 0 };
    157157};
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r280547 r280824  
    7777}
    7878
    79 // Unregisters the Blob's internal URL upon destruction. This can be used to extend the lifetime of the Blob data
    80 // without actually keeping the Blob object alive.
    81 class BlobInternalURL : public ThreadSafeRefCounted<BlobInternalURL> {
    82 public:
    83     static Ref<BlobInternalURL> create(Vector<BlobPart>&& blobParts, const String& contentType)
    84     {
    85         return adoptRef(*new BlobInternalURL(WTFMove(blobParts), contentType));
    86     }
    87 
    88     static Ref<BlobInternalURL> createForDeserialization(const URL& sourceURL, const String& fileBackedPath, const String& type)
    89     {
    90         return adoptRef(*new BlobInternalURL(sourceURL, fileBackedPath, type));
    91     }
    92 
    93     static Ref<BlobInternalURL> createForSlice(const URL& sourceURL, long long start, long long end, const String& type)
    94     {
    95         return adoptRef(*new BlobInternalURL(sourceURL, start, end, type));
    96     }
    97 
    98     static Ref<BlobInternalURL> adoptInternalURL(const URL& url)
    99     {
    100         return adoptRef(*new BlobInternalURL(crossThreadCopy(url)));
    101     }
    102 
    103     ~BlobInternalURL()
    104     {
    105         ThreadableBlobRegistry::unregisterBlobURL(m_internalURL);
    106     }
    107 
    108     URL url() const { return m_internalURL.isolatedCopy(); }
    109 
    110 private:
    111     BlobInternalURL(Vector<BlobPart>&& blobParts, const String& contentType)
    112         : m_internalURL(BlobURL::createInternalURL())
    113     {
    114         ThreadableBlobRegistry::registerBlobURL(m_internalURL, WTFMove(blobParts), contentType);
    115     }
    116     BlobInternalURL(const URL& sourceURL, long long start, long long end, const String& type)
    117         : m_internalURL(BlobURL::createInternalURL())
    118     {
    119         ThreadableBlobRegistry::registerBlobURLForSlice(m_internalURL, sourceURL, start, end, type);
    120     }
    121     BlobInternalURL(const URL& sourceURL, const String& fileBackedPath, const String& type)
    122         : m_internalURL(BlobURL::createInternalURL())
    123     {
    124         if (fileBackedPath.isEmpty())
    125             ThreadableBlobRegistry::registerBlobURL(nullptr, m_internalURL, sourceURL);
    126         else
    127             ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(m_internalURL, sourceURL, fileBackedPath, type);
    128     }
    129     BlobInternalURL(URL&& internalURL)
    130         : m_internalURL(WTFMove(internalURL))
    131     { }
    132 
    133     URL m_internalURL;
    134 };
    135 
    13679Blob::Blob(UninitializedContructor, ScriptExecutionContext* context, URL&& url, String&& type)
    13780    : ActiveDOMObject(context)
    13881    , m_type(WTFMove(type))
    139     , m_internalURL(BlobInternalURL::adoptInternalURL(url))
     82    , m_internalURL(WTFMove(url))
    14083{
    14184}
     
    14487    : ActiveDOMObject(context)
    14588    , m_size(0)
    146     , m_internalURL(BlobInternalURL::create({ }, { }))
    147 {
     89    , m_internalURL(BlobURL::createInternalURL())
     90{
     91    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { }, { });
    14892}
    14993
     
    164108    : ActiveDOMObject(&context)
    165109    , m_type(normalizedContentType(propertyBag.type))
    166     , m_internalURL(BlobInternalURL::create(buildBlobData(WTFMove(blobPartVariants), propertyBag), m_type))
    167 {
     110    , m_internalURL(BlobURL::createInternalURL())
     111{
     112    ThreadableBlobRegistry::registerBlobURL(m_internalURL, buildBlobData(WTFMove(blobPartVariants), propertyBag), m_type);
    168113}
    169114
     
    172117    , m_type(contentType)
    173118    , m_size(data.size())
    174     , m_internalURL(BlobInternalURL::create({ BlobPart(WTFMove(data)) }, contentType))
    175 {
     119    , m_internalURL(BlobURL::createInternalURL())
     120{
     121    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { BlobPart(WTFMove(data)) }, contentType);
    176122}
    177123
     
    180126    , m_type(blob.type())
    181127    , m_size(blob.size())
    182     , m_internalURL(BlobInternalURL::create({ BlobPart(blob.url()) } , m_type))
    183 {
     128    , m_internalURL(BlobURL::createInternalURL())
     129{
     130    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { BlobPart(blob.url()) } , m_type);
    184131}
    185132
     
    188135    , m_type(normalizedContentType(type))
    189136    , m_size(size)
    190     , m_internalURL(BlobInternalURL::createForDeserialization(srcURL, fileBackedPath, m_type))
    191 {
     137    , m_internalURL(BlobURL::createInternalURL())
     138{
     139    if (fileBackedPath.isEmpty())
     140        ThreadableBlobRegistry::registerBlobURL(nullptr, m_internalURL, srcURL);
     141    else
     142        ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(m_internalURL, srcURL, fileBackedPath, m_type);
    192143}
    193144
     
    195146    : ActiveDOMObject(context)
    196147    , m_type(normalizedContentType(type))
    197     , m_internalURL(BlobInternalURL::createForSlice(srcURL, start, end, m_type))
     148    , m_internalURL(BlobURL::createInternalURL())
    198149    // m_size is not necessarily equal to end - start so we do not initialize it here.
    199150{
     151    ThreadableBlobRegistry::registerBlobURLForSlice(m_internalURL, srcURL, start, end, m_type);
    200152}
    201153
     
    206158}
    207159
    208 URL Blob::url() const
    209 {
    210     return m_internalURL->url();
    211 }
    212 
    213160Ref<Blob> Blob::slice(ScriptExecutionContext& context, long long start, long long end, const String& contentType) const
    214161{
    215     auto blob = adoptRef(*new Blob(&context, m_internalURL->url(), start, end, contentType));
     162    auto blob = adoptRef(*new Blob(&context, m_internalURL, start, end, contentType));
    216163    blob->suspendIfNeeded();
    217164    return blob;
     
    223170        // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to
    224171        // come up with an exception to throw if file size is not representable.
    225         unsigned long long actualSize = ThreadableBlobRegistry::blobSize(m_internalURL->url());
     172        unsigned long long actualSize = ThreadableBlobRegistry::blobSize(m_internalURL);
    226173        m_size = isInBounds<long long>(actualSize) ? actualSize : 0;
    227174    }
     
    396343}
    397344
    398 Blob::Handle Blob::handle() const
    399 {
    400     return Handle { m_internalURL.copyRef() };
    401 }
    402 
    403 Blob::Handle::Handle(Ref<BlobInternalURL>&& internalURL)
    404     : m_internalURL(WTFMove(internalURL))
    405 { }
    406 
    407 Blob::Handle::~Handle() = default;
    408 
    409 Blob::Handle::Handle(Handle&&) = default;
    410 Blob::Handle::Handle(const Handle&) = default;
    411 
    412 URL Blob::Handle::url() const
    413 {
    414     return m_internalURL->url();
     345BlobURLHandle Blob::handle() const
     346{
     347    return BlobURLHandle { m_internalURL };
    415348}
    416349
  • trunk/Source/WebCore/fileapi/Blob.h

    r280547 r280824  
    3333
    3434#include "BlobPropertyBag.h"
     35#include "BlobURL.h"
    3536#include "FileReaderLoader.h"
    3637#include "ScriptExecutionContext.h"
     
    5859
    5960using BlobPartVariant = Variant<RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>, RefPtr<Blob>, String>;
    60 class BlobInternalURL;
    6161
    6262class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Blob>, public ActiveDOMObject {
     
    9494    virtual ~Blob();
    9595
    96     WEBCORE_EXPORT URL url() const;
     96    URL url() const { return m_internalURL; }
    9797    const String& type() const { return m_type; }
    9898
     
    118118    ExceptionOr<Ref<ReadableStream>> stream(ScriptExecutionContext&);
    119119
    120     class Handle {
    121     public:
    122         explicit Handle(Ref<BlobInternalURL>&&);
    123         ~Handle();
    124         Handle(Handle&&);
    125         Handle(const Handle&);
    126         URL url() const;
    127     private:
    128         Ref<BlobInternalURL> m_internalURL;
    129     };
    130 
    131120    // Keeping the handle alive will keep the Blob data alive (but not the Blob object).
    132     Handle handle() const;
     121    BlobURLHandle handle() const;
    133122
    134123protected:
     
    161150    // as an identifier for this blob. The internal URL is never used to source the blob's content
    162151    // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
    163     Ref<BlobInternalURL> m_internalURL;
     152    URL m_internalURL;
    164153
    165154    HashSet<std::unique_ptr<BlobLoader>> m_blobLoaders;
  • trunk/Source/WebCore/fileapi/BlobURL.cpp

    r279881 r280824  
    9797}
    9898
    99 URLWithBlobURLLifetimeExtension::URLWithBlobURLLifetimeExtension(const URL& url)
    100     : m_url(url)
     99BlobURLHandle::BlobURLHandle(const BlobURLHandle& other)
     100    : m_url(other.m_url.isolatedCopy())
    101101{
    102     extendBlobURLLifetimeIfNecessary();
     102    registerBlobURLHandleIfNecessary();
    103103}
    104104
    105 URLWithBlobURLLifetimeExtension::~URLWithBlobURLLifetimeExtension()
     105BlobURLHandle::BlobURLHandle(const URL& url)
     106    : m_url(url.isolatedCopy())
    106107{
    107     unregisterCurrentURLIfNecessary();
     108    ASSERT(m_url.protocolIsBlob());
     109    registerBlobURLHandleIfNecessary();
    108110}
    109111
    110 void URLWithBlobURLLifetimeExtension::extendBlobURLLifetimeIfNecessary()
     112BlobURLHandle::~BlobURLHandle()
    111113{
    112     if (m_url.protocolIsBlob()) {
    113         auto origin = SecurityOrigin::create(BlobURL::getOriginURL(m_url));
    114         URL temporaryBlobURL = BlobURL::createPublicURL(origin.ptr());
    115         ThreadableBlobRegistry::registerBlobURL(origin.ptr(), temporaryBlobURL, m_url);
    116         m_url = WTFMove(temporaryBlobURL);
    117     }
     114    unregisterBlobURLHandleIfNecessary();
    118115}
    119116
    120 void URLWithBlobURLLifetimeExtension::unregisterCurrentURLIfNecessary()
     117void BlobURLHandle::registerBlobURLHandleIfNecessary()
    121118{
    122119    if (m_url.protocolIsBlob())
    123         ThreadableBlobRegistry::unregisterBlobURL(m_url);
     120        ThreadableBlobRegistry::registerBlobURLHandle(m_url);
    124121}
    125122
    126 URLWithBlobURLLifetimeExtension& URLWithBlobURLLifetimeExtension::operator=(URLWithBlobURLLifetimeExtension&& other)
     123void BlobURLHandle::unregisterBlobURLHandleIfNecessary()
    127124{
    128     unregisterCurrentURLIfNecessary();
     125    if (m_url.protocolIsBlob())
     126        ThreadableBlobRegistry::unregisterBlobURLHandle(m_url);
     127}
     128
     129BlobURLHandle& BlobURLHandle::operator=(const BlobURLHandle& other)
     130{
     131    if (this == &other)
     132        return *this;
     133
     134    unregisterBlobURLHandleIfNecessary();
     135    m_url = other.m_url.isolatedCopy();
     136    registerBlobURLHandleIfNecessary();
     137
     138    return *this;
     139}
     140
     141void BlobURLHandle::clear()
     142{
     143    unregisterBlobURLHandleIfNecessary();
     144    m_url = { };
     145}
     146
     147BlobURLHandle& BlobURLHandle::operator=(BlobURLHandle&& other)
     148{
     149    unregisterBlobURLHandleIfNecessary();
    129150    m_url = std::exchange(other.m_url, { });
    130151    return *this;
    131152}
    132153
    133 URLWithBlobURLLifetimeExtension& URLWithBlobURLLifetimeExtension::operator=(URL&& url)
     154BlobURLHandle& BlobURLHandle::operator=(const URL& url)
    134155{
    135     unregisterCurrentURLIfNecessary();
    136     m_url = WTFMove(url);
    137     extendBlobURLLifetimeIfNecessary();
     156    ASSERT(url.protocolIsBlob());
     157    unregisterBlobURLHandleIfNecessary();
     158    m_url = url.isolatedCopy();
     159    registerBlobURLHandleIfNecessary();
    138160    return *this;
    139161}
  • trunk/Source/WebCore/fileapi/BlobURL.h

    r279881 r280824  
    5959};
    6060
    61 class URLWithBlobURLLifetimeExtension {
     61// Extends the lifetime of the Blob URL. This means that the blob URL will remain valid after
     62// revokeObjectURL() has been called, as long as BlobURLHandle objects refer to the blob URL.
     63class BlobURLHandle {
    6264    WTF_MAKE_FAST_ALLOCATED;
    63     WTF_MAKE_NONCOPYABLE(URLWithBlobURLLifetimeExtension);
    6465public:
    65     URLWithBlobURLLifetimeExtension() = default;
    66     explicit URLWithBlobURLLifetimeExtension(const URL&);
    67     ~URLWithBlobURLLifetimeExtension();
     66    BlobURLHandle() = default;
     67    explicit BlobURLHandle(const URL&);
     68    ~BlobURLHandle();
    6869
    69     URLWithBlobURLLifetimeExtension(URLWithBlobURLLifetimeExtension&& other)
     70    BlobURLHandle(const BlobURLHandle&);
     71    BlobURLHandle(BlobURLHandle&& other)
    7072        : m_url(std::exchange(other.m_url, { }))
    7173    { }
    7274
    73     URLWithBlobURLLifetimeExtension& operator=(URLWithBlobURLLifetimeExtension&&);
    74     URLWithBlobURLLifetimeExtension& operator=(URL&&);
     75    BlobURLHandle& operator=(const BlobURLHandle&);
     76    BlobURLHandle& operator=(BlobURLHandle&&);
     77    BlobURLHandle& operator=(const URL&);
    7578
    76     operator const URL&() const { return m_url; }
    77     const URL& url() const { return m_url; }
     79    URL url() const { return m_url.isolatedCopy(); }
     80
     81    void clear();
    7882
    7983private:
    80     void unregisterCurrentURLIfNecessary();
    81     void extendBlobURLLifetimeIfNecessary();
     84    void unregisterBlobURLHandleIfNecessary();
     85    void registerBlobURLHandleIfNecessary();
    8286
    8387    URL m_url;
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp

    r276677 r280824  
    156156        originMap()->remove(url.string());
    157157
    158     if (isMainThread()) {
     158    ensureOnMainThread([url = url.isolatedCopy()] {
    159159        blobRegistry().unregisterBlobURL(url);
    160         return;
    161     }
    162     callOnMainThread([url = url.isolatedCopy()] {
    163         blobRegistry().unregisterBlobURL(url);
     160    });
     161}
     162
     163void ThreadableBlobRegistry::registerBlobURLHandle(const URL& url)
     164{
     165    ensureOnMainThread([url = url.isolatedCopy()] {
     166        blobRegistry().registerBlobURLHandle(url);
     167    });
     168}
     169
     170void ThreadableBlobRegistry::unregisterBlobURLHandle(const URL& url)
     171{
     172    ensureOnMainThread([url = url.isolatedCopy()] {
     173        blobRegistry().unregisterBlobURLHandle(url);
    164174    });
    165175}
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.h

    r276677 r280824  
    4848    static void unregisterBlobURL(const URL&);
    4949
     50    static void registerBlobURLHandle(const URL&);
     51    static void unregisterBlobURLHandle(const URL&);
     52
    5053    static unsigned long long blobSize(const URL&);
    5154
  • trunk/Source/WebCore/loader/PolicyChecker.cpp

    r279881 r280824  
    105105}
    106106
    107 URLWithBlobURLLifetimeExtension FrameLoader::PolicyChecker::extendBlobURLLifetimeIfNecessary(ResourceRequest& request, DocumentLoader* loader, PolicyDecisionMode mode) const
     107BlobURLHandle FrameLoader::PolicyChecker::extendBlobURLLifetimeIfNecessary(const ResourceRequest& request, PolicyDecisionMode mode) const
    108108{
    109109    if (mode != PolicyDecisionMode::Asynchronous || !request.url().protocolIsBlob())
    110110        return { };
    111111
    112     URLWithBlobURLLifetimeExtension urlWithLifetimeExtension(request.url());
    113     request.setURL(urlWithLifetimeExtension);
    114     if (loader)
    115         loader->request().setURL(urlWithLifetimeExtension);
    116 
    117     return urlWithLifetimeExtension;
     112    return BlobURLHandle { request.url() };
    118113}
    119114
     
    198193    m_frame.loader().clearProvisionalLoadForPolicyCheck();
    199194
    200     auto blobURLLifetimeExtension = extendBlobURLLifetimeIfNecessary(request, loader, policyDecisionMode);
     195    auto blobURLLifetimeExtension = extendBlobURLLifetimeIfNecessary(request, policyDecisionMode);
    201196
    202197    bool isInitialEmptyDocumentLoad = !m_frame.loader().stateMachine().committedFirstRealDocumentLoad() && request.url().protocolIsAbout() && !substituteData.isValid();
     
    256251        return function({ }, nullptr, { }, { }, ShouldContinuePolicyCheck::No);
    257252
    258     auto blobURLLifetimeExtension = extendBlobURLLifetimeIfNecessary(request, nullptr);
     253    auto blobURLLifetimeExtension = extendBlobURLLifetimeIfNecessary(request);
    259254
    260255    auto requestIdentifier = PolicyCheckIdentifier::create();
  • trunk/Source/WebCore/loader/PolicyChecker.h

    r279881 r280824  
    5252class ResourceError;
    5353class ResourceResponse;
    54 class URLWithBlobURLLifetimeExtension;
     54class BlobURLHandle;
    5555
    5656enum class NavigationPolicyDecision : uint8_t {
     
    9191private:
    9292    void handleUnimplementablePolicy(const ResourceError&);
    93     URLWithBlobURLLifetimeExtension extendBlobURLLifetimeIfNecessary(ResourceRequest&, DocumentLoader*, PolicyDecisionMode = PolicyDecisionMode::Asynchronous) const;
     93    BlobURLHandle extendBlobURLLifetimeIfNecessary(const ResourceRequest&, PolicyDecisionMode = PolicyDecisionMode::Asynchronous) const;
    9494
    9595    Frame& m_frame;
  • trunk/Source/WebCore/platform/network/BlobRegistry.h

    r276677 r280824  
    6464    virtual void unregisterBlobURL(const URL&) = 0;
    6565
     66    virtual void registerBlobURLHandle(const URL&) = 0;
     67    virtual void unregisterBlobURLHandle(const URL&) = 0;
     68
    6669    virtual unsigned long long blobSize(const URL&) = 0;
    6770
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp

    r278516 r280824  
    116116    auto blobData = BlobData::create(contentType);
    117117    blobData->appendFile(WTFMove(file));
    118     m_blobs.set(url.string(), WTFMove(blobData));
     118    addBlobData(url.string(), WTFMove(blobData));
    119119}
    120120
     
    150150    }
    151151
    152     m_blobs.set(url.string(), WTFMove(blobData));
     152    addBlobData(url.string(), WTFMove(blobData));
    153153}
    154154
     
    165165    BlobData* src = getBlobDataFromURL(srcURL);
    166166    if (src) {
    167         m_blobs.set(url.string(), src);
     167        addBlobData(url.string(), src);
    168168        return;
    169169    }
     
    175175    backingFile->appendFile(file.releaseNonNull());
    176176
    177     m_blobs.set(url.string(), WTFMove(backingFile));
     177    addBlobData(url.string(), WTFMove(backingFile));
    178178}
    179179
     
    211211    appendStorageItems(newData.ptr(), originalData->items(), start, newLength);
    212212
    213     m_blobs.set(url.string(), WTFMove(newData));
     213    addBlobData(url.string(), WTFMove(newData));
    214214}
    215215
     
    217217{
    218218    ASSERT(isMainThread());
    219     m_blobs.remove(url.string());
     219    if (m_blobReferences.remove(url.string()))
     220        m_blobs.remove(url.string());
    220221}
    221222
     
    360361}
    361362
     363void BlobRegistryImpl::addBlobData(const String& url, RefPtr<BlobData>&& blobData)
     364{
     365    auto addResult = m_blobs.set(url, WTFMove(blobData));
     366    if (addResult.isNewEntry)
     367        m_blobReferences.add(url);
     368}
     369
     370void BlobRegistryImpl::registerBlobURLHandle(const URL& url)
     371{
     372    if (m_blobs.contains(url.string()))
     373        m_blobReferences.add(url.string());
     374}
     375
     376void BlobRegistryImpl::unregisterBlobURLHandle(const URL& url)
     377{
     378    if (m_blobReferences.remove(url.string()))
     379        m_blobs.remove(url.string());
     380}
     381
    362382} // namespace WebCore
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.h

    r276677 r280824  
    3434#include "BlobData.h"
    3535#include "BlobRegistry.h"
     36#include <wtf/HashCountedSet.h>
    3637#include <wtf/HashMap.h>
    3738#include <wtf/URLHash.h>
     
    6667    void unregisterBlobURL(const URL&);
    6768
     69    void registerBlobURLHandle(const URL&);
     70    void unregisterBlobURLHandle(const URL&);
     71
    6872    unsigned long long blobSize(const URL&);
    6973
     
    7983
    8084private:
     85    void addBlobData(const String& url, RefPtr<BlobData>&&);
     86
     87    HashCountedSet<String> m_blobReferences;
    8188    HashMap<String, RefPtr<BlobData>> m_blobs;
    8289};
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r280260 r280824  
    252252    // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols
    253253    // such as file: and data: still make sense to allow.
    254     if (!m_async && scriptExecutionContext()->isDocument() && m_url.url().protocolIsInHTTPFamily()) {
     254    if (!m_async && scriptExecutionContext()->isDocument() && m_url.protocolIsInHTTPFamily()) {
    255255        logConsoleError(scriptExecutionContext(), "XMLHttpRequest.responseType cannot be changed for synchronous HTTP(S) requests made from the window context.");
    256256        return Exception { InvalidAccessError };
     
    383383    clearRequest();
    384384
    385     auto upgradedURL = url;
    386     context->contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(upgradedURL, ContentSecurityPolicy::InsecureRequestType::Load);
    387     m_url = WTFMove(upgradedURL);
     385    m_url = url;
     386    context->contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(m_url, ContentSecurityPolicy::InsecureRequestType::Load);
     387    if (m_url.protocolIsBlob())
     388        m_blobURLLifetimeExtension = m_url;
    388389
    389390    m_async = async;
     
    418419
    419420    if (is<Document>(context) && downcast<Document>(context).shouldIgnoreSyncXHRs()) {
    420         logConsoleError(scriptExecutionContext(), makeString("Ignoring XMLHttpRequest.send() call for '", m_url.url().string(), "' because the maximum number of synchronous failures was reached."));
     421        logConsoleError(scriptExecutionContext(), makeString("Ignoring XMLHttpRequest.send() call for '", m_url.string(), "' because the maximum number of synchronous failures was reached."));
    421422        return ExceptionOr<void> { };
    422423    }
     
    522523
    523524    if (m_method != "GET" && m_method != "HEAD") {
    524         if (!m_url.url().protocolIsInHTTPFamily()) {
     525        if (!m_url.protocolIsInHTTPFamily()) {
    525526            // FIXME: We would like to support posting Blobs to non-http URLs (e.g. custom URL schemes)
    526527            // but because of the architecture of blob-handling that will require a fair amount of work.
     
    595596{
    596597    // Only GET request is supported for blob URL.
    597     if (!m_async && m_url.url().protocolIsBlob() && m_method != "GET")
     598    if (!m_async && m_url.protocolIsBlob() && m_method != "GET") {
     599        m_blobURLLifetimeExtension.clear();
    598600        return Exception { NetworkError };
     601    }
    599602
    600603    if (m_async && m_upload && m_upload->hasEventListeners())
     
    748751    m_requestEntityBody = nullptr;
    749752    m_url = URL { };
     753    m_blobURLLifetimeExtension.clear();
    750754}
    751755
     
    940944    m_loadingActivity = std::nullopt;
    941945    m_url = URL { };
     946    m_blobURLLifetimeExtension.clear();
    942947
    943948    m_sendFlag = false;
  • trunk/Source/WebCore/xml/XMLHttpRequest.h

    r279881 r280824  
    217217    std::unique_ptr<XMLHttpRequestUpload> m_upload;
    218218
    219     URLWithBlobURLLifetimeExtension m_url;
     219    URL m_url;
     220    BlobURLHandle m_blobURLLifetimeExtension;
    220221    String m_method;
    221222    HTTPHeaderMap m_requestHeaders;
  • trunk/Source/WebKit/ChangeLog

    r280811 r280824  
     12021-08-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob URL changes after loading it
     4        https://bugs.webkit.org/show_bug.cgi?id=228923
     5
     6        Reviewed by Geoff Garen.
     7
     8        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     9        (WebKit::NetworkConnectionToWebProcess::registerBlobURLHandle):
     10        (WebKit::NetworkConnectionToWebProcess::unregisterBlobURLHandle):
     11        * NetworkProcess/NetworkConnectionToWebProcess.h:
     12        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     13        * NetworkProcess/NetworkProcessPlatformStrategies.cpp:
     14        (WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
     15        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
     16        (WebKit::BlobRegistryProxy::registerBlobURLHandle):
     17        (WebKit::BlobRegistryProxy::unregisterBlobURLHandle):
     18        * WebProcess/FileAPI/BlobRegistryProxy.h:
     19
    1202021-08-09  Myles C. Maxfield  <mmaxfield@apple.com>
    221
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r280419 r280824  
    867867}
    868868
     869void NetworkConnectionToWebProcess::registerBlobURLHandle(const URL& url)
     870{
     871    auto* session = networkSession();
     872    if (!session)
     873        return;
     874
     875    session->blobRegistry().registerBlobURLHandle(url);
     876}
     877
     878void NetworkConnectionToWebProcess::unregisterBlobURLHandle(const URL& url)
     879{
     880    auto* session = networkSession();
     881    if (!session)
     882        return;
     883
     884    session->blobRegistry().unregisterBlobURLHandle(url);
     885}
     886
    869887void NetworkConnectionToWebProcess::blobSize(const URL& url, CompletionHandler<void(uint64_t)>&& completionHandler)
    870888{
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

    r279619 r280824  
    237237    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&&)>&&);
    238238
     239    void registerBlobURLHandle(const URL&);
     240    void unregisterBlobURLHandle(const URL&);
     241
    239242    void setCaptureExtraNetworkLoadMetricsEnabled(bool);
    240243
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r279619 r280824  
    5757    BlobSize(URL url) -> (uint64_t resultSize) Synchronous
    5858    WriteBlobsToTemporaryFiles(Vector<String> blobURLs) -> (Vector<String> fileNames) Async
     59    RegisterBlobURLHandle(URL url);
     60    UnregisterBlobURLHandle(URL url);
    5961
    6062    SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp

    r276677 r280824  
    6666        unsigned long long blobSize(const URL&) final { ASSERT_NOT_REACHED(); return 0; }
    6767        void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final { ASSERT_NOT_REACHED(); }
     68        void registerBlobURLHandle(const URL&) final { ASSERT_NOT_REACHED(); }
     69        void unregisterBlobURLHandle(const URL&) final { ASSERT_NOT_REACHED(); }
    6870    };
    6971    static NeverDestroyed<EmptyBlobRegistry> blobRegistry;
  • trunk/Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.cpp

    r276677 r280824  
    7575}
    7676
     77void BlobRegistryProxy::registerBlobURLHandle(const URL& url)
     78{
     79    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLHandle(url), 0);
     80}
     81
     82void BlobRegistryProxy::unregisterBlobURLHandle(const URL& url)
     83{
     84    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UnregisterBlobURLHandle(url), 0);
     85}
     86
    7787unsigned long long BlobRegistryProxy::blobSize(const URL& url)
    7888{
  • trunk/Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.h

    r276677 r280824  
    4040    unsigned long long blobSize(const URL&) final;
    4141    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&&) final;
     42    void registerBlobURLHandle(const URL&) final;
     43    void unregisterBlobURLHandle(const URL&) final;
    4244};
    4345
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r280795 r280824  
     12021-08-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob URL changes after loading it
     4        https://bugs.webkit.org/show_bug.cgi?id=228923
     5
     6        Reviewed by Geoff Garen.
     7
     8        * WebCoreSupport/WebPlatformStrategies.mm:
     9
    1102021-08-09  Myles C. Maxfield  <mmaxfield@apple.com>
    211
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm

    r278253 r280824  
    9292    unsigned long long blobSize(const URL& url) final { return m_blobRegistry.blobSize(url); }
    9393    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler) final { m_blobRegistry.writeBlobsToTemporaryFiles(blobURLs, WTFMove(completionHandler)); }
     94    void registerBlobURLHandle(const URL& url) final { m_blobRegistry.registerBlobURLHandle(url); }
     95    void unregisterBlobURLHandle(const URL& url) final { m_blobRegistry.unregisterBlobURLHandle(url); }
    9496
    9597    BlobRegistryImpl* blobRegistryImpl() final { return &m_blobRegistry; }
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r280784 r280824  
     12021-08-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Blob URL changes after loading it
     4        https://bugs.webkit.org/show_bug.cgi?id=228923
     5
     6        Reviewed by Geoff Garen.
     7
     8        * WebCoreSupport/WebPlatformStrategies.cpp:
     9
    1102021-08-09  Stephan Szabo  <stephan.szabo@sony.com>
    211
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp

    r276982 r280824  
    8888    unsigned long long blobSize(const URL& url) final { return m_blobRegistry.blobSize(url); }
    8989    void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler) final { m_blobRegistry.writeBlobsToTemporaryFiles(blobURLs, WTFMove(completionHandler)); }
     90    void registerBlobURLHandle(const URL& url) final { m_blobRegistry.registerBlobURLHandle(url); }
     91    void unregisterBlobURLHandle(const URL& url) final { m_blobRegistry.unregisterBlobURLHandle(url); }
    9092
    9193    BlobRegistryImpl* blobRegistryImpl() final { return &m_blobRegistry; }
Note: See TracChangeset for help on using the changeset viewer.