Changeset 248503 in webkit


Ignore:
Timestamp:
Aug 10, 2019 3:50:19 PM (5 years ago)
Author:
youenn@apple.com
Message:

Blob should store its session ID
https://bugs.webkit.org/show_bug.cgi?id=200572

Reviewed by Darin Adler.

Blob at creation time now initializes its session ID.
This will allow in the future to call blob registry routines with it.
Update all call sites to provide the session ID.

No observable change.

  • Modules/entriesapi/DOMFileSystem.cpp:

(WebCore::DOMFileSystem::getFile):

  • Modules/fetch/FetchBody.cpp:

(WebCore::FetchBody::fromFormData):

  • Modules/fetch/FetchBody.h:
  • Modules/fetch/FetchBodyConsumer.cpp:

(WebCore::blobFromData):
(WebCore::resolveWithTypeAndData):
(WebCore::FetchBodyConsumer::resolve):
(WebCore::FetchBodyConsumer::takeAsBlob):

  • Modules/fetch/FetchBodyConsumer.h:
  • Modules/fetch/FetchBodyOwner.cpp:

(WebCore::FetchBodyOwner::blob):

  • Modules/mediarecorder/MediaRecorder.cpp:

(WebCore::MediaRecorder::createRecordingDataBlob):

  • Modules/mediastream/RTCDataChannel.cpp:

(WebCore::RTCDataChannel::didReceiveRawData):

  • Modules/websockets/WebSocket.cpp:

(WebCore::WebSocket::didReceiveBinaryData):

  • Modules/websockets/WorkerThreadableWebSocketChannel.cpp:

(WebCore::WorkerThreadableWebSocketChannel::Bridge::send):

  • bindings/js/JSDOMPromiseDeferred.h:

(WebCore::DeferredPromise::sessionID const):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneDeserializer::readFile):
(WebCore::CloneDeserializer::readTerminal):

  • dom/DataTransfer.cpp:

(WebCore::DataTransfer::DataTransfer):
(WebCore::DataTransfer::createForCopyAndPaste):
(WebCore::DataTransfer::filesFromPasteboardAndItemList const):
(WebCore::DataTransfer::createForInputEvent):
(WebCore::DataTransfer::createForDrag):
(WebCore::DataTransfer::createForDragStartEvent):
(WebCore::DataTransfer::createForDrop):
(WebCore::DataTransfer::createForUpdatingDropTarget):

  • dom/DataTransfer.h:
  • dom/Document.cpp:

(WebCore::Document::originIdentifierForPasteboard const):

  • dom/Document.h:
  • editing/ReplaceRangeWithTextCommand.cpp:

(WebCore::ReplaceRangeWithTextCommand::inputEventDataTransfer const):

  • editing/ReplaceSelectionCommand.cpp:

(WebCore::ReplaceSelectionCommand::inputEventDataTransfer const):

  • editing/SpellingCorrectionCommand.cpp:

(WebCore::SpellingCorrectionCommand::inputEventDataTransfer const):

  • editing/TypingCommand.cpp:

(WebCore::TypingCommand::inputEventDataTransfer const):

  • editing/WebCorePasteboardFileReader.cpp:

(WebCore::WebCorePasteboardFileReader::readFilename):
(WebCore::WebCorePasteboardFileReader::readBuffer):

  • editing/WebCorePasteboardFileReader.h:
  • editing/cocoa/WebContentReaderCocoa.mm:

(WebCore::createFragmentForImageAttachment):
(WebCore::replaceRichContentWithAttachments):
(WebCore::createFragmentAndAddResources):
(WebCore::sanitizeMarkupWithArchive):
(WebCore::WebContentReader::readImage):
(WebCore::attachmentForFilePath):
(WebCore::attachmentForData):

  • editing/markup.cpp:

(WebCore::restoreAttachmentElementsInFragment):

  • fileapi/Blob.cpp:

(WebCore::Blob::Blob):

  • fileapi/Blob.h:

(WebCore::Blob::create):
(WebCore::Blob::deserialize):
(WebCore::Blob::slice const):

  • fileapi/Blob.idl:
  • fileapi/File.cpp:

(WebCore::File::createWithRelativePath):
(WebCore::File::File):

  • fileapi/File.h:
  • fileapi/File.idl:
  • html/FileInputType.cpp:

(WebCore::FileInputType::appendFormData const):
(WebCore::FileInputType::filesChosen):

  • html/FileListCreator.cpp:

(WebCore::appendDirectoryFiles):
(WebCore::FileListCreator::FileListCreator):
(WebCore::FileListCreator::createFileList):

  • html/FileListCreator.h:

(WebCore::FileListCreator::create):

  • html/HTMLAttachmentElement.cpp:

(WebCore::HTMLAttachmentElement::updateEnclosingImageWithData):

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::toBlob):

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleDrag):

  • testing/Internals.cpp:

(WebCore::Internals::createFile):

  • testing/ServiceWorkerInternals.cpp:

(WebCore::ServiceWorkerInternals::createOpaqueWithBlobBodyResponse):

  • workers/service/context/ServiceWorkerFetch.cpp:

(WebCore::ServiceWorkerFetch::dispatchFetchEvent):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::createResponseBlob):

