Title: [262999] trunk/Source
Revision
262999
Author
[email protected]
Date
2020-06-13 09:24:15 -0700 (Sat, 13 Jun 2020)

Log Message

Remove FileError.h
https://bugs.webkit.org/show_bug.cgi?id=213119

Patch by Tetsuharu Ohzeki <[email protected]> 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):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (262998 => 262999)


--- trunk/Source/WebCore/ChangeLog	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/ChangeLog	2020-06-13 16:24:15 UTC (rev 262999)
@@ -1,3 +1,50 @@
+2020-06-13  Tetsuharu Ohzeki  <[email protected]>
+
+        Remove FileError.h
+        https://bugs.webkit.org/show_bug.cgi?id=213119
+
+        Reviewed by Chris Dumez.
+
+        * 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:
+
 2020-06-12  Simon Fraser  <[email protected]>
 
         REGRESSION(r261985): Unable to respond to large comments on Bugzilla with always-on scrollbars

Modified: trunk/Source/WebCore/Headers.cmake (262998 => 262999)


--- trunk/Source/WebCore/Headers.cmake	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/Headers.cmake	2020-06-13 16:24:15 UTC (rev 262999)
@@ -534,7 +534,6 @@
     fileapi/BlobPropertyBag.h
     fileapi/EndingType.h
     fileapi/File.h
-    fileapi/FileError.h
     fileapi/FileList.h
     fileapi/FileReaderLoader.h
     fileapi/FileReaderLoaderClient.h

Modified: trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp (262998 => 262999)


--- trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -31,6 +31,7 @@
 #include "Clipboard.h"
 #include "ClipboardItem.h"
 #include "Document.h"
+#include "ExceptionCode.h"
 #include "FileReaderLoader.h"
 #include "Frame.h"
 #include "GraphicsContext.h"
@@ -249,7 +250,7 @@
     invokeCompletionHandler();
 }
 
-void ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::didFail(int)
+void ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::didFail(ExceptionCode)
 {
     ASSERT(m_blobLoader);
     m_blobLoader = nullptr;

Modified: trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.h (262998 => 262999)


--- trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "ClipboardItemDataSource.h"
+#include "ExceptionCode.h"
 #include "FileReaderLoaderClient.h"
 #include <wtf/Optional.h>
 #include <wtf/Variant.h>
@@ -80,7 +81,7 @@
         void didStartLoading() final { }
         void didReceiveData() final { }
         void didFinishLoading() final;
-        void didFail(int) final;
+        void didFail(ExceptionCode) final;
 
         String m_type;
         BufferOrString m_data;

Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (262998 => 262999)


--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -30,6 +30,7 @@
 
 #include "Blob.h"
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "MessageEvent.h"
 #include "ScriptExecutionContext.h"
 #include "SharedBuffer.h"
@@ -71,9 +72,11 @@
     }, [&channel](auto* data, size_t length) {
         if (!channel.m_handler->sendRawData(data, length))
             channel.scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "Error sending binary data through RTCDataChannel."_s);
-    }, [&channel](int errorCode) {
-        if (auto* context = channel.scriptExecutionContext())
-            context->addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Error ", errorCode, " in retrieving a blob data to be sent through RTCDataChannel."));
+    }, [&channel](ExceptionCode errorCode) {
+        if (auto* context = channel.scriptExecutionContext()) {
+            auto code = static_cast<int>(errorCode);
+            context->addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Error ", code, " in retrieving a blob data to be sent through RTCDataChannel."));
+        }
         return NetworkSendQueue::Continue::Yes;
     } };
 }

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (262998 => 262999)


--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -36,7 +36,7 @@
 #include "ContentRuleListResults.h"
 #include "CookieJar.h"
 #include "Document.h"
-#include "FileError.h"
+#include "ExceptionCode.h"
 #include "FileReaderLoader.h"
 #include "Frame.h"
 #include "FrameLoader.h"
@@ -395,14 +395,15 @@
     deref();
 }
 
