Title: [278521] trunk
Revision
278521
Author
[email protected]
Date
2021-06-04 21:47:23 -0700 (Fri, 04 Jun 2021)

Log Message

FileSystem::readFromFile() should return data as `void*`
https://bugs.webkit.org/show_bug.cgi?id=226671

Reviewed by Darin Adler.

FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and
consistent with FileSystem::writeToFile().

Source/_javascript_Core:

* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::backendCommands const):

Source/WebCore:

* platform/FileHandle.cpp:
(WebCore::FileHandle::read):
* platform/FileStream.cpp:
(WebCore::FileStream::read):
* platform/FileStream.h:
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::readSync):
(WebCore::BlobResourceHandle::readDataSync):
(WebCore::BlobResourceHandle::readFileSync):
(WebCore::BlobResourceHandle::notifyReceiveData):
* platform/network/BlobResourceHandle.h:
* platform/network/curl/CurlCacheEntry.cpp:
(WebCore::CurlCacheEntry::readCachedData):
(WebCore::CurlCacheEntry::loadResponseHeaders):
(WebCore::CurlCacheEntry::loadFileToBuffer):
* platform/network/curl/CurlCacheEntry.h:
* rendering/RenderThemeWin.cpp:
(WebCore::fillBufferWithContentsOfFile):
(WebCore::RenderThemeWin::stringWithContentsOfFile):

Source/WebKit:

* NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
(WebKit::NetworkCache::IOChannel::read):
* Shared/PersistencyUtils.cpp:
(WebKit::createForFile):

Source/WTF:

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::appendFileContentsToFileHandle):
(WTF::FileSystemImpl::readOrMakeSalt):
* wtf/FileSystem.h:
* wtf/glib/FileSystemGlib.cpp:
(WTF::FileSystemImpl::readFromFile):
* wtf/posix/FileSystemPOSIX.cpp:
(WTF::FileSystemImpl::readFromFile):
* wtf/win/FileSystemWin.cpp:
(WTF::FileSystemImpl::readFromFile):

Tools:

* TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
(TestWebKitAPI::readContentsOfFile):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (278520 => 278521)


--- trunk/Source/_javascript_Core/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-06-05 04:47:23 UTC (rev 278521)
@@ -1,3 +1,16 @@
+2021-06-04  Chris Dumez  <[email protected]>
+
+        FileSystem::readFromFile() should return data as `void*`
+        https://bugs.webkit.org/show_bug.cgi?id=226671
+
+        Reviewed by Darin Adler.
+
+        FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and
+        consistent with FileSystem::writeToFile().
+
+        * inspector/remote/socket/RemoteInspectorSocket.cpp:
+        (Inspector::RemoteInspector::backendCommands const):
+
 2021-06-04  Devin Rousso  <[email protected]>
 
         Web Inspector: mark recently added protocol commands/events as page-only

Modified: trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp (278520 => 278521)


--- trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -270,7 +270,7 @@
     String result;
     if (auto size = FileSystem::fileSize(handle)) {
         Vector<LChar> buffer(*size);
-        if (FileSystem::readFromFile(handle, reinterpret_cast<char*>(buffer.data()), *size) == *size)
+        if (FileSystem::readFromFile(handle, buffer.data(), *size) == *size)
             result = String::adopt(WTFMove(buffer));
     }
     FileSystem::closeFile(handle);

Modified: trunk/Source/WTF/ChangeLog (278520 => 278521)


--- trunk/Source/WTF/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WTF/ChangeLog	2021-06-05 04:47:23 UTC (rev 278521)
@@ -1,3 +1,24 @@
+2021-06-04  Chris Dumez  <[email protected]>
+
+        FileSystem::readFromFile() should return data as `void*`
+        https://bugs.webkit.org/show_bug.cgi?id=226671
+
+        Reviewed by Darin Adler.
+
+        FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and
+        consistent with FileSystem::writeToFile().
+
+        * wtf/FileSystem.cpp:
+        (WTF::FileSystemImpl::appendFileContentsToFileHandle):
+        (WTF::FileSystemImpl::readOrMakeSalt):
+        * wtf/FileSystem.h:
+        * wtf/glib/FileSystemGlib.cpp:
+        (WTF::FileSystemImpl::readFromFile):
+        * wtf/posix/FileSystemPOSIX.cpp:
+        (WTF::FileSystemImpl::readFromFile):
+        * wtf/win/FileSystemWin.cpp:
+        (WTF::FileSystemImpl::readFromFile):
+
 2021-06-04  Alex Christensen  <[email protected]>
 
         Implement off-by-default experimental feature for PerformanceResourceTiming.transferSize, encodedBodySize, and decodedBodySize

