Changeset 244403 in webkit
- Timestamp:
- Apr 17, 2019 3:10:03 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244402 r244403 1 2019-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 1 19 2019-04-17 John Wilander <wilander@apple.com> 2 20 -
trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp
r244225 r244403 61 61 } 62 62 63 // fileData needs to be kept in the UIProcess, but it does not need to be serialized.64 // FIXME: Move it to API::ContentRuleList65 66 63 encoder << conditionsApplyOnlyToDomainOffset; 67 64 encoder << actionsOffset; … … 77 74 Optional<WebCompiledContentRuleListData> WebCompiledContentRuleListData::decode(IPC::Decoder& decoder) 78 75 { 79 WebCompiledContentRuleListData compiledContentRuleListData;76 Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>> data; 80 77 81 78 Optional<bool> hasSharedMemory; … … 83 80 if (!hasSharedMemory) 84 81 return WTF::nullopt; 82 85 83 if (*hasSharedMemory) { 86 84 SharedMemory::Handle handle; 87 85 if (!decoder.decode(handle)) 88 86 return WTF::nullopt; 89 compiledContentRuleListData.data = { SharedMemory::map(handle, SharedMemory::Protection::ReadOnly) };87 data = { SharedMemory::map(handle, SharedMemory::Protection::ReadOnly) }; 90 88 } else { 91 89 IPC::DataReference dataReference; 92 90 if (!decoder.decode(dataReference)) 93 91 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())) }; 95 93 } 96 94 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) 114 98 return WTF::nullopt; 115 99 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 }}; 117 152 } 118 153 -
trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h
r242735 r244403 28 28 #if ENABLE(CONTENT_EXTENSIONS) 29 29 30 #include "NetworkCacheData.h"31 30 #include "SharedMemory.h" 32 31 #include <WebCore/SharedBuffer.h> … … 43 42 class WebCompiledContentRuleListData { 44 43 public: 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) 48 45 : data(WTFMove(data)) 49 , fileData(fileData)50 46 , conditionsApplyOnlyToDomainOffset(conditionsApplyOnlyToDomainOffset) 51 47 , actionsOffset(actionsOffset) … … 67 63 68 64 Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>> data; 69 NetworkCache::Data fileData;70 65 unsigned conditionsApplyOnlyToDomainOffset { 0 }; 71 66 unsigned actionsOffset { 0 }; -
trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp
r242735 r244403 33 33 namespace API { 34 34 35 ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList )35 ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile) 36 36 : m_name(name) 37 37 , m_compiledRuleList(WTFMove(contentRuleList)) 38 , m_mappedFile(WTFMove(mappedFile)) 38 39 { 39 40 } -
trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h
r242735 r244403 27 27 28 28 #include "APIObject.h" 29 #include "NetworkCacheData.h" 29 30 #include <wtf/text/WTFString.h> 30 31 … … 38 39 public: 39 40 #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) 41 42 { 42 return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList) ));43 return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList), WTFMove(mappedFile))); 43 44 } 44 45 45 ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& );46 ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&&, WebKit::NetworkCache::Data&&); 46 47 virtual ~ContentRuleList(); 47 48 … … 54 55 WTF::String m_name; 55 56 Ref<WebKit::WebCompiledContentRuleList> m_compiledRuleList; 57 WebKit::NetworkCache::Data m_mappedFile; 56 58 #endif // ENABLE(CONTENT_EXTENSIONS) 57 59 }; -
trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp
r243163 r244403 440 440 auto compiledContentRuleListData = WebKit::WebCompiledContentRuleListData( 441 441 WTFMove(mappedOrCopiedFileData), 442 WTF::holds_alternative<WebKit::NetworkCache::Data>(data.data) ? WTF::get<WebKit::NetworkCache::Data>(data.data) : WebKit::NetworkCache::Data { },443 442 ConditionsApplyOnlyToDomainOffset, 444 443 headerAndSourceSize, … … 458 457 ); 459 458 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 { }); 461 460 } 462 461
Note: See TracChangeset
for help on using the changeset viewer.