-void WebSocketChannel::didFail(int errorCode)
+void WebSocketChannel::didFail(ExceptionCode errorCode)
 {
-    LOG(Network, "WebSocketChannel %p didFail() errorCode=%d", this, errorCode);
+    auto code = static_cast<int>(errorCode);
+    LOG(Network, "WebSocketChannel %p didFail() errorCode=%d", this, code);
     ASSERT(m_blobLoader);
     ASSERT(m_blobLoaderStatus == BlobLoaderStarted);
     m_blobLoader = nullptr;
     m_blobLoaderStatus = BlobLoaderFailed;
-    fail(makeString("Failed to load Blob: error code = ", errorCode)); // FIXME: Generate human-friendly reason message.
+    fail(makeString("Failed to load Blob: error code = ", code)); // FIXME: Generate human-friendly reason message.
     deref();
 }
 
@@ -809,7 +810,7 @@
     m_outgoingFrameQueueStatus = OutgoingFrameQueueClosed;
     if (m_blobLoaderStatus == BlobLoaderStarted) {
         m_blobLoader->cancel();
-        didFail(FileError::ABORT_ERR);
+        didFail(AbortError);
     }
 }
 

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h (262998 => 262999)


--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -30,6 +30,7 @@
 
 #pragma once
 
+#include "ExceptionCode.h"
 #include "FileReaderLoaderClient.h"
 #include "SocketStreamHandleClient.h"
 #include "ThreadableWebSocketChannel.h"
@@ -113,7 +114,7 @@
     void didStartLoading() override;
     void didReceiveData() override;
     void didFinishLoading() override;
-    void didFail(int errorCode) override;
+    void didFail(ExceptionCode errorCode) override;
 
     unsigned identifier() const { return m_identifier; }
     bool hasCreatedHandshake() { return !!m_handshake; }

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (262998 => 262999)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-06-13 16:24:15 UTC (rev 262999)
@@ -2823,7 +2823,6 @@
 		976D6C7C122B8A3D001FD1F7 /* BlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5D122B8A3D001FD1F7 /* BlobBuilder.h */; };
 		976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C60122B8A3D001FD1F7 /* BlobURL.h */; };
 		976D6C81122B8A3D001FD1F7 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C62122B8A3D001FD1F7 /* File.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		976D6C83122B8A3D001FD1F7 /* FileError.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C64122B8A3D001FD1F7 /* FileError.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C67122B8A3D001FD1F7 /* FileList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		976D6C89122B8A3D001FD1F7 /* FileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C6A122B8A3D001FD1F7 /* FileReader.h */; };
 		976D6C95122B8A3D001FD1F7 /* ThreadableBlobRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */; };
@@ -11165,7 +11164,6 @@
 		976D6C60122B8A3D001FD1F7 /* BlobURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobURL.h; sourceTree = "<group>"; };
 		976D6C61122B8A3D001FD1F7 /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = File.cpp; sourceTree = "<group>"; };
 		976D6C62122B8A3D001FD1F7 /* File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = File.h; sourceTree = "<group>"; };
-		976D6C64122B8A3D001FD1F7 /* FileError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileError.h; sourceTree = "<group>"; };
 		976D6C66122B8A3D001FD1F7 /* FileList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileList.cpp; sourceTree = "<group>"; };
 		976D6C67122B8A3D001FD1F7 /* FileList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileList.h; sourceTree = "<group>"; };
 		976D6C69122B8A3D001FD1F7 /* FileReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileReader.cpp; sourceTree = "<group>"; };
@@ -22920,7 +22918,6 @@
 				976D6C62122B8A3D001FD1F7 /* File.h */,
 				E1AB1EB714E9E35800449E13 /* File.idl */,
 				E164A2E7191AC5BB0010737D /* FileCocoa.mm */,
-				976D6C64122B8A3D001FD1F7 /* FileError.h */,
 				976D6C66122B8A3D001FD1F7 /* FileList.cpp */,
 				976D6C67122B8A3D001FD1F7 /* FileList.h */,
 				E1AB1EA814E9E27D00449E13 /* FileList.idl */,