Modified: trunk/Source/WTF/wtf/FileSystem.cpp (278520 => 278521)


--- trunk/Source/WTF/wtf/FileSystem.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WTF/wtf/FileSystem.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -256,7 +256,7 @@
         return false;
 
     static int bufferSize = 1 << 19;
-    Vector<char> buffer(bufferSize);
+    Vector<uint8_t> buffer(bufferSize);
 
     auto fileCloser = WTF::makeScopeExit([source]() {
         PlatformFileHandle handle = source;
@@ -498,7 +498,7 @@
     if (FileSystem::fileExists(path)) {
         auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Read);
         Salt salt;
-        auto bytesRead = static_cast<std::size_t>(FileSystem::readFromFile(file, reinterpret_cast<char*>(salt.data()), salt.size()));
+        auto bytesRead = static_cast<std::size_t>(FileSystem::readFromFile(file, salt.data(), salt.size()));
         FileSystem::closeFile(file);
         if (bytesRead == salt.size())
             return salt;

Modified: trunk/Source/WTF/wtf/FileSystem.h (278520 => 278521)


--- trunk/Source/WTF/wtf/FileSystem.h	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WTF/wtf/FileSystem.h	2021-06-05 04:47:23 UTC (rev 278521)
@@ -155,7 +155,7 @@
 // Returns number of bytes actually read if successful, -1 otherwise.
 WTF_EXPORT_PRIVATE int writeToFile(PlatformFileHandle, const void* data, int length);
 // Returns number of bytes actually written if successful, -1 otherwise.
-WTF_EXPORT_PRIVATE int readFromFile(PlatformFileHandle, char* data, int length); // FIXME: Should use `void*`.
+WTF_EXPORT_PRIVATE int readFromFile(PlatformFileHandle, void* data, int length);
 
 WTF_EXPORT_PRIVATE PlatformFileHandle openAndLockFile(const String&, FileOpenMode, OptionSet<FileLockMode> = FileLockMode::Exclusive);
 WTF_EXPORT_PRIVATE void unlockAndCloseFile(PlatformFileHandle);

Modified: trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp (278520 => 278521)


--- trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -224,7 +224,7 @@
     return bytesWritten;
 }
 
-int readFromFile(PlatformFileHandle handle, char* data, int length)
+int readFromFile(PlatformFileHandle handle, void* data, int length)
 {
     GUniqueOutPtr<GError> error;
     do {

Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (278520 => 278521)


--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -128,7 +128,7 @@
     return -1;
 }
 
-int readFromFile(PlatformFileHandle handle, char* data, int length)
+int readFromFile(PlatformFileHandle handle, void* data, int length)
 {
     do {
         int bytesRead = read(handle, data, static_cast<size_t>(length));

Modified: trunk/Source/WTF/wtf/win/FileSystemWin.cpp (278520 => 278521)


--- trunk/Source/WTF/wtf/win/FileSystemWin.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WTF/wtf/win/FileSystemWin.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -316,7 +316,7 @@
     return static_cast<int>(bytesWritten);
 }
 
-int readFromFile(PlatformFileHandle handle, char* data, int length)
+int readFromFile(PlatformFileHandle handle, void* data, int length)
 {
     if (!isHandleValid(handle))
         return -1;

Modified: trunk/Source/WebCore/ChangeLog (278520 => 278521)


--- trunk/Source/WebCore/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/ChangeLog	2021-06-05 04:47:23 UTC (rev 278521)
@@ -1,5 +1,35 @@
 2021-06-04  Chris Dumez  <[email protected]>
 
+        FileSystem::readFromFile() should return data as `void*`
+        https://bugs.webkit.org/show_bug.cgi?id=226671
+
+        Reviewed by Darin Adler.
+
+        FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and
+        consistent with FileSystem::writeToFile().
+
+        * platform/FileHandle.cpp:
+        (WebCore::FileHandle::read):
+        * platform/FileStream.cpp:
+        (WebCore::FileStream::read):
+        * platform/FileStream.h:
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::readSync):
+        (WebCore::BlobResourceHandle::readDataSync):
+        (WebCore::BlobResourceHandle::readFileSync):
+        (WebCore::BlobResourceHandle::notifyReceiveData):
+        * platform/network/BlobResourceHandle.h:
+        * platform/network/curl/CurlCacheEntry.cpp:
+        (WebCore::CurlCacheEntry::readCachedData):
+        (WebCore::CurlCacheEntry::loadResponseHeaders):
+        (WebCore::CurlCacheEntry::loadFileToBuffer):
+        * platform/network/curl/CurlCacheEntry.h:
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::fillBufferWithContentsOfFile):
+        (WebCore::RenderThemeWin::stringWithContentsOfFile):
+
+2021-06-04  Chris Dumez  <[email protected]>
+
         Worker.constructor throws an exception when the url param is an empty string
         https://bugs.webkit.org/show_bug.cgi?id=226637
 

Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.cpp (278520 => 278521)


--- trunk/Source/WebCore/fileapi/AsyncFileStream.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -167,7 +167,7 @@
     });
 }
 
