Title: [203954] trunk/Source/WebKit2
Revision
203954
Author
commit-qu...@webkit.org
Date
2016-07-31 01:31:14 -0700 (Sun, 31 Jul 2016)

Log Message

[GTK][Unix] Implement missing WebKit::SharedMemory::create() function
https://bugs.webkit.org/show_bug.cgi?id=160364

Patch by Adrian Perez de Castro <ape...@igalia.com> on 2016-07-31
Reviewed by Carlos Garcia Campos.

The WebKit::SharedMemory::create() function is missing for the Unix
platform, which is also used by the GTK+ port. The latter is going
to need this in place to use the common content filtering code.

* Platform/unix/SharedMemoryUnix.cpp:
(WebKit::accessModeMMap): Added helper function to convert a
SharedMemory::Protection value into flags useable with mmap().
(WebKit::SharedMemory::create): Added. Implementation reuses code
existing in the SharedMemory::allocate() function.
(WebKit::SharedMemory::allocate): Reimplemented in terms of
SharedMemory::create().

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (203953 => 203954)


--- trunk/Source/WebKit2/ChangeLog	2016-07-31 07:04:57 UTC (rev 203953)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-31 08:31:14 UTC (rev 203954)
@@ -1,3 +1,22 @@
+2016-07-31  Adrian Perez de Castro  <ape...@igalia.com>
+
+        [GTK][Unix] Implement missing WebKit::SharedMemory::create() function
+        https://bugs.webkit.org/show_bug.cgi?id=160364
+
+        Reviewed by Carlos Garcia Campos.
+
+        The WebKit::SharedMemory::create() function is missing for the Unix
+        platform, which is also used by the GTK+ port. The latter is going
+        to need this in place to use the common content filtering code.
+
+        * Platform/unix/SharedMemoryUnix.cpp:
+        (WebKit::accessModeMMap): Added helper function to convert a
+        SharedMemory::Protection value into flags useable with mmap().
+        (WebKit::SharedMemory::create): Added. Implementation reuses code
+        existing in the SharedMemory::allocate() function.
+        (WebKit::SharedMemory::allocate): Reimplemented in terms of
+        SharedMemory::create().
+
 2016-07-30  Dan Bernstein  <m...@apple.com>
 
         [Xcode] WebKit.framework is touched on incremental build even if nothing’s changed

Modified: trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp (203953 => 203954)


--- trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp	2016-07-31 07:04:57 UTC (rev 203953)
+++ trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp	2016-07-31 08:31:14 UTC (rev 203954)
@@ -93,8 +93,21 @@
     m_attachment = WTFMove(attachment);
 }
 
-RefPtr<SharedMemory> SharedMemory::allocate(size_t size)
+static inline int accessModeMMap(SharedMemory::Protection protection)
 {
+    switch (protection) {
+    case SharedMemory::Protection::ReadOnly:
+        return PROT_READ;
+    case SharedMemory::Protection::ReadWrite:
+        return PROT_READ | PROT_WRITE;
+    }
+
+    ASSERT_NOT_REACHED();
+    return PROT_READ | PROT_WRITE;
+}
+
+RefPtr<SharedMemory> SharedMemory::create(void* address, size_t size, Protection protection)
+{
     CString tempName;
 
     int fileDescriptor = -1;
@@ -119,7 +132,7 @@
         }
     }
 
-    void* data = "" size, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0);
+    void* data = "" size, accessModeMMap(protection), MAP_SHARED, fileDescriptor, 0);
     if (data == MAP_FAILED) {
         closeWithRetry(fileDescriptor);
         shm_unlink(tempName.data());
@@ -135,17 +148,9 @@
     return instance.release();
 }
 
-static inline int accessModeMMap(SharedMemory::Protection protection)
+RefPtr<SharedMemory> SharedMemory::allocate(size_t size)
 {
-    switch (protection) {
-    case SharedMemory::Protection::ReadOnly:
-        return PROT_READ;
-    case SharedMemory::Protection::ReadWrite:
-        return PROT_READ | PROT_WRITE;
-    }
-
-    ASSERT_NOT_REACHED();
-    return PROT_READ | PROT_WRITE;
+    return SharedMemory::create(nullptr, size, SharedMemory::Protection::ReadWrite);
 }
 
 RefPtr<SharedMemory> SharedMemory::map(const Handle& handle, Protection protection)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to