Changeset 203954 in webkit


Ignore:
Timestamp:
Jul 31, 2016 1:31:14 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Adrian Perez de Castro <Adrian Perez de Castro> 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().

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r203944 r203954  
     12016-07-31  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [GTK][Unix] Implement missing WebKit::SharedMemory::create() function
     4        https://bugs.webkit.org/show_bug.cgi?id=160364
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        The WebKit::SharedMemory::create() function is missing for the Unix
     9        platform, which is also used by the GTK+ port. The latter is going
     10        to need this in place to use the common content filtering code.
     11
     12        * Platform/unix/SharedMemoryUnix.cpp:
     13        (WebKit::accessModeMMap): Added helper function to convert a
     14        SharedMemory::Protection value into flags useable with mmap().
     15        (WebKit::SharedMemory::create): Added. Implementation reuses code
     16        existing in the SharedMemory::allocate() function.
     17        (WebKit::SharedMemory::allocate): Reimplemented in terms of
     18        SharedMemory::create().
     19
    1202016-07-30  Dan Bernstein  <mitz@apple.com>
    221
  • trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp

    r203155 r203954  
    9494}
    9595
    96 RefPtr<SharedMemory> SharedMemory::allocate(size_t size)
     96static inline int accessModeMMap(SharedMemory::Protection protection)
     97{
     98    switch (protection) {
     99    case SharedMemory::Protection::ReadOnly:
     100        return PROT_READ;
     101    case SharedMemory::Protection::ReadWrite:
     102        return PROT_READ | PROT_WRITE;
     103    }
     104
     105    ASSERT_NOT_REACHED();
     106    return PROT_READ | PROT_WRITE;
     107}
     108
     109RefPtr<SharedMemory> SharedMemory::create(void* address, size_t size, Protection protection)
    97110{
    98111    CString tempName;
     
    120133    }
    121134
    122     void* data = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0);
     135    void* data = mmap(address, size, accessModeMMap(protection), MAP_SHARED, fileDescriptor, 0);
    123136    if (data == MAP_FAILED) {
    124137        closeWithRetry(fileDescriptor);
     
    136149}
    137150
    138 static inline int accessModeMMap(SharedMemory::Protection protection)
    139 {
    140     switch (protection) {
    141     case SharedMemory::Protection::ReadOnly:
    142         return PROT_READ;
    143     case SharedMemory::Protection::ReadWrite:
    144         return PROT_READ | PROT_WRITE;
    145     }
    146 
    147     ASSERT_NOT_REACHED();
    148     return PROT_READ | PROT_WRITE;
     151RefPtr<SharedMemory> SharedMemory::allocate(size_t size)
     152{
     153    return SharedMemory::create(nullptr, size, SharedMemory::Protection::ReadWrite);
    149154}
    150155
Note: See TracChangeset for help on using the changeset viewer.