-void AsyncFileStream::read(char* buffer, int length)
+void AsyncFileStream::read(void* buffer, int length)
 {
     perform([buffer, length](FileStream& stream) -> WTF::Function<void(FileStreamClient&)> {
         int bytesRead = stream.read(buffer, length);

Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.h (278520 => 278521)


--- trunk/Source/WebCore/fileapi/AsyncFileStream.h	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.h	2021-06-05 04:47:23 UTC (rev 278521)
@@ -49,7 +49,7 @@
     void getSize(const String& path, std::optional<WallTime> expectedModificationTime);
     void openForRead(const String& path, long long offset, long long length);
     void close();
-    void read(char* buffer, int length);
+    void read(void* buffer, int length);
 
 private:
     void start();

Modified: trunk/Source/WebCore/platform/FileHandle.cpp (278520 => 278521)


--- trunk/Source/WebCore/platform/FileHandle.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/FileHandle.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -93,7 +93,7 @@
 {
     if (!open())
         return -1;
-    return FileSystem::readFromFile(m_fileHandle, static_cast<char*>(data), length);
+    return FileSystem::readFromFile(m_fileHandle, data, length);
 }
 
 int FileHandle::write(const void* data, int length)

Modified: trunk/Source/WebCore/platform/FileStream.cpp (278520 => 278521)


--- trunk/Source/WebCore/platform/FileStream.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/FileStream.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -96,7 +96,7 @@
     }
 }
 
-int FileStream::read(char* buffer, int bufferSize)
+int FileStream::read(void* buffer, int bufferSize)
 {
     if (!FileSystem::isHandleValid(m_handle))
         return -1;

Modified: trunk/Source/WebCore/platform/FileStream.h (278520 => 278521)


--- trunk/Source/WebCore/platform/FileStream.h	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/FileStream.h	2021-06-05 04:47:23 UTC (rev 278521)
@@ -55,7 +55,7 @@
     // Reads a file into the provided data buffer.
     // Returns number of bytes being read on success. -1 otherwise.
     // If 0 is returned, it means that the reading is completed.
-    int read(char* buffer, int length);
+    int read(void* buffer, int length);
 
 private:
     FileSystem::PlatformFileHandle m_handle;

Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (278520 => 278521)


--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -122,7 +122,7 @@
 
     // Read all the data.
     m_data.resize(static_cast<size_t>(response.expectedContentLength()));
-    static_cast<BlobResourceHandle*>(handle)->readSync(reinterpret_cast<char*>(m_data.data()), static_cast<int>(m_data.size()));
+    static_cast<BlobResourceHandle*>(handle)->readSync(m_data.data(), static_cast<int>(m_data.size()));
     completionHandler();
 }
 
@@ -320,7 +320,7 @@
         m_totalRemainingSize -= m_rangeOffset;
 }
 
-int BlobResourceHandle::readSync(char* buf, int length)
+int BlobResourceHandle::readSync(uint8_t* buf, int length)
 {
     ASSERT(isMainThread());
 
@@ -368,7 +368,7 @@
     return result;
 }
 
-int BlobResourceHandle::readDataSync(const BlobDataItem& item, char* buf, int length)
+int BlobResourceHandle::readDataSync(const BlobDataItem& item, void* buf, int length)
 {
     ASSERT(isMainThread());
 
@@ -390,7 +390,7 @@
     return bytesToRead;
 }
 
-int BlobResourceHandle::readFileSync(const BlobDataItem& item, char* buf, int length)
+int BlobResourceHandle::readFileSync(const BlobDataItem& item, void* buf, int length)
 {
     ASSERT(isMainThread());
 
@@ -460,7 +460,7 @@
     if (bytesToRead > m_totalRemainingSize)
         bytesToRead = m_totalRemainingSize;
 
-    auto* data = "" char*>(item.data().data()->data()) + item.offset() + m_currentItemReadSize;
+    auto* data = "" + item.offset() + m_currentItemReadSize;
     m_currentItemReadSize = 0;
 
     consumeData(data, static_cast<int>(bytesToRead));
@@ -506,7 +506,7 @@
     consumeData(m_buffer.data(), bytesRead);
 }
 