@@ -30582,7 +30579,6 @@
 				976D6C81122B8A3D001FD1F7 /* File.h in Headers */,
 				838F86DA1F509E7400E8CFC5 /* FileCallback.h in Headers */,
 				066C772B0AB603B700238CC4 /* FileChooser.h in Headers */,
-				976D6C83122B8A3D001FD1F7 /* FileError.h in Headers */,
 				5351D4B11DF916B4008010CD /* FileHandle.h in Headers */,
 				1A88A90517553CD7000C74F9 /* FileIconLoader.h in Headers */,
 				F55B3DBE1251F12D003EF269 /* FileInputType.h in Headers */,

Modified: trunk/Source/WebCore/fileapi/BlobLoader.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/BlobLoader.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/BlobLoader.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -27,11 +27,13 @@
 
 #include "Blob.h"
 #include "Document.h"
+#include "ExceptionCode.h"
 #include "FileReaderLoader.h"
 #include "FileReaderLoaderClient.h"
 #include "SharedBuffer.h"
 #include <_javascript_Core/ArrayBuffer.h>
 #include <wtf/CompletionHandler.h>
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -43,7 +45,7 @@
 
     bool isLoading() const { return !!m_loader; }
     const RefPtr<JSC::ArrayBuffer>& result() const { return m_buffer; }
-    int errorCode() const { return m_errorCode; }
+    Optional<ExceptionCode> errorCode() const { return m_errorCode; }
 
 private:
     void didStartLoading() final { }
@@ -50,12 +52,12 @@
     void didReceiveData() final { }
 
     void didFinishLoading() final;
-    void didFail(int errorCode) final;
+    void didFail(ExceptionCode errorCode) final;
     void complete();
 
     std::unique_ptr<FileReaderLoader> m_loader;
     RefPtr<JSC::ArrayBuffer> m_buffer;
-    int m_errorCode { 0 };
+    Optional<ExceptionCode> m_errorCode;
     CompletionHandler<void()> m_completionHandler;
 };
 
@@ -78,7 +80,7 @@
     complete();
 }
 
-inline void BlobLoader::didFail(int errorCode)
+inline void BlobLoader::didFail(ExceptionCode errorCode)
 {
     m_errorCode = errorCode;
     complete();

Deleted: trunk/Source/WebCore/fileapi/FileError.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileError.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileError.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2010 Google 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:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR 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 <wtf/Ref.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class FileError : public RefCounted<FileError> {
-public:
-    enum ErrorCode {
-        OK = 0,
-        NOT_FOUND_ERR = 1,
-        SECURITY_ERR = 2,
-        ABORT_ERR = 3,
-        NOT_READABLE_ERR = 4,
-        ENCODING_ERR = 5,
-        NO_MODIFICATION_ALLOWED_ERR = 6,
-        INVALID_STATE_ERR = 7,
-        SYNTAX_ERR = 8,
-        INVALID_MODIFICATION_ERR = 9,
-        QUOTA_EXCEEDED_ERR = 10,
-        TYPE_MISMATCH_ERR = 11,
-        PATH_EXISTS_ERR = 12,
-    };
-
-    static Ref<FileError> create(ErrorCode code) { return adoptRef(*new FileError(code)); }
-
-    ErrorCode code() const { return m_code; }
-
-private:
-    FileError(ErrorCode code)
-        : m_code(code)
-    { }
-
-    ErrorCode m_code;
-};
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/fileapi/FileReader.cpp (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReader.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReader.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -37,7 +37,6 @@
 #include "Exception.h"
 #include "ExceptionCode.h"
 #include "File.h"
-#include "FileError.h"
 #include "Logging.h"
 #include "ProgressEvent.h"
 #include "ScriptExecutionContext.h"
@@ -211,7 +210,7 @@
     });
 }
 
