Diff
Modified: trunk/Source/WebKit/ChangeLog (244402 => 244403)
--- trunk/Source/WebKit/ChangeLog 2019-04-17 21:47:04 UTC (rev 244402)
+++ trunk/Source/WebKit/ChangeLog 2019-04-17 22:10:03 UTC (rev 244403)
@@ -1,3 +1,21 @@
+2019-04-17 Alex Christensen <[email protected]>
+
+ 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):
+
2019-04-17 John Wilander <[email protected]>
Add prioritization of ad click conversions and cleaning of sent ad click conversions
Modified: trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp (244402 => 244403)
--- trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp 2019-04-17 21:47:04 UTC (rev 244402)
+++ trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp 2019-04-17 22:10:03 UTC (rev 244403)
@@ -60,9 +60,6 @@
encoder << IPC::SharedBufferDataReference { *WTF::get<RefPtr<WebCore::SharedBuffer>>(data) };
}
- // fileData needs to be kept in the UIProcess, but it does not need to be serialized.
- // FIXME: Move it to API::ContentRuleList
-
encoder << conditionsApplyOnlyToDomainOffset;
encoder << actionsOffset;
encoder << actionsSize;
@@ -76,44 +73,82 @@
Optional<WebCompiledContentRuleListData> WebCompiledContentRuleListData::decode(IPC::Decoder& decoder)
{
- WebCompiledContentRuleListData compiledContentRuleListData;
+ Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>> data;
Optional<bool> hasSharedMemory;
decoder >> hasSharedMemory;
if (!hasSharedMemory)
return WTF::nullopt;
+
if (*hasSharedMemory) {
SharedMemory::Handle handle;
if (!decoder.decode(handle))
return WTF::nullopt;
- compiledContentRuleListData.data = { SharedMemory::map(handle, SharedMemory::Protection::ReadOnly) };
+ data = { SharedMemory::map(handle, SharedMemory::Protection::ReadOnly) };
} else {
IPC::DataReference dataReference;
if (!decoder.decode(dataReference))
return WTF::nullopt;
- compiledContentRuleListData.data = { RefPtr<WebCore::SharedBuffer>(WebCore::SharedBuffer::create(dataReference.data(), dataReference.size())) };
+ data = { RefPtr<WebCore::SharedBuffer>(WebCore::SharedBuffer::create(dataReference.data(), dataReference.size())) };
}
- if (!decoder.decode(compiledContentRuleListData.conditionsApplyOnlyToDomainOffset))
+ Optional<unsigned> conditionsApplyOnlyToDomainOffset;
+ decoder >> conditionsApplyOnlyToDomainOffset;
+ if (!conditionsApplyOnlyToDomainOffset)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.actionsOffset))
+
+ Optional<unsigned> actionsOffset;
+ decoder >> actionsOffset;
+ if (!actionsOffset)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.actionsSize))
+
+ Optional<unsigned> actionsSize;
+ decoder >> actionsSize;
+ if (!actionsSize)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.filtersWithoutConditionsBytecodeOffset))
+
+ Optional<unsigned> filtersWithoutConditionsBytecodeOffset;
+ decoder >> filtersWithoutConditionsBytecodeOffset;
+ if (!filtersWithoutConditionsBytecodeOffset)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.filtersWithoutConditionsBytecodeSize))
+
+ Optional<unsigned> filtersWithoutConditionsBytecodeSize;
+ decoder >> filtersWithoutConditionsBytecodeSize;
+ if (!filtersWithoutConditionsBytecodeSize)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.filtersWithConditionsBytecodeOffset))
+
+ Optional<unsigned> filtersWithConditionsBytecodeOffset;
+ decoder >> filtersWithConditionsBytecodeOffset;
+ if (!filtersWithConditionsBytecodeOffset)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.filtersWithConditionsBytecodeSize))
+
+ Optional<unsigned> filtersWithConditionsBytecodeSize;
+ decoder >> filtersWithConditionsBytecodeSize;
+ if (!filtersWithConditionsBytecodeSize)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.topURLFiltersBytecodeOffset))
+
+ Optional<unsigned> topURLFiltersBytecodeOffset;
+ decoder >> topURLFiltersBytecodeOffset;
+ if (!topURLFiltersBytecodeOffset)
return WTF::nullopt;
- if (!decoder.decode(compiledContentRuleListData.topURLFiltersBytecodeSize))
+
+ Optional<unsigned> topURLFiltersBytecodeSize;
+ decoder >> topURLFiltersBytecodeSize;
+ if (!topURLFiltersBytecodeSize)
return WTF::nullopt;
- return compiledContentRuleListData;
+ return {{
+ WTFMove(data),
+ WTFMove(*conditionsApplyOnlyToDomainOffset),
+ WTFMove(*actionsOffset),
+ WTFMove(*actionsSize),
+ WTFMove(*filtersWithoutConditionsBytecodeOffset),
+ WTFMove(*filtersWithoutConditionsBytecodeSize),
+ WTFMove(*filtersWithConditionsBytecodeOffset),
+ WTFMove(*filtersWithConditionsBytecodeSize),
+ WTFMove(*topURLFiltersBytecodeOffset),
+ WTFMove(*topURLFiltersBytecodeSize)
+ }};
}
} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h (244402 => 244403)
--- trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h 2019-04-17 21:47:04 UTC (rev 244402)
+++ trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h 2019-04-17 22:10:03 UTC (rev 244403)
@@ -27,7 +27,6 @@
#if ENABLE(CONTENT_EXTENSIONS)
-#include "NetworkCacheData.h"
#include "SharedMemory.h"
#include <WebCore/SharedBuffer.h>
#include <wtf/RefPtr.h>
@@ -42,11 +41,8 @@
class WebCompiledContentRuleListData {
public:
- WebCompiledContentRuleListData() = default;
-
- 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)
+ 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)
: data(WTFMove(data))
- , fileData(fileData)
, conditionsApplyOnlyToDomainOffset(conditionsApplyOnlyToDomainOffset)
, actionsOffset(actionsOffset)
, actionsSize(actionsSize)
@@ -66,7 +62,6 @@
const void* dataPointer() const;
Variant<RefPtr<SharedMemory>, RefPtr<WebCore::SharedBuffer>> data;
- NetworkCache::Data fileData;
unsigned conditionsApplyOnlyToDomainOffset { 0 };
unsigned actionsOffset { 0 };
unsigned actionsSize { 0 };
Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp (244402 => 244403)
--- trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp 2019-04-17 21:47:04 UTC (rev 244402)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp 2019-04-17 22:10:03 UTC (rev 244403)
@@ -32,9 +32,10 @@
namespace API {
-ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList)
+ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
: m_name(name)
, m_compiledRuleList(WTFMove(contentRuleList))
+ , m_mappedFile(WTFMove(mappedFile))
{
}
Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h (244402 => 244403)
--- trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h 2019-04-17 21:47:04 UTC (rev 244402)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h 2019-04-17 22:10:03 UTC (rev 244403)
@@ -26,6 +26,7 @@
#pragma once
#include "APIObject.h"
+#include "NetworkCacheData.h"
#include <wtf/text/WTFString.h>
namespace WebKit {
@@ -37,12 +38,12 @@
class ContentRuleList final : public ObjectImpl<Object::Type::ContentRuleList> {
public:
#if ENABLE(CONTENT_EXTENSIONS)
- static Ref<ContentRuleList> create(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList)
+ static Ref<ContentRuleList> create(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
{
- return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList)));
+ return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList), WTFMove(mappedFile)));
}
- ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&&);
+ ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&&, WebKit::NetworkCache::Data&&);
virtual ~ContentRuleList();
const WTF::String& name() const { return m_name; }
@@ -53,6 +54,7 @@
private:
WTF::String m_name;
Ref<WebKit::WebCompiledContentRuleList> m_compiledRuleList;
+ WebKit::NetworkCache::Data m_mappedFile;
#endif // ENABLE(CONTENT_EXTENSIONS)
};
Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp (244402 => 244403)
--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp 2019-04-17 21:47:04 UTC (rev 244402)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp 2019-04-17 22:10:03 UTC (rev 244403)
@@ -439,7 +439,6 @@
const size_t headerAndSourceSize = ContentRuleListFileHeaderSize + data.metaData.sourceSize;
auto compiledContentRuleListData = WebKit::WebCompiledContentRuleListData(
WTFMove(mappedOrCopiedFileData),
- WTF::holds_alternative<WebKit::NetworkCache::Data>(data.data) ? WTF::get<WebKit::NetworkCache::Data>(data.data) : WebKit::NetworkCache::Data { },
ConditionsApplyOnlyToDomainOffset,
headerAndSourceSize,
data.metaData.actionsSize,
@@ -457,7 +456,7 @@
data.metaData.conditionedFiltersBytecodeSize
);
auto compiledContentRuleList = WebKit::WebCompiledContentRuleList::create(WTFMove(compiledContentRuleListData));
- return API::ContentRuleList::create(identifier, WTFMove(compiledContentRuleList));
+ 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 { });
}
void ContentRuleListStore::lookupContentRuleList(const WTF::String& identifier, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)