haikuwebkit/Source/WebCore/fileapi/BlobLoader.h

103 lines
3.3 KiB
C
Raw Permalink Normal View History

/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "Blob.h"
#include "Document.h"
Remove FileError.h https://bugs.webkit.org/show_bug.cgi?id=213119 Patch by Tetsuharu Ohzeki <tetsuharu.ohzeki@gmail.com> on 2020-06-13 Reviewed by Chris Dumez. Source/WebCore: * Headers.cmake: * Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp: (WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::didFail): * Modules/async-clipboard/ClipboardItemBindingsDataSource.h: * Modules/mediastream/RTCDataChannel.cpp: (WebCore::RTCDataChannel::createMessageQueue): * Modules/websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::didFail): (WebCore::WebSocketChannel::abortOutgoingFrameQueue): * Modules/websockets/WebSocketChannel.h: * WebCore.xcodeproj/project.pbxproj: * fileapi/BlobLoader.h: (WebCore::BlobLoader::didFail): * fileapi/FileError.h: Removed. * fileapi/FileReader.cpp: (WebCore::FileReader::didFail): * fileapi/FileReader.h: * fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::start): (WebCore::FileReaderLoader::cancel): (WebCore::FileReaderLoader::cleanup): (WebCore::FileReaderLoader::didReceiveResponse): (WebCore::FileReaderLoader::didReceiveData): (WebCore::FileReaderLoader::didFail): (WebCore::FileReaderLoader::failed): (WebCore::FileReaderLoader::toErrorCode): (WebCore::FileReaderLoader::httpStatusCodeToErrorCode): (WebCore::FileReaderLoader::arrayBufferResult const): (WebCore::FileReaderLoader::stringResult): * fileapi/FileReaderLoader.h: (WebCore::FileReaderLoader::errorCode const): * fileapi/FileReaderLoaderClient.h: * fileapi/FileReaderSync.cpp: (WebCore::FileReaderSync::startLoading): * fileapi/FileReaderSync.h: * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::processMessages): * fileapi/NetworkSendQueue.h: * html/ImageBitmap.cpp: Source/WebKit: * WebProcess/Network/WebSocketChannel.cpp: (WebKit::WebSocketChannel::createMessageQueue): Canonical link: https://commits.webkit.org/225939@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262999 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-13 16:24:15 +00:00
#include "ExceptionCode.h"
#include "FileReaderLoader.h"
#include "FileReaderLoaderClient.h"
#include "SharedBuffer.h"
#include <JavaScriptCore/ArrayBuffer.h>
#include <wtf/CompletionHandler.h>
namespace WebCore {
class BlobLoader final : public FileReaderLoaderClient {
WTF_MAKE_FAST_ALLOCATED;
public:
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
explicit BlobLoader(CompletionHandler<void(BlobLoader&)>&&);
~BlobLoader();
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
void start(Blob&, ScriptExecutionContext*, FileReaderLoader::ReadType);
void cancel();
bool isLoading() const { return m_loader && m_completionHandler; }
String stringResult() const { return m_loader ? m_loader->stringResult() : String(); }
RefPtr<JSC::ArrayBuffer> arrayBufferResult() const { return m_loader ? m_loader->arrayBufferResult() : nullptr; }
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<ExceptionCode> errorCode() const { return m_loader ? m_loader->errorCode() : std::nullopt; }
private:
void didStartLoading() final { }
void didReceiveData() final { }
void didFinishLoading() final;
Remove FileError.h https://bugs.webkit.org/show_bug.cgi?id=213119 Patch by Tetsuharu Ohzeki <tetsuharu.ohzeki@gmail.com> on 2020-06-13 Reviewed by Chris Dumez. Source/WebCore: * Headers.cmake: * Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp: (WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::didFail): * Modules/async-clipboard/ClipboardItemBindingsDataSource.h: * Modules/mediastream/RTCDataChannel.cpp: (WebCore::RTCDataChannel::createMessageQueue): * Modules/websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::didFail): (WebCore::WebSocketChannel::abortOutgoingFrameQueue): * Modules/websockets/WebSocketChannel.h: * WebCore.xcodeproj/project.pbxproj: * fileapi/BlobLoader.h: (WebCore::BlobLoader::didFail): * fileapi/FileError.h: Removed. * fileapi/FileReader.cpp: (WebCore::FileReader::didFail): * fileapi/FileReader.h: * fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::start): (WebCore::FileReaderLoader::cancel): (WebCore::FileReaderLoader::cleanup): (WebCore::FileReaderLoader::didReceiveResponse): (WebCore::FileReaderLoader::didReceiveData): (WebCore::FileReaderLoader::didFail): (WebCore::FileReaderLoader::failed): (WebCore::FileReaderLoader::toErrorCode): (WebCore::FileReaderLoader::httpStatusCodeToErrorCode): (WebCore::FileReaderLoader::arrayBufferResult const): (WebCore::FileReaderLoader::stringResult): * fileapi/FileReaderLoader.h: (WebCore::FileReaderLoader::errorCode const): * fileapi/FileReaderLoaderClient.h: * fileapi/FileReaderSync.cpp: (WebCore::FileReaderSync::startLoading): * fileapi/FileReaderSync.h: * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::processMessages): * fileapi/NetworkSendQueue.h: * html/ImageBitmap.cpp: Source/WebKit: * WebProcess/Network/WebSocketChannel.cpp: (WebKit::WebSocketChannel::createMessageQueue): Canonical link: https://commits.webkit.org/225939@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262999 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-13 16:24:15 +00:00
void didFail(ExceptionCode errorCode) final;
void complete();
std::unique_ptr<FileReaderLoader> m_loader;
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
CompletionHandler<void(BlobLoader&)> m_completionHandler;
};
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
inline BlobLoader::BlobLoader(CompletionHandler<void(BlobLoader&)>&& completionHandler)
: m_completionHandler(WTFMove(completionHandler))
{
}
inline BlobLoader::~BlobLoader()
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
{
if (isLoading())
cancel();
}
inline void BlobLoader::cancel()
{
if (m_loader)
m_loader->cancel();
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
if (m_completionHandler)
m_completionHandler(*this);
}
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
inline void BlobLoader::start(Blob& blob, ScriptExecutionContext* context, FileReaderLoader::ReadType readType)
{
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
ASSERT(!m_loader);
m_loader = makeUnique<FileReaderLoader>(readType, this);
m_loader->start(context, blob);
}
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
inline void BlobLoader::didFinishLoading()
{
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
m_completionHandler(*this);
}
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
inline void BlobLoader::didFail(ExceptionCode)
{
Blob is missing text() & arrayBuffer() operations https://bugs.webkit.org/show_bug.cgi?id=215663 Reviewed by Geoff Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-array-buffer.any.worker-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any-expected.txt: * web-platform-tests/FileAPI/blob/Blob-text.any.worker-expected.txt: * web-platform-tests/FileAPI/idlharness-expected.txt: * web-platform-tests/FileAPI/idlharness.worker-expected.txt: Source/WebCore: Implementation support for Blob.text() & Blob.arrayBuffer() as per specification: - https://w3c.github.io/FileAPI/#blob-section The implementation relies on the pre-existing BlobLoader class but the following changes were made: - Stop calling start() in the BlobLoader constructor and have the caller call start() explicitly after constructing the BlobLoader. This is important because the load may fail synchronously in some cases. - Add support for reading Blob as text. Previously, BlobLoader would only support reading the blob as an ArrayBuffer. - Use a CompletionHandler instead of a Function and make sure that it is always called. No new tests, rebaselined existing tests. * fileapi/Blob.cpp: (WebCore::Blob::~Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::text): (WebCore::Blob::arrayBuffer): * fileapi/Blob.h: * fileapi/Blob.idl: * fileapi/BlobLoader.h: (WebCore::BlobLoader::BlobLoader): (WebCore::BlobLoader::~BlobLoader): (WebCore::BlobLoader::cancel): (WebCore::BlobLoader::start): (WebCore::BlobLoader::didFinishLoading): (WebCore::BlobLoader::didFail): (WebCore::BlobLoader::complete): Deleted. * fileapi/NetworkSendQueue.cpp: (WebCore::NetworkSendQueue::enqueue): (WebCore::NetworkSendQueue::clear): (WebCore::NetworkSendQueue::processMessages): * page/ShareDataReader.cpp: (WebCore::ShareDataReader::start): (WebCore::ShareDataReader::didFinishLoading): (WebCore::ShareDataReader::cancel): Canonical link: https://commits.webkit.org/228429@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-19 23:56:03 +00:00
m_completionHandler(*this);
}
} // namespace WebCore