-void FileReader::didFail(int errorCode)
+void FileReader::didFail(ExceptionCode errorCode)
 {
     // If we're aborting, do not proceed with normal error handling since it is covered in aborting code.
     if (m_aborting)
@@ -221,9 +220,7 @@
         ASSERT(m_state != DONE);
         m_state = DONE;
 
-        auto e = FileReaderSync::errorCodeToException(static_cast<FileError::ErrorCode>(errorCode));
-        ASSERT(e.hasException());
-        m_error = DOMException::create(e.exception());
+        m_error = DOMException::create(Exception { errorCode });
 
         fireEvent(eventNames().errorEvent);
         fireEvent(eventNames().loadendEvent);

Modified: trunk/Source/WebCore/fileapi/FileReader.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReader.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReader.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -33,6 +33,7 @@
 #include "ActiveDOMObject.h"
 #include "DOMException.h"
 #include "EventTarget.h"
+#include "ExceptionCode.h"
 #include "ExceptionOr.h"
 #include "FileReaderLoader.h"
 #include "FileReaderLoaderClient.h"
@@ -95,7 +96,7 @@
     void didStartLoading() final;
     void didReceiveData() final;
     void didFinishLoading() final;
-    void didFail(int errorCode) final;
+    void didFail(ExceptionCode errorCode) final;
 
     ExceptionOr<void> readInternal(Blob&, FileReaderLoader::ReadType);
     void fireErrorEvent(int httpStatusCode);

Modified: trunk/Source/WebCore/fileapi/FileReaderLoader.cpp (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReaderLoader.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReaderLoader.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -34,6 +34,7 @@
 
 #include "Blob.h"
 #include "BlobURL.h"
+#include "ExceptionCode.h"
 #include "FileReaderLoaderClient.h"
 #include "HTTPHeaderNames.h"
 #include "ResourceError.h"
@@ -78,7 +79,7 @@
     // The blob is read by routing through the request handling layer given a temporary public url.
     m_urlForReading = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin());
     if (m_urlForReading.isEmpty()) {
-        failed(FileError::SECURITY_ERR);
+        failed(SecurityError);
         return;
     }
     ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext->securityOrigin(), m_urlForReading, blob.url());
@@ -102,7 +103,7 @@
 
 void FileReaderLoader::cancel()
 {
-    m_errorCode = FileError::ABORT_ERR;
+    m_errorCode = AbortError;
     terminate();
 }
 
@@ -144,7 +145,7 @@
     // so to call ArrayBuffer's create function.
     // FIXME: Support reading more than the current size limit of ArrayBuffer.
     if (length > std::numeric_limits<unsigned>::max()) {
-        failed(FileError::NOT_READABLE_ERR);
+        failed(NotReadableError);
         return;
     }
 
@@ -152,7 +153,7 @@
     m_rawData = ArrayBuffer::tryCreate(static_cast<unsigned>(length), 1);
 
     if (!m_rawData) {
-        failed(FileError::NOT_READABLE_ERR);
+        failed(NotReadableError);
         return;
     }
 