Location:
trunk/Source/WebCore
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r248502 r248503  
     12019-08-10  Youenn Fablet  <youenn@apple.com>
     2
     3        Blob should store its session ID
     4        https://bugs.webkit.org/show_bug.cgi?id=200572
     5
     6        Reviewed by Darin Adler.
     7
     8        Blob at creation time now initializes its session ID.
     9        This will allow in the future to call blob registry routines with it.
     10        Update all call sites to provide the session ID.
     11
     12        No observable change.
     13
     14        * Modules/entriesapi/DOMFileSystem.cpp:
     15        (WebCore::DOMFileSystem::getFile):
     16        * Modules/fetch/FetchBody.cpp:
     17        (WebCore::FetchBody::fromFormData):
     18        * Modules/fetch/FetchBody.h:
     19        * Modules/fetch/FetchBodyConsumer.cpp:
     20        (WebCore::blobFromData):
     21        (WebCore::resolveWithTypeAndData):
     22        (WebCore::FetchBodyConsumer::resolve):
     23        (WebCore::FetchBodyConsumer::takeAsBlob):
     24        * Modules/fetch/FetchBodyConsumer.h:
     25        * Modules/fetch/FetchBodyOwner.cpp:
     26        (WebCore::FetchBodyOwner::blob):
     27        * Modules/mediarecorder/MediaRecorder.cpp:
     28        (WebCore::MediaRecorder::createRecordingDataBlob):
     29        * Modules/mediastream/RTCDataChannel.cpp:
     30        (WebCore::RTCDataChannel::didReceiveRawData):
     31        * Modules/websockets/WebSocket.cpp:
     32        (WebCore::WebSocket::didReceiveBinaryData):
     33        * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
     34        (WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
     35        * bindings/js/JSDOMPromiseDeferred.h:
     36        (WebCore::DeferredPromise::sessionID const):
     37        * bindings/js/SerializedScriptValue.cpp:
     38        (WebCore::CloneDeserializer::readFile):
     39        (WebCore::CloneDeserializer::readTerminal):
     40        * dom/DataTransfer.cpp:
     41        (WebCore::DataTransfer::DataTransfer):
     42        (WebCore::DataTransfer::createForCopyAndPaste):
     43        (WebCore::DataTransfer::filesFromPasteboardAndItemList const):
     44        (WebCore::DataTransfer::createForInputEvent):
     45        (WebCore::DataTransfer::createForDrag):
     46        (WebCore::DataTransfer::createForDragStartEvent):
     47        (WebCore::DataTransfer::createForDrop):
     48        (WebCore::DataTransfer::createForUpdatingDropTarget):
     49        * dom/DataTransfer.h:
     50        * dom/Document.cpp:
     51        (WebCore::Document::originIdentifierForPasteboard const):
     52        * dom/Document.h:
     53        * editing/ReplaceRangeWithTextCommand.cpp:
     54        (WebCore::ReplaceRangeWithTextCommand::inputEventDataTransfer const):
     55        * editing/ReplaceSelectionCommand.cpp:
     56        (WebCore::ReplaceSelectionCommand::inputEventDataTransfer const):
     57        * editing/SpellingCorrectionCommand.cpp:
     58        (WebCore::SpellingCorrectionCommand::inputEventDataTransfer const):
     59        * editing/TypingCommand.cpp:
     60        (WebCore::TypingCommand::inputEventDataTransfer const):
     61        * editing/WebCorePasteboardFileReader.cpp:
     62        (WebCore::WebCorePasteboardFileReader::readFilename):
     63        (WebCore::WebCorePasteboardFileReader::readBuffer):
     64        * editing/WebCorePasteboardFileReader.h:
     65        * editing/cocoa/WebContentReaderCocoa.mm:
     66        (WebCore::createFragmentForImageAttachment):
     67        (WebCore::replaceRichContentWithAttachments):
     68        (WebCore::createFragmentAndAddResources):
     69        (WebCore::sanitizeMarkupWithArchive):
     70        (WebCore::WebContentReader::readImage):
     71        (WebCore::attachmentForFilePath):
     72        (WebCore::attachmentForData):
     73        * editing/markup.cpp:
     74        (WebCore::restoreAttachmentElementsInFragment):
     75        * fileapi/Blob.cpp:
     76        (WebCore::Blob::Blob):
     77        * fileapi/Blob.h:
     78        (WebCore::Blob::create):
     79        (WebCore::Blob::deserialize):
     80        (WebCore::Blob::slice const):
     81        * fileapi/Blob.idl:
     82        * fileapi/File.cpp:
     83        (WebCore::File::createWithRelativePath):
     84        (WebCore::File::File):
     85        * fileapi/File.h:
     86        * fileapi/File.idl:
     87        * html/FileInputType.cpp:
     88        (WebCore::FileInputType::appendFormData const):
     89        (WebCore::FileInputType::filesChosen):
     90        * html/FileListCreator.cpp:
     91        (WebCore::appendDirectoryFiles):
     92        (WebCore::FileListCreator::FileListCreator):
     93        (WebCore::FileListCreator::createFileList):
     94        * html/FileListCreator.h:
     95        (WebCore::FileListCreator::create):
     96        * html/HTMLAttachmentElement.cpp:
     97        (WebCore::HTMLAttachmentElement::updateEnclosingImageWithData):
     98        * html/HTMLCanvasElement.cpp:
     99        (WebCore::HTMLCanvasElement::toBlob):
     100        * page/EventHandler.cpp:
     101        (WebCore::EventHandler::handleDrag):
     102        * testing/Internals.cpp:
     103        (WebCore::Internals::createFile):
     104        * testing/ServiceWorkerInternals.cpp:
     105        (WebCore::ServiceWorkerInternals::createOpaqueWithBlobBodyResponse):
     106        * workers/service/context/ServiceWorkerFetch.cpp:
     107        (WebCore::ServiceWorkerFetch::dispatchFetchEvent):
     108        * xml/XMLHttpRequest.cpp:
     109        (WebCore::XMLHttpRequest::createResponseBlob):
     110
    11112019-08-10  Alex Christensen  <achristensen@webkit.org>
    2112
  • trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp

    r243887 r248503  
    344344                completionCallback(validatedVirtualPath.releaseException());
    345345            else
    346                 completionCallback(File::create(fullPath));
     346                completionCallback(File::create(context->sessionID(), fullPath));
    347347        });
    348348    });
  • trunk/Source/WebCore/Modules/fetch/FetchBody.cpp

    r248283 r248503  
    7676}
    7777
    78 Optional<FetchBody> FetchBody::fromFormData(FormData& formData)
     78Optional<FetchBody> FetchBody::fromFormData(PAL::SessionID sessionID, FormData& formData)
    7979{
    8080    ASSERT(!formData.isEmpty());
     
    8989    if (!url.isNull()) {
    9090        // FIXME: Properly set mime type and size of the blob.
    91         Ref<const Blob> blob = Blob::deserialize(url, { }, 0, { });
     91        Ref<const Blob> blob = Blob::deserialize(sessionID, url, { }, 0, { });
    9292        return FetchBody { WTFMove(blob) };
    9393    }
  • trunk/Source/WebCore/Modules/fetch/FetchBody.h

    r248283 r248503  
    6060    FetchBody() = default;
    6161
    62     WEBCORE_EXPORT static Optional<FetchBody> fromFormData(FormData&);
     62    WEBCORE_EXPORT static Optional<FetchBody> fromFormData(PAL::SessionID, FormData&);
    6363
    6464    void loadingFailed(const Exception&);
  • trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp

    r239644 r248503  
    3636namespace WebCore {
    3737
    38 static inline Ref<Blob> blobFromData(const unsigned char* data, unsigned length, const String& contentType)
     38static inline Ref<Blob> blobFromData(PAL::SessionID sessionID, const unsigned char* data, unsigned length, const String& contentType)
    3939{
    4040    Vector<uint8_t> value(length);
    4141    memcpy(value.data(), data, length);
    42     return Blob::create(WTFMove(value), contentType);
     42    return Blob::create(sessionID, WTFMove(value), contentType);
    4343}
    4444
     
    6565        return;
    6666    case FetchBodyConsumer::Type::Blob:
    67         promise->resolveWithNewlyCreated<IDLInterface<Blob>>(blobFromData(data, length, contentType).get());
     67        promise->resolveWithNewlyCreated<IDLInterface<Blob>>(blobFromData(promise->sessionID(), data, length, contentType).get());
    6868        return;
    6969    case FetchBodyConsumer::Type::JSON:
     
    131131        return;
    132132    case Type::Blob:
    133         promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob().get());
     133        promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob(promise->sessionID()).get());
    134134        return;
    135135    case Type::JSON:
     
    178178}
    179179
    180 Ref<Blob> FetchBodyConsumer::takeAsBlob()
     180Ref<Blob> FetchBodyConsumer::takeAsBlob(PAL::SessionID sessionID)
    181181{
    182182    if (!m_buffer)
    183         return Blob::create(Vector<uint8_t>(), m_contentType);
     183        return Blob::create(sessionID, Vector<uint8_t>(), m_contentType);
    184184
    185185    // FIXME: We should try to move m_buffer to Blob without doing extra copy.
    186     return blobFromData(reinterpret_cast<const unsigned char*>(m_buffer->data()), m_buffer->size(), m_contentType);
     186    return blobFromData(sessionID, reinterpret_cast<const unsigned char*>(m_buffer->data()), m_buffer->size(), m_contentType);
    187187}
    188188
  • trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h

    r239644 r248503  
    5555    RefPtr<SharedBuffer> takeData();
    5656    RefPtr<JSC::ArrayBuffer> takeAsArrayBuffer();
    57     Ref<Blob> takeAsBlob();
    5857    String takeAsText();
    5958
     
    7675
    7776private:
     77    Ref<Blob> takeAsBlob(PAL::SessionID);
     78
    7879    Type m_type;
    7980    String m_contentType;
  • trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp

    r248283 r248503  
    125125
    126126    if (isBodyNullOrOpaque()) {
    127         promise->resolve<IDLInterface<Blob>>(Blob::create(Vector<uint8_t> { }, Blob::normalizedContentType(extractMIMETypeFromMediaType(m_contentType))));
     127        promise->resolve<IDLInterface<Blob>>(Blob::create(promise->sessionID(), Vector<uint8_t> { }, Blob::normalizedContentType(extractMIMETypeFromMediaType(m_contentType))));
    128128        return;
    129129    }
  • trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp

    r243887 r248503  
    158158    auto data = m_private->fetchData();
    159159    if (!data)
    160         return Blob::create();
    161     return Blob::create(*data, m_private->mimeType());
     160        return Blob::create(scriptExecutionContext()->sessionID());
     161    return Blob::create(scriptExecutionContext()->sessionID(), *data, m_private->mimeType());
    162162}
    163163
  • trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp

    r246490 r248503  
    203203    switch (m_binaryType) {
    204204    case BinaryType::Blob:
    205         scheduleDispatchEvent(MessageEvent::create(Blob::create(SharedBuffer::create(data, dataLength), emptyString()), { }));
     205        scheduleDispatchEvent(MessageEvent::create(Blob::create(scriptExecutionContext()->sessionID(), SharedBuffer::create(data, dataLength), emptyString()), { }));
    206206        return;
    207207    case BinaryType::ArrayBuffer:
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r246388 r248503  
    585585    case BinaryType::Blob:
    586586        // FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient.
    587         dispatchEvent(MessageEvent::create(Blob::create(WTFMove(binaryData), emptyString()), SecurityOrigin::create(m_url)->toString()));
     587        dispatchEvent(MessageEvent::create(Blob::create(scriptExecutionContext()->sessionID(), WTFMove(binaryData), emptyString()), SecurityOrigin::create(m_url)->toString()));
    588588        break;
    589589    case BinaryType::ArrayBuffer:
  • trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp

    r247902 r248503  
    466466        ASSERT(peer);
    467467
    468         peer->send(Blob::deserialize(url, type, size, { }));
     468        peer->send(Blob::deserialize(context.sessionID(), url, type, size, { }));
    469469    });
    470470
  • trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h

    r244312 r248503  
    2929#include "JSDOMConvert.h"
    3030#include "JSDOMGuardedObject.h"
     31#include "ScriptExecutionContext.h"
    3132#include <JavaScriptCore/CatchScope.h>
    3233#include <JavaScriptCore/JSPromiseDeferred.h>
     34#include <pal/SessionID.h>
    3335
    3436namespace WebCore {
     
    136138
    137139    void whenSettled(std::function<void()>&&);
     140
     141    PAL::SessionID sessionID() const { return globalObject()->scriptExecutionContext()->sessionID(); }
    138142
    139143private:
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r246770 r248503  
    20962096
    20972097        if (m_isDOMGlobalObject)
    2098             file = File::deserialize(filePath, URL(URL(), url->string()), type->string(), name->string(), optionalLastModified);
     2098            file = File::deserialize(jsCast<JSDOMGlobalObject*>(m_globalObject)->scriptExecutionContext()->sessionID(), filePath, URL(URL(), url->string()), type->string(), name->string(), optionalLastModified);
    20992099        return true;
    21002100    }
     
    28622862            if (!m_isDOMGlobalObject)
    28632863                return jsNull();
    2864             return getJSValue(Blob::deserialize(URL(URL(), url->string()), type->string(), size, blobFilePathForBlobURL(url->string())).get());
     2864            return getJSValue(Blob::deserialize(jsCast<JSDOMGlobalObject*>(m_globalObject)->scriptExecutionContext()->sessionID(), URL(URL(), url->string()), type->string(), size, blobFilePathForBlobURL(url->string())).get());
    28652865        }
    28662866        case StringTag: {
  • trunk/Source/WebCore/dom/DataTransfer.cpp

    r246285 r248503  
    6969#endif
    7070
    71 DataTransfer::DataTransfer(StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type)
    72     : m_storeMode(mode)
     71DataTransfer::DataTransfer(const Document& document, StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type)
     72    : m_sessionID(document.sessionID())
     73    , m_storeMode(mode)
    7374    , m_pasteboard(WTFMove(pasteboard))
    7475#if ENABLE(DRAG_SUPPORT)
     
    8485}
    8586
    86 Ref<DataTransfer> DataTransfer::createForCopyAndPaste(Document& document, StoreMode storeMode, std::unique_ptr<Pasteboard>&& pasteboard)
    87 {
    88     auto dataTransfer = adoptRef(*new DataTransfer(storeMode, WTFMove(pasteboard)));
     87Ref<DataTransfer> DataTransfer::createForCopyAndPaste(const Document& document, StoreMode storeMode, std::unique_ptr<Pasteboard>&& pasteboard)
     88{
     89    auto dataTransfer = adoptRef(*new DataTransfer(document, storeMode, WTFMove(pasteboard)));
    8990    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
    9091    return dataTransfer;
     
    349350    Vector<Ref<File>> files;
    350351    if ((!forDrag() || forFileDrag()) && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) {
    351         WebCorePasteboardFileReader reader;
     352        WebCorePasteboardFileReader reader { m_sessionID };
    352353        m_pasteboard->read(reader);
    353354        files = WTFMove(reader.files);
     
    414415}
    415416
    416 Ref<DataTransfer> DataTransfer::createForInputEvent(const String& plainText, const String& htmlText)
     417Ref<DataTransfer> DataTransfer::createForInputEvent(const Document& document, const String& plainText, const String& htmlText)
    417418{
    418419    auto pasteboard = std::make_unique<StaticPasteboard>();
    419420    pasteboard->writeString("text/plain"_s, plainText);
    420421    pasteboard->writeString("text/html"_s, htmlText);
    421     return adoptRef(*new DataTransfer(StoreMode::Readonly, WTFMove(pasteboard), Type::InputEvent));
     422    return adoptRef(*new DataTransfer(document, StoreMode::Readonly, WTFMove(pasteboard), Type::InputEvent));
    422423}
    423424
     
    464465#else
    465466
    466 Ref<DataTransfer> DataTransfer::createForDrag()
    467 {
    468     return adoptRef(*new DataTransfer(StoreMode::ReadWrite, Pasteboard::createForDragAndDrop(), Type::DragAndDropData));
    469 }
    470 
    471 Ref<DataTransfer> DataTransfer::createForDragStartEvent(Document& document)
    472 {
    473     auto dataTransfer = adoptRef(*new DataTransfer(StoreMode::ReadWrite, std::make_unique<StaticPasteboard>(), Type::DragAndDropData));
     467Ref<DataTransfer> DataTransfer::createForDrag(const Document& document)
     468{
     469    return adoptRef(*new DataTransfer(document, StoreMode::ReadWrite, Pasteboard::createForDragAndDrop(), Type::DragAndDropData));
     470}
     471
     472Ref<DataTransfer> DataTransfer::createForDragStartEvent(const Document& document)
     473{
     474    auto dataTransfer = adoptRef(*new DataTransfer(document, StoreMode::ReadWrite, std::make_unique<StaticPasteboard>(), Type::DragAndDropData));
    474475    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
    475476    return dataTransfer;
    476477}
    477478
    478 Ref<DataTransfer> DataTransfer::createForDrop(Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
    479 {
    480     auto dataTransfer = adoptRef(*new DataTransfer(DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
     479Ref<DataTransfer> DataTransfer::createForDrop(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
     480{
     481    auto dataTransfer = adoptRef(*new DataTransfer(document, DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
    481482    dataTransfer->setSourceOperation(sourceOperation);
    482483    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
     
    484485}
    485486
    486 Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
    487 {
    488     auto dataTransfer = adoptRef(*new DataTransfer(DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
     487Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
     488{
     489    auto dataTransfer = adoptRef(*new DataTransfer(document, DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
    489490    dataTransfer->setSourceOperation(sourceOperation);
    490491    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
  • trunk/Source/WebCore/dom/DataTransfer.h

    r228340 r248503  
    2727#include "DragActions.h"
    2828#include "DragImage.h"
     29#include <pal/SessionID.h>
    2930#include <wtf/text/WTFString.h>
    3031
     
    4748    enum class StoreMode { Invalid, ReadWrite, Readonly, Protected };
    4849
    49     static Ref<DataTransfer> createForCopyAndPaste(Document&, StoreMode, std::unique_ptr<Pasteboard>&&);
    50     static Ref<DataTransfer> createForInputEvent(const String& plainText, const String& htmlText);
     50    static Ref<DataTransfer> createForCopyAndPaste(const Document&, StoreMode, std::unique_ptr<Pasteboard>&&);
     51    static Ref<DataTransfer> createForInputEvent(const Document&, const String& plainText, const String& htmlText);
    5152
    5253    WEBCORE_EXPORT ~DataTransfer();
     
    8788
    8889#if ENABLE(DRAG_SUPPORT)
    89     static Ref<DataTransfer> createForDrag();
    90     static Ref<DataTransfer> createForDragStartEvent(Document&);
    91     static Ref<DataTransfer> createForDrop(Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
    92     static Ref<DataTransfer> createForUpdatingDropTarget(Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
     90    static Ref<DataTransfer> createForDrag(const Document&);
     91    static Ref<DataTransfer> createForDragStartEvent(const Document&);
     92    static Ref<DataTransfer> createForDrop(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
     93    static Ref<DataTransfer> createForUpdatingDropTarget(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
    9394
    9495    bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
     
    113114private:
    114115    enum class Type { CopyAndPaste, DragAndDropData, DragAndDropFiles, InputEvent };
    115     DataTransfer(StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste);
     116    DataTransfer(const Document&, StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste);
    116117
    117118#if ENABLE(DRAG_SUPPORT)
     
    130131    Vector<Ref<File>> filesFromPasteboardAndItemList() const;
    131132
     133    PAL::SessionID m_sessionID;
    132134    String m_originIdentifier;
    133135    StoreMode m_storeMode;
  • trunk/Source/WebCore/dom/Document.cpp

    r248467 r248503  
    57295729#endif
    57305730
    5731 String Document::originIdentifierForPasteboard()
     5731String Document::originIdentifierForPasteboard() const
    57325732{
    57335733    auto origin = securityOrigin().toString();
  • trunk/Source/WebCore/dom/Document.h

    r247530 r248503  
    10341034    uint64_t domTreeVersion() const { return m_domTreeVersion; }
    10351035
    1036     WEBCORE_EXPORT String originIdentifierForPasteboard();
     1036    WEBCORE_EXPORT String originIdentifierForPasteboard() const;
    10371037
    10381038    // XPathEvaluator methods
     
    16891689    static uint64_t s_globalTreeVersion;
    16901690
    1691     String m_uniqueIdentifier;
     1691    mutable String m_uniqueIdentifier;
    16921692
    16931693    HashSet<NodeIterator*> m_nodeIterators;
  • trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp

    r239535 r248503  
    8383{
    8484    if (!isEditingTextAreaOrTextInput())
    85         return DataTransfer::createForInputEvent(m_text, serializeFragment(*m_textFragment, SerializedNodes::SubtreeIncludingNode));
     85        return DataTransfer::createForInputEvent(document(), m_text, serializeFragment(*m_textFragment, SerializedNodes::SubtreeIncludingNode));
    8686
    8787    return CompositeEditCommand::inputEventDataTransfer();
  • trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp

    r246868 r248503  
    13271327        return CompositeEditCommand::inputEventDataTransfer();
    13281328
    1329     return DataTransfer::createForInputEvent(m_documentFragmentPlainText, m_documentFragmentHTMLMarkup);
     1329    return DataTransfer::createForInputEvent(document(), m_documentFragmentPlainText, m_documentFragmentHTMLMarkup);
    13301330}
    13311331
  • trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp

    r239535 r248503  
    131131{
    132132    if (!isEditingTextAreaOrTextInput())
    133         return DataTransfer::createForInputEvent(m_correction, serializeFragment(*m_correctionFragment, SerializedNodes::SubtreeIncludingNode));
     133        return DataTransfer::createForInputEvent(document(), m_correction, serializeFragment(*m_correctionFragment, SerializedNodes::SubtreeIncludingNode));
    134134
    135135    return CompositeEditCommand::inputEventDataTransfer();
  • trunk/Source/WebCore/editing/TypingCommand.cpp

    r245823 r248503  
    426426    StringBuilder htmlText;
    427427    MarkupAccumulator::appendCharactersReplacingEntities(htmlText, m_currentTextToInsert, 0, m_currentTextToInsert.length(), EntityMaskInHTMLPCDATA);
    428     return DataTransfer::createForInputEvent(m_currentTextToInsert, htmlText.toString());
     428    return DataTransfer::createForInputEvent(document(), m_currentTextToInsert, htmlText.toString());
    429429}
    430430
  • trunk/Source/WebCore/editing/WebCorePasteboardFileReader.cpp

    r222839 r248503  
    3636void WebCorePasteboardFileReader::readFilename(const String& filename)
    3737{
    38     files.append(File::create(filename));
     38    files.append(File::create(sessionID, filename));
    3939}
    4040
    4141void WebCorePasteboardFileReader::readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&& buffer)
    4242{
    43     files.append(File::create(Blob::create(buffer.get(), type), filename));
     43    files.append(File::create(Blob::create(sessionID, buffer.get(), type), filename));
    4444}
    4545
  • trunk/Source/WebCore/editing/WebCorePasteboardFileReader.h

    r222699 r248503  
    3333
    3434struct WebCorePasteboardFileReader final : PasteboardFileReader {
     35    explicit WebCorePasteboardFileReader(PAL::SessionID sessionID)
     36        : sessionID(sessionID)
     37    {
     38    }
     39
    3540    ~WebCorePasteboardFileReader();
    3641
     
    3843    void readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&&) final;
    3944
     45    PAL::SessionID sessionID;
    4046    Vector<Ref<File>> files;
    4147};
  • trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm

    r246892 r248503  
    260260        if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) {
    261261            auto image = HTMLImageElement::create(document);
    262             image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(buffer.get(), contentType)));
     262            image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(document.sessionID(), buffer.get(), contentType)));
    263263            image->setAttachmentElement(WTFMove(attachment));
    264264            if (preferredSize.width)
     
    272272        }
    273273    } else {
    274         attachment->setFile(File::create(Blob::create(buffer.get(), contentType), defaultImageAttachmentName), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
     274        attachment->setFile(File::create(Blob::create(document.sessionID(), buffer.get(), contentType), defaultImageAttachmentName), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
    275275        fragment->appendChild(WTFMove(attachment));
    276276    }
     
    366366            if (is<HTMLImageElement>(originalElement.get()) && contentTypeIsSuitableForInlineImageRepresentation(info.contentType)) {
    367367                auto& image = downcast<HTMLImageElement>(originalElement.get());
    368                 image.setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(*frame.document(), Blob::create(info.data, info.contentType)));
     368                image.setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(*frame.document(), Blob::create(fragment.document().sessionID(), info.data, info.contentType)));
    369369                image.setAttachmentElement(attachment.copyRef());
    370370            } else {
     
    374374            frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), WTFMove(info.contentType), WTFMove(info.fileName), WTFMove(info.data));
    375375        } else {
    376             attachment->setFile(File::create(Blob::create(WTFMove(info.data), WTFMove(info.contentType)), WTFMove(info.fileName)), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
     376            attachment->setFile(File::create(Blob::create(fragment.document().sessionID(), WTFMove(info.data), WTFMove(info.contentType)), WTFMove(info.fileName)), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
    377377            parent->replaceChild(WTFMove(attachment), WTFMove(originalElement));
    378378        }
     
    416416    HashMap<AtomString, AtomString> blobURLMap;
    417417    for (const Ref<ArchiveResource>& subresource : fragmentAndResources.resources) {
    418         auto blob = Blob::create(subresource->data(), subresource->mimeType());
     418        auto blob = Blob::create(document.sessionID(), subresource->data(), subresource->mimeType());
    419419        String blobURL = DOMURL::createObjectURL(document, blob);
    420420        blobURLMap.set(subresource->url().string(), blobURL);
     
    465465        if (!shouldReplaceSubresourceURL(subresourceURL))
    466466            continue;
    467         auto blob = Blob::create(subresource->data(), subresource->mimeType());
     467        auto blob = Blob::create(destinationDocument.sessionID(), subresource->data(), subresource->mimeType());
    468468        String blobURL = DOMURL::createObjectURL(destinationDocument, blob);
    469469        blobURLMap.set(subresourceURL.string(), blobURL);
     
    492492        blobBuffer.reserveCapacity(utf8.length());
    493493        blobBuffer.append(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length());
    494         auto blob = Blob::create(WTFMove(blobBuffer), type);
     494        auto blob = Blob::create(destinationDocument.sessionID(), WTFMove(blobBuffer), type);
    495495
    496496        String subframeBlobURL = DOMURL::createObjectURL(destinationDocument, blob);
     
    689689        addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize));
    690690    else
    691         addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(buffer.get(), type)), preferredPresentationSize));
     691        addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(document.sessionID(), buffer.get(), type)), preferredPresentationSize));
    692692
    693693    return fragment;
     
    710710    auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
    711711    if (!supportsClientSideAttachmentData(frame)) {
    712         attachment->setFile(File::create(path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
     712        attachment->setFile(File::create(document->sessionID(), path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
    713713        return attachment;
    714714    }
     
    737737    if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) {
    738738        auto image = HTMLImageElement::create(document);
    739         image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(path)));
     739        image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(document->sessionID(), path)));
    740740        image->setAttachmentElement(WTFMove(attachment));
    741741        if (preferredSize.width)
     
    766766
    767767    if (!supportsClientSideAttachmentData(frame)) {
    768         attachment->setFile(File::create(Blob::create(buffer, WTFMove(attachmentType)), fileName));
     768        attachment->setFile(File::create(Blob::create(document->sessionID(), buffer, WTFMove(attachmentType)), fileName));
    769769        return attachment;
    770770    }
     
    774774    if (contentTypeIsSuitableForInlineImageRepresentation(attachmentType)) {
    775775        auto image = HTMLImageElement::create(document);
    776         image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create(buffer, WTFMove(attachmentType)), WTFMove(fileName))));
     776        image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create(document->sessionID(), buffer, WTFMove(attachmentType)), WTFMove(fileName))));
    777777        image->setAttachmentElement(WTFMove(attachment));
    778778        if (preferredSize.width)
  • trunk/Source/WebCore/editing/gtk/EditorGtk.cpp

    r246490 r248503  
    6767        }, &buffer);
    6868        if (status == CAIRO_STATUS_SUCCESS) {
    69             auto blob = Blob::create(WTFMove(buffer), "image/png");
     69            auto blob = Blob::create(frame.document()->sessionID(), WTFMove(buffer), "image/png");
    7070            if (!frame.document())
    7171                return nullptr;
  • trunk/Source/WebCore/editing/markup.cpp

    r247222 r248503  
    984984        auto blobURL = attachment->blobURL();
    985985        if (!attachmentPath.isEmpty())
    986             attachment->setFile(File::create(attachmentPath));
     986            attachment->setFile(File::create(fragment.document().sessionID(), attachmentPath));
    987987        else if (!blobURL.isEmpty())
    988             attachment->setFile(File::deserialize({ }, blobURL, attachment->attachmentType(), attachment->attachmentTitle()));
     988            attachment->setFile(File::deserialize(fragment.document().sessionID(), { }, blobURL, attachment->attachmentType(), attachment->attachmentTitle()));
    989989
    990990        // Remove temporary attributes that were previously added in StyledMarkupAccumulator::appendCustomAttributes.
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r248473 r248503  
    7373}
    7474
    75 Blob::Blob(UninitializedContructor)
    76 {
    77 }
    78 
    79 Blob::Blob()
    80     : m_size(0)
     75Blob::Blob(UninitializedContructor, PAL::SessionID sessionID)
     76    : m_sessionID(sessionID)
     77{
     78}
     79
     80Blob::Blob(PAL::SessionID sessionID)
     81    : m_sessionID(sessionID)
     82    , m_size(0)
    8183{
    8284    m_internalURL = BlobURL::createInternalURL();
     
    8486}
    8587
    86 Blob::Blob(Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
    87     : m_internalURL(BlobURL::createInternalURL())
     88Blob::Blob(PAL::SessionID sessionID, Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
     89    : m_sessionID(sessionID)
     90    , m_internalURL(BlobURL::createInternalURL())
    8891    , m_type(normalizedContentType(propertyBag.type))
    8992    , m_size(-1)
     
    101104}
    102105
    103 Blob::Blob(const SharedBuffer& buffer, const String& contentType)
    104     : m_type(contentType)
     106Blob::Blob(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& contentType)
     107    : m_sessionID(sessionID)
     108    , m_type(contentType)
    105109    , m_size(buffer.size())
    106110{
     
    114118}
    115119
    116 Blob::Blob(Vector<uint8_t>&& data, const String& contentType)
    117     : m_type(contentType)
     120Blob::Blob(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& contentType)
     121    : m_sessionID(sessionID)
     122    , m_type(contentType)
    118123    , m_size(data.size())
    119124{
     
    125130
    126131Blob::Blob(ReferencingExistingBlobConstructor, const Blob& blob)
    127     : m_internalURL(BlobURL::createInternalURL())
     132    : m_sessionID(blob.m_sessionID)
     133    , m_internalURL(BlobURL::createInternalURL())
    128134    , m_type(blob.type())
    129135    , m_size(blob.size())
     
    132138}
    133139
    134 Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size, const String& fileBackedPath)
    135     : m_type(normalizedContentType(type))
     140Blob::Blob(DeserializationContructor, PAL::SessionID sessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath)
     141    : m_sessionID(sessionID)
     142    , m_type(normalizedContentType(type))
    136143    , m_size(size)
    137144{
     
    143150}
    144151
    145 Blob::Blob(const URL& srcURL, long long start, long long end, const String& type)
    146     : m_type(normalizedContentType(type))
     152Blob::Blob(PAL::SessionID sessionID, const URL& srcURL, long long start, long long end, const String& type)
     153    : m_sessionID(sessionID)
     154    , m_type(normalizedContentType(type))
    147155    , m_size(-1) // size is not necessarily equal to end - start.
    148156{
  • trunk/Source/WebCore/fileapi/Blob.h

    r243931 r248503  
    3333
    3434#include "BlobPropertyBag.h"
     35#include "ScriptExecutionContext.h"
    3536#include "ScriptWrappable.h"
    3637#include <wtf/IsoMalloc.h>
    3738#include <wtf/URL.h>
    3839#include "URLRegistry.h"
     40#include <pal/SessionID.h>
    3941#include <wtf/Variant.h>
    4042
     
    5557    WTF_MAKE_ISO_ALLOCATED_EXPORT(Blob, WEBCORE_EXPORT);
    5658public:
    57     static Ref<Blob> create()
     59    static Ref<Blob> create(PAL::SessionID sessionID)
    5860    {
    59         return adoptRef(*new Blob);
     61        return adoptRef(*new Blob(sessionID));
    6062    }
    6163
    62     static Ref<Blob> create(Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
     64    static Ref<Blob> create(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
    6365    {
    64         return adoptRef(*new Blob(WTFMove(blobPartVariants), propertyBag));
     66        return adoptRef(*new Blob(context.sessionID(), WTFMove(blobPartVariants), propertyBag));
    6567    }
    6668
    67     static Ref<Blob> create(const SharedBuffer& buffer, const String& contentType)
     69    static Ref<Blob> create(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& contentType)
    6870    {
    69         return adoptRef(*new Blob(buffer, contentType));
     71        return adoptRef(*new Blob(sessionID, buffer, contentType));
    7072    }
    7173
    72     static Ref<Blob> create(Vector<uint8_t>&& data, const String& contentType)
     74    static Ref<Blob> create(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& contentType)
    7375    {
    74         return adoptRef(*new Blob(WTFMove(data), contentType));
     76        return adoptRef(*new Blob(sessionID, WTFMove(data), contentType));
    7577    }
    7678
    77     static Ref<Blob> deserialize(const URL& srcURL, const String& type, long long size, const String& fileBackedPath)
     79    static Ref<Blob> deserialize(PAL::SessionID sessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath)
    7880    {
    7981        ASSERT(Blob::isNormalizedContentType(type));
    80         return adoptRef(*new Blob(deserializationContructor, srcURL, type, size, fileBackedPath));
     82        return adoptRef(*new Blob(deserializationContructor, sessionID, srcURL, type, size, fileBackedPath));
    8183    }
    8284
     
    103105    Ref<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const
    104106    {
    105         return adoptRef(*new Blob(m_internalURL, start, end, contentType));
     107        return adoptRef(*new Blob(m_sessionID, m_internalURL, start, end, contentType));
    106108    }
    107109
    108110protected:
    109     WEBCORE_EXPORT Blob();
    110     Blob(Vector<BlobPartVariant>&&, const BlobPropertyBag&);
    111     Blob(const SharedBuffer&, const String& contentType);
    112     Blob(Vector<uint8_t>&&, const String& contentType);
     111    WEBCORE_EXPORT explicit Blob(PAL::SessionID);
     112    Blob(PAL::SessionID, Vector<BlobPartVariant>&&, const BlobPropertyBag&);
     113    Blob(PAL::SessionID, const SharedBuffer&, const String& contentType);
     114    Blob(PAL::SessionID, Vector<uint8_t>&&, const String& contentType);
    113115
    114116    enum ReferencingExistingBlobConstructor { referencingExistingBlobConstructor };
     
    116118
    117119    enum UninitializedContructor { uninitializedContructor };
    118     Blob(UninitializedContructor);
     120    Blob(UninitializedContructor, PAL::SessionID);
    119121
    120122    enum DeserializationContructor { deserializationContructor };
    121     Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size, const String& fileBackedPath);
     123    Blob(DeserializationContructor, PAL::SessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath);
    122124
    123125    // For slicing.
    124     Blob(const URL& srcURL, long long start, long long end, const String& contentType);
     126    Blob(PAL::SessionID, const URL& srcURL, long long start, long long end, const String& contentType);
    125127
     128    PAL::SessionID m_sessionID;
    126129    // This is an internal URL referring to the blob data associated with this object. It serves
    127130    // as an identifier for this blob. The internal URL is never used to source the blob's content
  • trunk/Source/WebCore/fileapi/Blob.idl

    r218495 r248503  
    3636    CustomToJSObject,
    3737    Constructor(optional sequence<BlobPart> blobParts, optional BlobPropertyBag options),
     38    ConstructorCallWith=ScriptExecutionContext,
    3839] interface Blob {
    3940    readonly attribute unsigned long long size;
  • trunk/Source/WebCore/fileapi/File.cpp

    r243887 r248503  
    4040WTF_MAKE_ISO_ALLOCATED_IMPL(File);
    4141
    42 Ref<File> File::createWithRelativePath(const String& path, const String& relativePath)
     42Ref<File> File::createWithRelativePath(PAL::SessionID sessionID, const String& path, const String& relativePath)
    4343{
    44     auto file = File::create(path);
     44    auto file = File::create(sessionID, path);
    4545    file->setRelativePath(relativePath);
    4646    return file;
    4747}
    4848
    49 File::File(const String& path)
    50     : Blob(uninitializedContructor)
     49File::File(PAL::SessionID sessionID, const String& path)
     50    : Blob(uninitializedContructor, sessionID)
    5151    , m_path(path)
    5252{
     
    5757}
    5858
    59 File::File(const String& path, const String& nameOverride)
    60     : Blob(uninitializedContructor)
     59File::File(PAL::SessionID sessionID, const String& path, const String& nameOverride)
     60    : Blob(uninitializedContructor, sessionID)
    6161    , m_path(path)
    6262{
     
    6767}
    6868
    69 File::File(DeserializationContructor, const String& path, const URL& url, const String& type, const String& name, const Optional<int64_t>& lastModified)
    70     : Blob(deserializationContructor, url, type, -1, path)
     69File::File(DeserializationContructor, PAL::SessionID sessionID, const String& path, const URL& url, const String& type, const String& name, const Optional<int64_t>& lastModified)
     70    : Blob(deserializationContructor, sessionID, url, type, -1, path)
    7171    , m_path(path)
    7272    , m_name(name)
     
    8282}
    8383
    84 File::File(Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)
    85     : Blob(WTFMove(blobPartVariants), convertPropertyBag(propertyBag))
     84File::File(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)
     85    : Blob(context.sessionID(), WTFMove(blobPartVariants), convertPropertyBag(propertyBag))
    8686    , m_name(filename)
    8787    , m_lastModifiedDateOverride(propertyBag.lastModified.valueOr(WallTime::now().secondsSinceEpoch().milliseconds()))
  • trunk/Source/WebCore/fileapi/File.h

    r243931 r248503  
    4242    };
    4343
    44     static Ref<File> create(const String& path)
     44    static Ref<File> create(PAL::SessionID sessionID, const String& path)
    4545    {
    46         return adoptRef(*new File(path));
     46        return adoptRef(*new File(sessionID, path));
    4747    }
    4848
    4949    // Create a File using the 'new File' constructor.
    50     static Ref<File> create(Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)
     50    static Ref<File> create(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)
    5151    {
    52         return adoptRef(*new File(WTFMove(blobPartVariants), filename, propertyBag));
     52        return adoptRef(*new File(context, WTFMove(blobPartVariants), filename, propertyBag));
    5353    }
    5454
    55     static Ref<File> deserialize(const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified = WTF::nullopt)
     55    static Ref<File> deserialize(PAL::SessionID sessionID, const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified = WTF::nullopt)
    5656    {
    57         return adoptRef(*new File(deserializationContructor, path, srcURL, type, name, lastModified));
     57        return adoptRef(*new File(deserializationContructor, sessionID, path, srcURL, type, name, lastModified));
    5858    }
    5959
    6060    // Create a file with a name exposed to the author (via File.name and associated DOM properties) that differs from the one provided in the path.
    61     static Ref<File> createWithName(const String& path, const String& nameOverride)
     61    static Ref<File> createWithName(PAL::SessionID sessionID, const String& path, const String& nameOverride)
    6262    {
    6363        if (nameOverride.isEmpty())
    64             return adoptRef(*new File(path));
    65         return adoptRef(*new File(path, nameOverride));
     64            return adoptRef(*new File(sessionID, path));
     65        return adoptRef(*new File(sessionID, path, nameOverride));
    6666    }
    6767
     
    7676    }
    7777
    78     static Ref<File> createWithRelativePath(const String& path, const String& relativePath);
     78    static Ref<File> createWithRelativePath(PAL::SessionID, const String& path, const String& relativePath);
    7979
    8080    bool isFile() const override { return true; }
     
    9696
    9797private:
    98     WEBCORE_EXPORT explicit File(const String& path);
    99     File(const String& path, const String& nameOverride);
    100     File(Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag&);
     98    WEBCORE_EXPORT explicit File(PAL::SessionID, const String& path);
     99    File(PAL::SessionID, const String& path, const String& nameOverride);
     100    File(ScriptExecutionContext&, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag&);
    101101    File(const Blob&, const String& name);
    102102    File(const File&, const String& name);
    103103
    104     File(DeserializationContructor, const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified);
     104    File(DeserializationContructor, PAL::SessionID, const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified);
    105105
    106106    static void computeNameAndContentType(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType);
  • trunk/Source/WebCore/fileapi/File.idl

    r221177 r248503  
    2929[
    3030    Constructor(sequence<BlobPart> fileBits, USVString fileName, optional FilePropertyBag options),
     31    ConstructorCallWith=ScriptExecutionContext,
    3132    ExportMacro=WEBCORE_EXPORT,
    3233    Exposed=(Window),
  • trunk/Source/WebCore/html/FileInputType.cpp

    r246490 r248503  
    176176    // Null would be more logical, but Netscape posts an empty file. Argh.
    177177    if (fileList->isEmpty()) {
    178         formData.append(name, File::create(emptyString()));
     178        formData.append(name, File::create(element()->document().sessionID(), emptyString()));
    179179        return true;
    180180    }
     
    415415    auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No;
    416416    auto shouldRequestIcon = icon ? RequestIcon::Yes : RequestIcon::No;
    417     m_fileListCreator = FileListCreator::create(paths, shouldResolveDirectories, [this, shouldRequestIcon](Ref<FileList>&& fileList) {
     417    m_fileListCreator = FileListCreator::create(element()->document().sessionID(), paths, shouldResolveDirectories, [this, shouldRequestIcon](Ref<FileList>&& fileList) {
    418418        setFiles(WTFMove(fileList), shouldRequestIcon);
    419419        m_fileListCreator = nullptr;
  • trunk/Source/WebCore/html/FileListCreator.cpp

    r240437 r248503  
    4040}
    4141
    42 static void appendDirectoryFiles(const String& directory, const String& relativePath, Vector<Ref<File>>& fileObjects)
     42static void appendDirectoryFiles(PAL::SessionID sessionID, const String& directory, const String& relativePath, Vector<Ref<File>>& fileObjects)
    4343{
    4444    for (auto& childPath : FileSystem::listDirectory(directory, "*")) {
     
    5252        String childRelativePath = relativePath + "/" + FileSystem::pathGetFileName(childPath);
    5353        if (metadata.value().type == FileMetadata::Type::Directory)
    54             appendDirectoryFiles(childPath, childRelativePath, fileObjects);
     54            appendDirectoryFiles(sessionID, childPath, childRelativePath, fileObjects);
    5555        else if (metadata.value().type == FileMetadata::Type::File)
    56             fileObjects.append(File::createWithRelativePath(childPath, childRelativePath));
     56            fileObjects.append(File::createWithRelativePath(sessionID, childPath, childRelativePath));
    5757    }
    5858}
    5959
    60 FileListCreator::FileListCreator(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
     60FileListCreator::FileListCreator(PAL::SessionID sessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
    6161{
    6262    if (shouldResolveDirectories == ShouldResolveDirectories::No)
    63         completionHandler(createFileList<ShouldResolveDirectories::No>(paths));
     63        completionHandler(createFileList<ShouldResolveDirectories::No>(sessionID, paths));
    6464    else {
    6565        // Resolve directories on a background thread to avoid blocking the main thread.
    6666        m_completionHander = WTFMove(completionHandler);
    6767        m_workQueue = WorkQueue::create("FileListCreator Work Queue");
    68         m_workQueue->dispatch([this, protectedThis = makeRef(*this), paths = crossThreadCopy(paths)]() mutable {
    69             auto fileList = createFileList<ShouldResolveDirectories::Yes>(paths);
     68        m_workQueue->dispatch([this, protectedThis = makeRef(*this), sessionID, paths = crossThreadCopy(paths)]() mutable {
     69            auto fileList = createFileList<ShouldResolveDirectories::Yes>(sessionID, paths);
    7070            callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = WTFMove(fileList)]() mutable {
    7171                if (auto completionHander = WTFMove(m_completionHander))
     
    7777
    7878template<FileListCreator::ShouldResolveDirectories shouldResolveDirectories>
    79 Ref<FileList> FileListCreator::createFileList(const Vector<FileChooserFileInfo>& paths)
     79Ref<FileList> FileListCreator::createFileList(PAL::SessionID sessionID, const Vector<FileChooserFileInfo>& paths)
    8080{
    8181    Vector<Ref<File>> fileObjects;
    8282    for (auto& info : paths) {
    8383        if (shouldResolveDirectories == ShouldResolveDirectories::Yes && FileSystem::fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No))
    84             appendDirectoryFiles(info.path, FileSystem::pathGetFileName(info.path), fileObjects);
     84            appendDirectoryFiles(sessionID, info.path, FileSystem::pathGetFileName(info.path), fileObjects);
    8585        else
    86             fileObjects.append(File::createWithName(info.path, info.displayName));
     86            fileObjects.append(File::createWithName(sessionID, info.path, info.displayName));
    8787    }
    8888    return FileList::create(WTFMove(fileObjects));
  • trunk/Source/WebCore/html/FileListCreator.h

    r222113 r248503  
    2626#pragma once
    2727
     28#include <pal/SessionID.h>
    2829#include <wtf/Forward.h>
    2930#include <wtf/Function.h>
     
    3940class FileListCreator : public ThreadSafeRefCounted<FileListCreator> {
    4041public:
    41     using CompletionHandler = WTF::Function<void(Ref<FileList>&&)>;
     42    using CompletionHandler = Function<void(Ref<FileList>&&)>;
    4243
    4344    enum class ShouldResolveDirectories { No, Yes };
    44     static Ref<FileListCreator> create(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
     45    static Ref<FileListCreator> create(PAL::SessionID sessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
    4546    {
    46         return adoptRef(*new FileListCreator(paths, shouldResolveDirectories, WTFMove(completionHandler)));
     47        return adoptRef(*new FileListCreator(sessionID, paths, shouldResolveDirectories, WTFMove(completionHandler)));
    4748    }
    4849
     
    5253
    5354private:
    54     FileListCreator(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&);
     55    FileListCreator(PAL::SessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&);
    5556
    5657    template<ShouldResolveDirectories shouldResolveDirectories>
    57     static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>&);
     58    static Ref<FileList> createFileList(PAL::SessionID, const Vector<FileChooserFileInfo>&);
    5859
    5960    RefPtr<WorkQueue> m_workQueue;
  • trunk/Source/WebCore/html/HTMLAttachmentElement.cpp

    r246490 r248503  
    247247        return;
    248248
    249     hostElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document(), Blob::create(WTFMove(data), mimeType)));
     249    hostElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document(), Blob::create(document().sessionID(), WTFMove(data), mimeType)));
    250250}
    251251
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r246490 r248503  
    740740        Vector<uint8_t> blobData = data(*imageData, encodingMIMEType, quality);
    741741        if (!blobData.isEmpty())
    742             blob = Blob::create(WTFMove(blobData), encodingMIMEType);
     742            blob = Blob::create(context.sessionID(), WTFMove(blobData), encodingMIMEType);
    743743        callback->scheduleCallback(context, WTFMove(blob));
    744744        return { };
     
    751751    Vector<uint8_t> blobData = buffer()->toData(encodingMIMEType, quality);
    752752    if (!blobData.isEmpty())
    753         blob = Blob::create(WTFMove(blobData), encodingMIMEType);
     753        blob = Blob::create(context.sessionID(), WTFMove(blobData), encodingMIMEType);
    754754    callback->scheduleCallback(context, WTFMove(blob));
    755755    return { };
  • trunk/Source/WebCore/page/EventHandler.cpp

    r247530 r248503  
    37733773    invalidateDataTransfer();
    37743774
    3775     dragState().dataTransfer = DataTransfer::createForDrag();
     3775    dragState().dataTransfer = DataTransfer::createForDrag(*m_frame.document());
    37763776    HasNonDefaultPasteboardData hasNonDefaultPasteboardData = HasNonDefaultPasteboardData::No;
    37773777   
  • trunk/Source/WebCore/testing/Internals.cpp

    r248497 r248503  
    42334233        return nullptr;
    42344234
    4235     return File::create(url.fileSystemPath());
     4235    return File::create(document->sessionID(), url.fileSystemPath());
    42364236}
    42374237
  • trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp

    r245299 r248503  
    6969Ref<FetchResponse> ServiceWorkerInternals::createOpaqueWithBlobBodyResponse(ScriptExecutionContext& context)
    7070{
    71     auto blob = Blob::create();
     71    auto blob = Blob::create(context.sessionID());
    7272    auto formData = FormData::create();
    7373    formData->appendBlob(blob->url());
     
    7676    response.setType(ResourceResponse::Type::Cors);
    7777    response.setTainting(ResourceResponse::Tainting::Opaque);
    78     auto fetchResponse = FetchResponse::create(context, FetchBody::fromFormData(formData), FetchHeaders::Guard::Response, WTFMove(response));
     78    auto fetchResponse = FetchResponse::create(context, FetchBody::fromFormData(context.sessionID(), formData), FetchHeaders::Guard::Response, WTFMove(response));
    7979    fetchResponse->initializeOpaqueLoadIdentifierForTesting();
    8080    return fetchResponse;
  • trunk/Source/WebCore/workers/WorkerGlobalScope.h

    r243887 r248503  
    127127    unsigned long createUniqueIdentifier() { return m_uniqueIdentifier++; }
    128128
     129    PAL::SessionID sessionID() const final { return m_sessionID; }
     130
    129131protected:
    130132    WorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID);
     
    150152    ScriptExecutionContext* scriptExecutionContext() const final { return const_cast<WorkerGlobalScope*>(this); }
    151153    URL completeURL(const String&) const final;
    152     PAL::SessionID sessionID() const final { return m_sessionID; }
    153154    String userAgent(const URL&) const final;
    154155    void disableEval(const String& errorMessage) final;
  • trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp

    r244115 r248503  
    150150    Optional<FetchBody> body;
    151151    if (formData && !formData->isEmpty()) {
    152         body = FetchBody::fromFormData(*formData);
     152        body = FetchBody::fromFormData(globalScope.sessionID(), *formData);
    153153        if (!body) {
    154154            client->didNotHandle();
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r248139 r248503  
    213213    m_binaryResponseBuilder = nullptr;
    214214    String normalizedContentType = Blob::normalizedContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
    215     return Blob::create(WTFMove(data), normalizedContentType);
     215    return Blob::create(scriptExecutionContext()->sessionID(), WTFMove(data), normalizedContentType);
    216216}
    217217
Note: See TracChangeset for help on using the changeset viewer.