-void BlobResourceHandle::consumeData(const char* data, int bytesRead)
+void BlobResourceHandle::consumeData(const uint8_t* data, int bytesRead)
 {
     ASSERT(m_async);
     Ref<BlobResourceHandle> protectedThis(*this);
@@ -614,10 +614,10 @@
     });
 }
 
-void BlobResourceHandle::notifyReceiveData(const char* data, int bytesRead)
+void BlobResourceHandle::notifyReceiveData(const uint8_t* data, int bytesRead)
 {
     if (client())
-        client()->didReceiveBuffer(this, SharedBuffer::create(reinterpret_cast<const uint8_t*>(data), bytesRead), bytesRead);
+        client()->didReceiveBuffer(this, SharedBuffer::create(data, bytesRead), bytesRead);
 }
 
 void BlobResourceHandle::notifyFail(Error errorCode)

Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.h (278520 => 278521)


--- trunk/Source/WebCore/platform/network/BlobResourceHandle.h	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.h	2021-06-05 04:47:23 UTC (rev 278521)
@@ -51,7 +51,7 @@
     static void loadResourceSynchronously(BlobData*, const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<uint8_t>& data);
 
     void start();
-    int readSync(char*, int);
+    int readSync(uint8_t*, int);
 
     bool aborted() const { return m_aborted; }
 
@@ -79,7 +79,7 @@
     void doStart();
     void getSizeForNext();
     void seek();
-    void consumeData(const char* data, int bytesRead);
+    void consumeData(const uint8_t* data, int bytesRead);
     void failed(Error);
 
     void readAsync();
@@ -86,13 +86,13 @@
     void readDataAsync(const BlobDataItem&);
     void readFileAsync(const BlobDataItem&);
 
-    int readDataSync(const BlobDataItem&, char*, int);
-    int readFileSync(const BlobDataItem&, char*, int);
+    int readDataSync(const BlobDataItem&, void*, int);
+    int readFileSync(const BlobDataItem&, void*, int);
 
     void notifyResponse();
     void notifyResponseOnSuccess();
     void notifyResponseOnError();
-    void notifyReceiveData(const char*, int);
+    void notifyReceiveData(const uint8_t*, int);
     void notifyFail(Error);
     void notifyFinish();
 
@@ -104,7 +104,7 @@
     bool m_async;
     std::unique_ptr<AsyncFileStream> m_asyncStream; // For asynchronous loading.
     std::unique_ptr<FileStream> m_stream; // For synchronous loading.
-    Vector<char> m_buffer;
+    Vector<uint8_t> m_buffer;
     Vector<long long> m_itemLengthList;
     Error m_errorCode { Error::NoError };
     bool m_aborted { false };

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp (278520 => 278521)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -113,12 +113,12 @@
 {
     ASSERT(job->client());
 
-    Vector<char> buffer;
+    Vector<uint8_t> buffer;
     if (!loadFileToBuffer(m_contentFilename, buffer))
         return false;
 
-    if (buffer.size())
-        job->getInternal()->client()->didReceiveBuffer(job, SharedBuffer::create(buffer.data(), buffer.size()), buffer.size());
+    if (auto bufferSize = buffer.size())
+        job->getInternal()->client()->didReceiveBuffer(job, SharedBuffer::create(WTFMove(buffer)), bufferSize);
 
     return true;
 }
@@ -151,7 +151,7 @@
 
 bool CurlCacheEntry::loadResponseHeaders()
 {
-    Vector<char> buffer;
+    Vector<uint8_t> buffer;
     if (!loadFileToBuffer(m_headerFilename, buffer))
         return false;
 
@@ -223,7 +223,7 @@
     m_basename = baseNameBuilder.toString();
 }
 
-bool CurlCacheEntry::loadFileToBuffer(const String& filepath, Vector<char>& buffer)
+bool CurlCacheEntry::loadFileToBuffer(const String& filepath, Vector<uint8_t>& buffer)
 {
     // Open the file
     FileSystem::PlatformFileHandle inputFile = FileSystem::openFile(filepath, FileSystem::FileOpenMode::Read);

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.h (278520 => 278521)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.h	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.h	2021-06-05 04:47:23 UTC (rev 278521)
@@ -89,7 +89,7 @@
     ResourceHandle* m_job;
 
     void generateBaseFilename(const CString& url);
-    bool loadFileToBuffer(const String& filepath, Vector<char>& buffer);
+    bool loadFileToBuffer(const String& filepath, Vector<uint8_t>& buffer);
     bool loadResponseHeaders();
 
     bool openContentFile();

Modified: trunk/Source/WebCore/rendering/RenderThemeWin.cpp (278520 => 278521)


--- trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -1013,7 +1013,7 @@
 }
 
 #if ENABLE(VIDEO)
