WebKit Bugzilla
Attachment 357418 Details for
Bug 192714
: Unify SharedMemory factory functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v3
bug-192714-20181216220544.patch (text/plain), 7.58 KB, created by
Adrian Perez
on 2018-12-16 10:07:16 PST
(
hide
)
Description:
Patch v3
Filename:
MIME Type:
Creator:
Adrian Perez
Created:
2018-12-16 10:07:16 PST
Size:
7.58 KB
patch
obsolete
>Subversion Revision: 239259 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 30d7454dfbc33c77fb4c2e701c7cdf8b28652140..6fb12557b6a2575f95a126741ca15130a494cd5d 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2018-12-16 Adrian Perez de Castro <aperez@igalia.com> >+ >+ Unify SharedMemory factory functions >+ https://bugs.webkit.org/show_bug.cgi?id=192714 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This unifies SharedMemory so in the following way, across platforms: >+ >+ - SharedMemory::create() is removed, to avoid ambiguity. >+ - SharedMemory::allocate() always allocates a new block of shared memory. >+ - SharedMemory::wrapMap() always creates a SharedMemory object which refers to an >+ existing region of memory resulting from memory-mapping a file. >+ >+ * NetworkProcess/cache/NetworkCacheDataCocoa.mm: >+ (WebKit::NetworkCache::Data::tryCreateSharedMemory const): Use SharedMemory::wrapMap(). >+ * Platform/SharedMemory.h: Remove the definition of SharedMemory::create(), and make >+ SharedMemory::wrapMap() available on OS(DARWIN) as well. >+ * Platform/cocoa/SharedMemoryCocoa.cpp: >+ (WebKit::SharedMemory::wrapMap): Renamed from ::create(). >+ * Platform/unix/SharedMemoryUnix.cpp: >+ (WebKit::SharedMemory::allocate): Renamed from ::create(). >+ * Platform/win/SharedMemoryWin.cpp: >+ (WebKit::SharedMemory::allocate): Renamed from ::create() >+ * UIProcess/API/APIContentRuleListStore.cpp: >+ (API::createExtension): Use NetworkCache::Data::tryCreateSharedMemory() instead of >+ SharedMemory::create(). >+ > 2018-12-14 Adrian Perez de Castro <aperez@igalia.com> > > [SOUP] Unreviewed build fix after r239219 >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm b/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm >index c81f858aa0a235e8d68985d1e79f791ef3118899..6a39f88700879443d669f3b29a03b28eaaf6522b 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm >@@ -108,7 +108,7 @@ RefPtr<SharedMemory> Data::tryCreateSharedMemory() const > if (isNull() || !isMap()) > return nullptr; > >- return SharedMemory::create(const_cast<uint8_t*>(data()), m_size, SharedMemory::Protection::ReadOnly); >+ return SharedMemory::wrapMap(const_cast<uint8_t*>(data()), m_size, SharedMemory::Protection::ReadOnly); > } > > } >diff --git a/Source/WebKit/Platform/SharedMemory.h b/Source/WebKit/Platform/SharedMemory.h >index 3eadb15f72a25472c7b560577f924e87b2df5065..1dc5afcfdaed4c2aca06bfb4374ebfc6653f8ded 100644 >--- a/Source/WebKit/Platform/SharedMemory.h >+++ b/Source/WebKit/Platform/SharedMemory.h >@@ -94,6 +94,8 @@ public: > static RefPtr<SharedMemory> map(const Handle&, Protection); > #if USE(UNIX_DOMAIN_SOCKETS) > static RefPtr<SharedMemory> wrapMap(void*, size_t, int fileDescriptor); >+#elif OS(DARWIN) >+ static RefPtr<SharedMemory> wrapMap(void*, size_t, Protection); > #endif > #if OS(WINDOWS) > static RefPtr<SharedMemory> adopt(HANDLE, size_t, Protection); >diff --git a/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp b/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp >index 363ad32a70ac40c28f40f7692a775c73033b7da0..e02889125f24fa666fae1bbdbce63ba02842513c 100644 >--- a/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp >+++ b/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp >@@ -157,7 +157,7 @@ static WTF::MachSendRight makeMemoryEntry(size_t size, vm_offset_t offset, Share > return WTF::MachSendRight::adopt(port); > } > >-RefPtr<SharedMemory> SharedMemory::create(void* data, size_t size, Protection protection) >+RefPtr<SharedMemory> SharedMemory::wrapMap(void* data, size_t size, Protection protection) > { > ASSERT(size); > >diff --git a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp >index 520e7975992ed9dee48a0577e0ab2950d94dc5ed..9d5c8dbd2fbc562da0cf5365f22be5086da6e1f8 100644 >--- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp >+++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp >@@ -148,7 +148,7 @@ static int createSharedMemory() > return fileDescriptor; > } > >-RefPtr<SharedMemory> SharedMemory::create(void* address, size_t size, Protection protection) >+RefPtr<SharedMemory> SharedMemory::allocate(size_t size) > { > int fileDescriptor = createSharedMemory(); > if (fileDescriptor == -1) { >@@ -163,7 +163,7 @@ RefPtr<SharedMemory> SharedMemory::create(void* address, size_t size, Protection > } > } > >- void* data = mmap(address, size, accessModeMMap(protection), MAP_SHARED, fileDescriptor, 0); >+ void* data = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0); > if (data == MAP_FAILED) { > closeWithRetry(fileDescriptor); > return nullptr; >@@ -176,11 +176,6 @@ RefPtr<SharedMemory> SharedMemory::create(void* address, size_t size, Protection > return instance; > } > >-RefPtr<SharedMemory> SharedMemory::allocate(size_t size) >-{ >- return SharedMemory::create(nullptr, size, SharedMemory::Protection::ReadWrite); >-} >- > RefPtr<SharedMemory> SharedMemory::map(const Handle& handle, Protection protection) > { > ASSERT(!handle.isNull()); >diff --git a/Source/WebKit/Platform/win/SharedMemoryWin.cpp b/Source/WebKit/Platform/win/SharedMemoryWin.cpp >index 2d32c3313cd432fadbd7c4676fa0752d50e8ee29..61df19a25906e94be259162b7d6e8bd32d13c81f 100644 >--- a/Source/WebKit/Platform/win/SharedMemoryWin.cpp >+++ b/Source/WebKit/Platform/win/SharedMemoryWin.cpp >@@ -132,16 +132,11 @@ static DWORD protectAttribute(SharedMemory::Protection protection) > > RefPtr<SharedMemory> SharedMemory::allocate(size_t size) > { >- return SharedMemory::create(nullptr, size, SharedMemory::Protection::ReadWrite); >-} >- >-RefPtr<SharedMemory> SharedMemory::create(void* address, size_t size, Protection protection) >-{ >- HANDLE handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, 0, protectAttribute(protection), 0, size, 0); >+ HANDLE handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, 0, protectAttribute(SharedMemory::Protection::ReadWrite), 0, size, 0); > if (!handle) > return nullptr; > >- void* baseAddress = ::MapViewOfFileEx(handle, FILE_MAP_ALL_ACCESS, 0, 0, size, address); >+ void* baseAddress = ::MapViewOfFileEx(handle, FILE_MAP_ALL_ACCESS, 0, 0, size, nullptr); > if (!baseAddress) { > ::CloseHandle(handle); > return nullptr; >diff --git a/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp b/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp >index 26f0c3351d717c51a842dea8f2bfe46ff6a40b96..38f42cb91a538ede68e225941050f96af67b9698 100644 >--- a/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp >+++ b/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp >@@ -369,7 +369,11 @@ static std::error_code compiledToFile(WTF::String&& json, Vector<WebCore::Conten > > static Ref<API::ContentRuleList> createExtension(const WTF::String& identifier, const ContentRuleListMetaData& metaData, const WebKit::NetworkCache::Data& fileData) > { >- auto sharedMemory = WebKit::SharedMemory::create(const_cast<uint8_t*>(fileData.data()), fileData.size(), WebKit::SharedMemory::Protection::ReadOnly); >+ // Content extensions are always compiled to files, and at this point the file >+ // has been already mapped, therefore tryCreateSharedMemory() cannot fail. >+ auto sharedMemory = fileData.tryCreateSharedMemory(); >+ ASSERT(sharedMemory); >+ > const size_t headerAndSourceSize = ContentRuleListFileHeaderSize + metaData.sourceSize; > auto compiledContentRuleListData = WebKit::WebCompiledContentRuleListData( > WTFMove(sharedMemory),
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192714
:
357339
|
357342
| 357418 |
357419