@@ -176,13 +177,13 @@
     if (length > static_cast<long long>(remainingBufferSpace)) {
         // If the buffer has hit maximum size, it can't be grown any more.
         if (m_totalBytes >= std::numeric_limits<unsigned>::max()) {
-            failed(FileError::NOT_READABLE_ERR);
+            failed(NotReadableError);
             return;
         }
         if (m_variableLength) {
             unsigned newLength = m_totalBytes + static_cast<unsigned>(dataLength);
             if (newLength < m_totalBytes) {
-                failed(FileError::NOT_READABLE_ERR);
+                failed(NotReadableError);
                 return;
             }
             newLength = std::max(newLength, m_totalBytes + m_totalBytes / 4 + 1);
@@ -189,7 +190,7 @@
             auto newData = ArrayBuffer::tryCreate(newLength, 1);
             if (!newData) {
                 // Not enough memory.
-                failed(FileError::NOT_READABLE_ERR);
+                failed(NotReadableError);
                 return;
             }
             memcpy(static_cast<char*>(newData->data()), static_cast<char*>(m_rawData->data()), m_bytesLoaded);
@@ -228,37 +229,37 @@
 void FileReaderLoader::didFail(const ResourceError& error)
 {
     // If we're aborting, do not proceed with normal error handling since it is covered in aborting code.
-    if (m_errorCode == FileError::ABORT_ERR)
+    if (m_errorCode && m_errorCode.value() == AbortError)
         return;
 
     failed(toErrorCode(static_cast<BlobResourceHandle::Error>(error.errorCode())));
 }
 
-void FileReaderLoader::failed(FileError::ErrorCode errorCode)
+void FileReaderLoader::failed(ExceptionCode errorCode)
 {
     m_errorCode = errorCode;
     cleanup();
     if (m_client)
-        m_client->didFail(m_errorCode);
+        m_client->didFail(errorCode);
 }
 
-FileError::ErrorCode FileReaderLoader::toErrorCode(BlobResourceHandle::Error error)
+ExceptionCode FileReaderLoader::toErrorCode(BlobResourceHandle::Error error)
 {
     switch (error) {
     case BlobResourceHandle::Error::NotFoundError:
-        return FileError::NOT_FOUND_ERR;
+        return NotFoundError;
     default:
-        return FileError::NOT_READABLE_ERR;
+        return NotReadableError;
     }
 }
 
-FileError::ErrorCode FileReaderLoader::httpStatusCodeToErrorCode(int httpStatusCode)
+ExceptionCode FileReaderLoader::httpStatusCodeToErrorCode(int httpStatusCode)
 {
     switch (httpStatusCode) {
     case 403:
-        return FileError::SECURITY_ERR;
+        return SecurityError;
     default:
-        return FileError::NOT_READABLE_ERR;
+        return NotReadableError;
     }
 }
 

Modified: trunk/Source/WebCore/fileapi/FileReaderLoader.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReaderLoader.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReaderLoader.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -31,11 +31,12 @@
 #pragma once
 
 #include "BlobResourceHandle.h"
-#include "FileError.h"
+#include "ExceptionCode.h"
 #include <wtf/URL.h>
 #include "TextEncoding.h"
 #include "ThreadableLoaderClient.h"
 #include <wtf/Forward.h>
+#include <wtf/Optional.h>
 #include <wtf/text/WTFString.h>
 
 namespace JSC {
@@ -77,7 +78,7 @@
     WEBCORE_EXPORT RefPtr<JSC::ArrayBuffer> arrayBufferResult() const;
     unsigned bytesLoaded() const { return m_bytesLoaded; }
     unsigned totalBytes() const { return m_totalBytes; }
-    FileError::ErrorCode errorCode() const { return m_errorCode; }
+    Optional<ExceptionCode> errorCode() const { return m_errorCode; }
 
     void setEncoding(const String&);
     void setDataType(const String& dataType) { m_dataType = dataType; }
@@ -87,14 +88,14 @@
 private:
     void terminate();
     void cleanup();
-    void failed(FileError::ErrorCode);
+    void failed(ExceptionCode);
     void convertToText();
     void convertToDataURL();
 
     bool isCompleted() const;
 
-    static FileError::ErrorCode httpStatusCodeToErrorCode(int);
-    static FileError::ErrorCode toErrorCode(BlobResourceHandle::Error);
+    static ExceptionCode httpStatusCodeToErrorCode(int);
+    static ExceptionCode toErrorCode(BlobResourceHandle::Error);
 
     ReadType m_readType;
     FileReaderLoaderClient* m_client;
@@ -117,7 +118,7 @@
     unsigned m_bytesLoaded;
     unsigned m_totalBytes;
 
-    FileError::ErrorCode m_errorCode { FileError::OK };
+    Optional<ExceptionCode> m_errorCode;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/fileapi/FileReaderLoaderClient.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReaderLoaderClient.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReaderLoaderClient.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -30,6 +30,8 @@
 
 #pragma once
 
+#include "ExceptionCode.h"
+
 namespace WebCore {
 
 class FileReaderLoaderClient {
@@ -39,7 +41,7 @@
     virtual void didStartLoading() = 0;
     virtual void didReceiveData() = 0;
     virtual void didFinishLoading() = 0;
-    virtual void didFail(int errorCode) = 0;
+    virtual void didFail(ExceptionCode errorCode) = 0;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/fileapi/FileReaderSync.cpp (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReaderSync.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReaderSync.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -34,7 +34,6 @@
 
 #include "Blob.h"
 #include "BlobURL.h"
-#include "FileError.h"
 #include "FileReaderLoader.h"
 #include <_javascript_Core/ArrayBuffer.h>
 
@@ -73,43 +72,14 @@
     return startLoadingString(scriptExecutionContext, loader, blob);
 }
 
-ExceptionOr<void> FileReaderSync::errorCodeToException(FileError::ErrorCode errorCode)
-{
-    switch (errorCode) {
-    case FileError::OK:
-        return { };
-    case FileError::NOT_FOUND_ERR:
-        return Exception { NotFoundError };
-    case FileError::SECURITY_ERR:
-        return Exception { SecurityError };
-    case FileError::ABORT_ERR:
-        return Exception { AbortError };
-    case FileError::NOT_READABLE_ERR:
-        return Exception { NotReadableError };
-    case FileError::ENCODING_ERR:
-        return Exception { EncodingError };
-    case FileError::NO_MODIFICATION_ALLOWED_ERR:
-        return Exception { NoModificationAllowedError };
-    case FileError::INVALID_STATE_ERR:
-        return Exception { InvalidStateError };
-    case FileError::SYNTAX_ERR:
-        return Exception { SyntaxError };
-    case FileError::INVALID_MODIFICATION_ERR:
-        return Exception { InvalidModificationError };
-    case FileError::QUOTA_EXCEEDED_ERR:
-        return Exception { QuotaExceededError };
-    case FileError::TYPE_MISMATCH_ERR:
-        return Exception { TypeMismatchError };
-    case FileError::PATH_EXISTS_ERR:
-        return Exception { NoModificationAllowedError };
-    }
-    return Exception { UnknownError };
-}
-
 ExceptionOr<void> FileReaderSync::startLoading(ScriptExecutionContext& scriptExecutionContext, FileReaderLoader& loader, Blob& blob)
 {
     loader.start(&scriptExecutionContext, blob);
-    return errorCodeToException(loader.errorCode());
+    auto error = loader.errorCode();
+    if (!error)
+        return { };
+    
+    return Exception { error.value() };
 }
 
 ExceptionOr<String> FileReaderSync::startLoadingString(ScriptExecutionContext& scriptExecutionContext, FileReaderLoader& loader, Blob& blob)

Modified: trunk/Source/WebCore/fileapi/FileReaderSync.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/FileReaderSync.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/FileReaderSync.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -31,7 +31,6 @@
 #pragma once
 
 #include "ExceptionOr.h"
-#include "FileError.h"
 
 namespace JSC {
 class ArrayBuffer;
@@ -55,8 +54,6 @@
     ExceptionOr<String> readAsText(ScriptExecutionContext&, Blob&, const String& encoding);
     ExceptionOr<String> readAsDataURL(ScriptExecutionContext&, Blob&);
 
-    static ExceptionOr<void> errorCodeToException(FileError::ErrorCode);
-
 private:
     FileReaderSync();
 

Modified: trunk/Source/WebCore/fileapi/NetworkSendQueue.cpp (262998 => 262999)


--- trunk/Source/WebCore/fileapi/NetworkSendQueue.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/NetworkSendQueue.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -85,7 +85,8 @@
         }, [this](Ref<SharedBuffer>& data) {
             m_writeRawData(data->data(), data->size());
         }, [this, &shouldStopProcessing](UniqueRef<BlobLoader>& loader) {
-            if (loader->isLoading() || loader->errorCode() == FileError::ABORT_ERR) {
+            auto errorCode = loader->errorCode();
+            if (loader->isLoading() || (errorCode && errorCode.value() == AbortError)) {
                 shouldStopProcessing = true;
                 return;
             }
@@ -94,8 +95,8 @@
                 m_writeRawData(static_cast<const char*>(result->data()), result->byteLength());
                 return;
             }
-            ASSERT(loader->errorCode());
-            shouldStopProcessing = m_processError(loader->errorCode()) == Continue::No;
+            ASSERT(errorCode);
+            shouldStopProcessing = m_processError(errorCode.value()) == Continue::No;
         });
         if (shouldStopProcessing)
             return;

Modified: trunk/Source/WebCore/fileapi/NetworkSendQueue.h (262998 => 262999)


--- trunk/Source/WebCore/fileapi/NetworkSendQueue.h	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/fileapi/NetworkSendQueue.h	2020-06-13 16:24:15 UTC (rev 262999)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ExceptionCode.h"
 #include <wtf/Deque.h>
 #include <wtf/Function.h>
 #include <wtf/UniqueRef.h>
@@ -47,7 +48,7 @@
     using WriteString = Function<void(const String&)>;
     using WriteRawData = Function<void(const char*, size_t)>;
     enum class Continue { No, Yes };
-    using ProcessError = Function<Continue(int)>;
+    using ProcessError = Function<Continue(ExceptionCode)>;
     NetworkSendQueue(Document&, WriteString&&, WriteRawData&&, ProcessError&&);
     ~NetworkSendQueue();
 

Modified: trunk/Source/WebCore/html/ImageBitmap.cpp (262998 => 262999)


--- trunk/Source/WebCore/html/ImageBitmap.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebCore/html/ImageBitmap.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -29,6 +29,7 @@
 #include "BitmapImage.h"
 #include "Blob.h"
 #include "CachedImage.h"
+#include "ExceptionCode.h"
 #include "ExceptionOr.h"
 #include "FileReaderLoader.h"
 #include "FileReaderLoaderClient.h"
@@ -597,7 +598,7 @@
         createImageBitmapAndResolvePromiseSoon(m_blobLoader.arrayBufferResult());
     }
 
-    void didFail(int) override
+    void didFail(ExceptionCode) override
     {
         createImageBitmapAndResolvePromiseSoon(nullptr);
     }

Modified: trunk/Source/WebKit/ChangeLog (262998 => 262999)


--- trunk/Source/WebKit/ChangeLog	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebKit/ChangeLog	2020-06-13 16:24:15 UTC (rev 262999)
@@ -1,3 +1,13 @@
+2020-06-13  Tetsuharu Ohzeki  <[email protected]>
+
+        Remove FileError.h
+        https://bugs.webkit.org/show_bug.cgi?id=213119
+
+        Reviewed by Chris Dumez.
+
+        * WebProcess/Network/WebSocketChannel.cpp:
+        (WebKit::WebSocketChannel::createMessageQueue):
+
 2020-06-12  Brian Burg  <[email protected]>
 
         Automation.computeElementLayout should return iframe-relative element rects (when coordinate system is 'Page')

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (262998 => 262999)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp	2020-06-13 08:43:28 UTC (rev 262998)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp	2020-06-13 16:24:15 UTC (rev 262999)
@@ -34,6 +34,7 @@
 #include "WebProcess.h"
 #include <WebCore/Blob.h>
 #include <WebCore/Document.h>
+#include <WebCore/ExceptionCode.h>
 #include <WebCore/Page.h>
 #include <WebCore/WebSocketChannel.h>
 #include <WebCore/WebSocketChannelClient.h>
@@ -62,8 +63,9 @@
     }, [&channel](const char* data, size_t byteLength) {
         channel.notifySendFrame(WebSocketFrame::OpCode::OpCodeBinary, data, byteLength);
         channel.sendMessage(Messages::NetworkSocketChannel::SendData { IPC::DataReference { reinterpret_cast<const uint8_t*>(data), byteLength } }, byteLength);
-    }, [&channel](auto errorCode) {
-        channel.fail(makeString("Failed to load Blob: error code = ", errorCode));
+    }, [&channel](ExceptionCode exceptionCode) {
+        auto code = static_cast<int>(exceptionCode);
+        channel.fail(makeString("Failed to load Blob: exception code = ", code));
         return NetworkSendQueue::Continue::No;
     } };
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to