WebKit Bugzilla
Attachment 373420 Details for
Bug 198269
: Implement MappedFileData for Windows
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
mmap.diff (text/plain), 4.67 KB, created by
Christopher Reid
on 2019-07-03 15:15:05 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Christopher Reid
Created:
2019-07-03 15:15:05 PDT
Size:
4.67 KB
patch
obsolete
>diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index c2f305e7700..9934b6aba35 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,18 @@ >+2019-07-03 Christopher Reid <chris.reid@sony.com> >+ >+ Implement MappedFileData for Windows >+ https://bugs.webkit.org/show_bug.cgi?id=198269 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Original patch by Fujii Hironori. >+ >+ Adding windows implementations for MappedFileData constructor and destructors. >+ >+ * wtf/FileSystem.cpp: >+ * wtf/FileSystem.h: >+ * wtf/win/FileSystemWin.cpp: >+ > 2019-07-01 Philippe Normand <pnormand@igalia.com> > > [GStreamer] Cannot play Bert's Bytes radio stream from http://radio.dos.nl/ >diff --git a/Source/WTF/wtf/FileSystem.cpp b/Source/WTF/wtf/FileSystem.cpp >index ba49b1e77a7..daea139558c 100644 >--- a/Source/WTF/wtf/FileSystem.cpp >+++ b/Source/WTF/wtf/FileSystem.cpp >@@ -274,21 +274,16 @@ bool excludeFromBackup(const String&) > > #endif > >+#if HAVE(MMAP) > MappedFileData::~MappedFileData() > { >-#if !OS(WINDOWS) > if (!m_fileData) > return; > munmap(m_fileData, m_fileSize); >-#endif > } > > MappedFileData::MappedFileData(const String& filePath, bool& success) > { >-#if OS(WINDOWS) >- // FIXME: Implement mapping >- success = false; >-#else > CString fsRep = fileSystemRepresentation(filePath); > int fd = !fsRep.isNull() ? open(fsRep.data(), O_RDONLY) : -1; > if (fd < 0) { >@@ -327,8 +322,8 @@ MappedFileData::MappedFileData(const String& filePath, bool& success) > success = true; > m_fileData = data; > m_fileSize = size; >-#endif > } >+#endif > > PlatformFileHandle openAndLockFile(const String& path, FileOpenMode openMode, OptionSet<FileLockMode> lockMode) > { >diff --git a/Source/WTF/wtf/FileSystem.h b/Source/WTF/wtf/FileSystem.h >index 52ed8074a51..1fedea14c68 100644 >--- a/Source/WTF/wtf/FileSystem.h >+++ b/Source/WTF/wtf/FileSystem.h >@@ -33,6 +33,7 @@ > #include <time.h> > #include <utility> > #include <wtf/Forward.h> >+#include <wtf/Noncopyable.h> > #include <wtf/OptionSet.h> > #include <wtf/Vector.h> > #include <wtf/WallTime.h> >@@ -192,6 +193,7 @@ WTF_EXPORT_PRIVATE bool isSafeToUseMemoryMapForPath(const String&); > WTF_EXPORT_PRIVATE void makeSafeToUseMemoryMapForPath(const String&); > > class MappedFileData { >+ WTF_MAKE_NONCOPYABLE(MappedFileData); > public: > MappedFileData() { } > MappedFileData(MappedFileData&&); >diff --git a/Source/WTF/wtf/win/FileSystemWin.cpp b/Source/WTF/wtf/win/FileSystemWin.cpp >index 512753002e7..8fe01715cd4 100644 >--- a/Source/WTF/wtf/win/FileSystemWin.cpp >+++ b/Source/WTF/wtf/win/FileSystemWin.cpp >@@ -599,5 +599,44 @@ bool deleteNonEmptyDirectory(const String& directoryPath) > return !SHFileOperation(&deleteOperation); > } > >+MappedFileData::~MappedFileData() >+{ >+ if (!m_fileData) >+ return; >+ UnmapViewOfFile(m_fileData); >+} >+ >+MappedFileData::MappedFileData(const String& filePath, bool& success) >+{ >+ success = false; >+ auto file = CreateFile(filePath.wideCharacters().data(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); >+ if (file == INVALID_HANDLE_VALUE) >+ return; >+ >+ long long size; >+ if (!getFileSize(file, size) || size > std::numeric_limits<size_t>::max() || size > std::numeric_limits<decltype(m_fileSize)>::max()) { >+ CloseHandle(file); >+ return; >+ } >+ >+ if (!size) { >+ CloseHandle(file); >+ success = true; >+ return; >+ } >+ >+ auto mapping = CreateFileMapping(file, nullptr, PAGE_READONLY, 0, 0, nullptr); >+ CloseHandle(file); >+ if (!mapping) >+ return; >+ >+ m_fileData = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, size); >+ CloseHandle(mapping); >+ if (!m_fileData) >+ return; >+ m_fileSize = size; >+ success = true; >+} >+ > } // namespace FileSystemImpl > } // namespace WTF >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index bdf9bb35804..e47067cfeff 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,12 @@ >+2019-07-03 Christopher Reid <chris.reid@sony.com> >+ >+ Implement MappedFileData for Windows >+ https://bugs.webkit.org/show_bug.cgi?id=198269 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/PlatformWin.cmake: >+ > 2019-07-01 Philippe Normand <pnormand@igalia.com> > > Unreviewed, GTK a11y tests fix after r246958 >diff --git a/Tools/TestWebKitAPI/PlatformWin.cmake b/Tools/TestWebKitAPI/PlatformWin.cmake >index 0c48cf04fe5..349334826fa 100644 >--- a/Tools/TestWebKitAPI/PlatformWin.cmake >+++ b/Tools/TestWebKitAPI/PlatformWin.cmake >@@ -17,7 +17,6 @@ set(test_main_SOURCES > ) > > # TestWTF >-list(REMOVE_ITEM TestWTF_SOURCES Tests/WTF/FileSystem.cpp) > list(APPEND TestWTF_SOURCES > ${test_main_SOURCES} > win/UtilitiesWin.cpp
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
darin
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198269
:
370666
|
373420
|
373645
|
373647
|
373649