-static void fillBufferWithContentsOfFile(FileSystem::PlatformFileHandle file, long long filesize, Vector<char>& buffer)
+static void fillBufferWithContentsOfFile(FileSystem::PlatformFileHandle file, long long filesize, Vector<uint8_t>& buffer)
 {
     // Load the file content into buffer
     buffer.resize(filesize + 1);
@@ -1058,7 +1058,7 @@
         return String();
     }
 
-    Vector<char> fileContents;
+    Vector<uint8_t> fileContents;
     fillBufferWithContentsOfFile(requestedFileHandle, *filesize, fileContents);
     FileSystem::closeFile(requestedFileHandle);
 

Modified: trunk/Source/WebKit/ChangeLog (278520 => 278521)


--- trunk/Source/WebKit/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebKit/ChangeLog	2021-06-05 04:47:23 UTC (rev 278521)
@@ -1,3 +1,18 @@
+2021-06-04  Chris Dumez  <[email protected]>
+
+        FileSystem::readFromFile() should return data as `void*`
+        https://bugs.webkit.org/show_bug.cgi?id=226671
+
+        Reviewed by Darin Adler.
+
+        FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and
+        consistent with FileSystem::writeToFile().
+
+        * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
+        (WebKit::NetworkCache::IOChannel::read):
+        * Shared/PersistencyUtils.cpp:
+        (WebKit::createForFile):
+
 2021-06-04  Alex Christensen  <[email protected]>
 
         REGRESSION(r275765) When ignoring HSTS, sometimes loads fail

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp (278520 => 278521)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -68,7 +68,7 @@
         readSize = std::min(size, readSize);
         Vector<uint8_t> buffer(readSize);
         FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning);
-        int err = FileSystem::readFromFile(m_fileDescriptor, reinterpret_cast<char*>(buffer.data()), readSize);
+        int err = FileSystem::readFromFile(m_fileDescriptor, buffer.data(), readSize);
         err = err < 0 ? err : 0;
         auto data = ""
         completionHandler(data, err);

Modified: trunk/Source/WebKit/Shared/PersistencyUtils.cpp (278520 => 278521)


--- trunk/Source/WebKit/Shared/PersistencyUtils.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Source/WebKit/Shared/PersistencyUtils.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -55,7 +55,7 @@
         return nullptr;
     }
 
-    Vector<char> buffer(bytesToRead);
+    Vector<uint8_t> buffer(bytesToRead);
     size_t totalBytesRead = FileSystem::readFromFile(handle, buffer.data(), buffer.size());
 
     FileSystem::unlockAndCloseFile(handle);
@@ -64,7 +64,7 @@
         return nullptr;
 
     // FIXME: We should try to modify the constructor to pass &&.
-    return KeyedDecoder::decoder(reinterpret_cast<const uint8_t*>(buffer.data()), buffer.size());
+    return KeyedDecoder::decoder(buffer.data(), buffer.size());
 }
 
 void writeToDisk(std::unique_ptr<KeyedEncoder>&& encoder, String&& path)

Modified: trunk/Tools/ChangeLog (278520 => 278521)


--- trunk/Tools/ChangeLog	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Tools/ChangeLog	2021-06-05 04:47:23 UTC (rev 278521)
@@ -1,5 +1,18 @@
 2021-06-04  Chris Dumez  <[email protected]>
 
+        FileSystem::readFromFile() should return data as `void*`
+        https://bugs.webkit.org/show_bug.cgi?id=226671
+
+        Reviewed by Darin Adler.
+
+        FileSystem::readFromFile() should return data as `void*` instead of `char*`. This is more flexible and
+        consistent with FileSystem::writeToFile().
+
+        * TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
+        (TestWebKitAPI::readContentsOfFile):
+
+2021-06-04  Chris Dumez  <[email protected]>
+
         Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer
         https://bugs.webkit.org/show_bug.cgi?id=226623
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/FileMonitor.cpp (278520 => 278521)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FileMonitor.cpp	2021-06-05 04:39:39 UTC (rev 278520)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FileMonitor.cpp	2021-06-05 04:47:23 UTC (rev 278521)
@@ -120,7 +120,7 @@
     });
 
     // Since we control the test files, we know we only need one read
-    int readBytes = FileSystem::readFromFile(source, reinterpret_cast<char*>(buffer.characters()), bufferSize);
+    int readBytes = FileSystem::readFromFile(source, buffer.characters(), bufferSize);
     if (readBytes < 0)
         return emptyString();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to