Changeset 244403 in webkit


Ignore:
Timestamp:
Apr 17, 2019 3:10:03 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Make WebCompiledContentRuleListData non-default-constructible, move its nonserialized member to API::ContentRuleList
https://bugs.webkit.org/show_bug.cgi?id=197033

Reviewed by Tim Horton.

This is just cleanup that makes the code nicer without changing behavior.

  • Shared/WebCompiledContentRuleListData.cpp:

(WebKit::WebCompiledContentRuleListData::encode const):
(WebKit::WebCompiledContentRuleListData::decode):

  • Shared/WebCompiledContentRuleListData.h:

(WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):

  • UIProcess/API/APIContentRuleList.h:
  • UIProcess/API/APIContentRuleListStore.cpp:

(API::createExtension):

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244402 r244403  
     12019-04-17  Alex Christensen  <achristensen@webkit.org>
     2
     3        Make WebCompiledContentRuleListData non-default-constructible, move its nonserialized member to API::ContentRuleList
     4        https://bugs.webkit.org/show_bug.cgi?id=197033
     5
     6        Reviewed by Tim Horton.
     7
     8        This is just cleanup that makes the code nicer without changing behavior.
     9
     10        * Shared/WebCompiledContentRuleListData.cpp:
     11        (WebKit::WebCompiledContentRuleListData::encode const):
     12        (WebKit::WebCompiledContentRuleListData::decode):
     13        * Shared/WebCompiledContentRuleListData.h:
     14        (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
     15        * UIProcess/API/APIContentRuleList.h:
     16        * UIProcess/API/APIContentRuleListStore.cpp:
     17        (API::createExtension):
     18
    1192019-04-17  John Wilander  <wilander@apple.com>
    220
  • trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp

    r244225 r244403  
    6161    }
    6262
    63     // fileData needs to be kept in the UIProcess, but it does not need to be serialized.
    64     // FIXME: Move it to API::ContentRuleList
    65 
    6663    encoder << conditionsApplyOnlyToDomainOffset;
    6764    encoder << actionsOffset;
     
    7774Optional<WebCompiledContentRuleListData> WebCompiledContentRuleListData::decode(IPC::Decoder& decoder)
    7875{
    79     WebCompiledContentRuleListData compiledContentRuleListData;
     76    Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>> data;
    8077
    8178    Optional<bool> hasSharedMemory;
     
    8380    if (!hasSharedMemory)
    8481        return WTF::nullopt;
     82
    8583    if (*hasSharedMemory) {
    8684        SharedMemory::Handle handle;
    8785        if (!decoder.decode(handle))
    8886            return WTF::nullopt;
    89         compiledContentRuleListData.data = { SharedMemory::map(handle, SharedMemory::Protection::ReadOnly) };
     87        data = { SharedMemory::map(handle, SharedMemory::Protection::ReadOnly) };
    9088    } else {
    9189        IPC::DataReference dataReference;
    9290        if (!decoder.decode(dataReference))
    9391            return WTF::nullopt;
    94         compiledContentRuleListData.data = { RefPtr<WebCore::SharedBuffer>(WebCore::SharedBuffer::create(dataReference.data(), dataReference.size())) };
     92        data = { RefPtr<WebCore::SharedBuffer>(WebCore::SharedBuffer::create(dataReference.data(), dataReference.size())) };
    9593    }
    9694
    97     if (!decoder.decode(compiledContentRuleListData.conditionsApplyOnlyToDomainOffset))
    98         return WTF::nullopt;
    99     if (!decoder.decode(compiledContentRuleListData.actionsOffset))
    100         return WTF::nullopt;
    101     if (!decoder.decode(compiledContentRuleListData.actionsSize))
    102         return WTF::nullopt;
    103     if (!decoder.decode(compiledContentRuleListData.filtersWithoutConditionsBytecodeOffset))
    104         return WTF::nullopt;
    105     if (!decoder.decode(compiledContentRuleListData.filtersWithoutConditionsBytecodeSize))
    106         return WTF::nullopt;
    107     if (!decoder.decode(compiledContentRuleListData.filtersWithConditionsBytecodeOffset))
    108         return WTF::nullopt;
    109     if (!decoder.decode(compiledContentRuleListData.filtersWithConditionsBytecodeSize))
    110         return WTF::nullopt;
    111     if (!decoder.decode(compiledContentRuleListData.topURLFiltersBytecodeOffset))
    112         return WTF::nullopt;
    113     if (!decoder.decode(compiledContentRuleListData.topURLFiltersBytecodeSize))
     95    Optional<unsigned> conditionsApplyOnlyToDomainOffset;
     96    decoder >> conditionsApplyOnlyToDomainOffset;
     97    if (!conditionsApplyOnlyToDomainOffset)
    11498        return WTF::nullopt;
    11599
    116     return compiledContentRuleListData;
     100    Optional<unsigned> actionsOffset;
     101    decoder >> actionsOffset;
     102    if (!actionsOffset)
     103        return WTF::nullopt;
     104
     105    Optional<unsigned> actionsSize;
     106    decoder >> actionsSize;
     107    if (!actionsSize)
     108        return WTF::nullopt;
     109
     110    Optional<unsigned> filtersWithoutConditionsBytecodeOffset;
     111    decoder >> filtersWithoutConditionsBytecodeOffset;
     112    if (!filtersWithoutConditionsBytecodeOffset)
     113        return WTF::nullopt;
     114
     115    Optional<unsigned> filtersWithoutConditionsBytecodeSize;
     116    decoder >> filtersWithoutConditionsBytecodeSize;
     117    if (!filtersWithoutConditionsBytecodeSize)
     118        return WTF::nullopt;
     119
     120    Optional<unsigned> filtersWithConditionsBytecodeOffset;
     121    decoder >> filtersWithConditionsBytecodeOffset;
     122    if (!filtersWithConditionsBytecodeOffset)
     123        return WTF::nullopt;
     124
     125    Optional<unsigned> filtersWithConditionsBytecodeSize;
     126    decoder >> filtersWithConditionsBytecodeSize;
     127    if (!filtersWithConditionsBytecodeSize)
     128        return WTF::nullopt;
     129
     130    Optional<unsigned> topURLFiltersBytecodeOffset;
     131    decoder >> topURLFiltersBytecodeOffset;
     132    if (!topURLFiltersBytecodeOffset)
     133        return WTF::nullopt;
     134
     135    Optional<unsigned> topURLFiltersBytecodeSize;
     136    decoder >> topURLFiltersBytecodeSize;
     137    if (!topURLFiltersBytecodeSize)
     138        return WTF::nullopt;
     139
     140    return {{
     141        WTFMove(data),
     142        WTFMove(*conditionsApplyOnlyToDomainOffset),
     143        WTFMove(*actionsOffset),
     144        WTFMove(*actionsSize),
     145        WTFMove(*filtersWithoutConditionsBytecodeOffset),
     146        WTFMove(*filtersWithoutConditionsBytecodeSize),
     147        WTFMove(*filtersWithConditionsBytecodeOffset),
     148        WTFMove(*filtersWithConditionsBytecodeSize),
     149        WTFMove(*topURLFiltersBytecodeOffset),
     150        WTFMove(*topURLFiltersBytecodeSize)
     151    }};
    117152}
    118153
  • trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h

    r242735 r244403  
    2828#if ENABLE(CONTENT_EXTENSIONS)
    2929
    30 #include "NetworkCacheData.h"
    3130#include "SharedMemory.h"
    3231#include <WebCore/SharedBuffer.h>
     
    4342class WebCompiledContentRuleListData {
    4443public:
    45     WebCompiledContentRuleListData() = default;
    46 
    47     WebCompiledContentRuleListData(Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>>&& data, NetworkCache::Data fileData, unsigned conditionsApplyOnlyToDomainOffset, unsigned actionsOffset, unsigned actionsSize, unsigned filtersWithoutConditionsBytecodeOffset, unsigned filtersWithoutConditionsBytecodeSize, unsigned filtersWithConditionsBytecodeOffset, unsigned filtersWithConditionsBytecodeSize, unsigned topURLFiltersBytecodeOffset, unsigned topURLFiltersBytecodeSize)
     44    WebCompiledContentRuleListData(Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>>&& data, unsigned conditionsApplyOnlyToDomainOffset, unsigned actionsOffset, unsigned actionsSize, unsigned filtersWithoutConditionsBytecodeOffset, unsigned filtersWithoutConditionsBytecodeSize, unsigned filtersWithConditionsBytecodeOffset, unsigned filtersWithConditionsBytecodeSize, unsigned topURLFiltersBytecodeOffset, unsigned topURLFiltersBytecodeSize)
    4845        : data(WTFMove(data))
    49         , fileData(fileData)
    5046        , conditionsApplyOnlyToDomainOffset(conditionsApplyOnlyToDomainOffset)
    5147        , actionsOffset(actionsOffset)
     
    6763   
    6864    Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>> data;
    69     NetworkCache::Data fileData;
    7065    unsigned conditionsApplyOnlyToDomainOffset { 0 };
    7166    unsigned actionsOffset { 0 };
  • trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp

    r242735 r244403  
    3333namespace API {
    3434
    35 ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList)
     35ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
    3636    : m_name(name)
    3737    , m_compiledRuleList(WTFMove(contentRuleList))
     38    , m_mappedFile(WTFMove(mappedFile))
    3839{
    3940}
  • trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h

    r242735 r244403  
    2727
    2828#include "APIObject.h"
     29#include "NetworkCacheData.h"
    2930#include <wtf/text/WTFString.h>
    3031
     
    3839public:
    3940#if ENABLE(CONTENT_EXTENSIONS)
    40     static Ref<ContentRuleList> create(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList)
     41    static Ref<ContentRuleList> create(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
    4142    {
    42         return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList)));
     43        return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList), WTFMove(mappedFile)));
    4344    }
    4445
    45     ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&&);
     46    ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&&, WebKit::NetworkCache::Data&&);
    4647    virtual ~ContentRuleList();
    4748
     
    5455    WTF::String m_name;
    5556    Ref<WebKit::WebCompiledContentRuleList> m_compiledRuleList;
     57    WebKit::NetworkCache::Data m_mappedFile;
    5658#endif // ENABLE(CONTENT_EXTENSIONS)
    5759};
  • trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp

    r243163 r244403  
    440440    auto compiledContentRuleListData = WebKit::WebCompiledContentRuleListData(
    441441        WTFMove(mappedOrCopiedFileData),
    442         WTF::holds_alternative<WebKit::NetworkCache::Data>(data.data) ? WTF::get<WebKit::NetworkCache::Data>(data.data) : WebKit::NetworkCache::Data { },
    443442        ConditionsApplyOnlyToDomainOffset,
    444443        headerAndSourceSize,
     
    458457    );
    459458    auto compiledContentRuleList = WebKit::WebCompiledContentRuleList::create(WTFMove(compiledContentRuleListData));
    460     return API::ContentRuleList::create(identifier, WTFMove(compiledContentRuleList));
     459    return API::ContentRuleList::create(identifier, WTFMove(compiledContentRuleList), WTF::holds_alternative<WebKit::NetworkCache::Data>(data.data) ? WTF::get<WebKit::NetworkCache::Data>(data.data) : WebKit::NetworkCache::Data { });
    461460}
    462461
Note: See TracChangeset for help on using the changeset viewer.