[Content Extensions] Move compiling of content extensions to the UIProcess
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2015 02:41:44 +0000 (02:41 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2015 02:41:44 +0000 (02:41 +0000)
commitd6ac12f6478d2edd6ce161032583a66bac02b74d
treed8e682b56f6397d0e78f6b73881a06d11651c49d
parentce2cf7e7faaf842b500ca102d01bab6b49b82fdd
[Content Extensions] Move compiling of content extensions to the UIProcess
https://bugs.webkit.org/show_bug.cgi?id=142402

Reviewed by Benjamin Poulain.

Source/WebCore:

* contentextensions/CompiledContentExtension.cpp:
(WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension):
(WebCore::ContentExtensions::CompiledContentExtension::create): Deleted.
(WebCore::ContentExtensions::CompiledContentExtension::CompiledContentExtension): Deleted.
* contentextensions/CompiledContentExtension.h:
(WebCore::ContentExtensions::CompiledContentExtension::bytecode): Deleted.
(WebCore::ContentExtensions::CompiledContentExtension::actions): Deleted.
Convert CompiledContentExtension to be an abstract base class so that we can back it however
we like at the WebKit level. Since it doesn't necessarily use Vectors for its backing store
any more, change the interface to use pointer/length.

* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionCompiler.h:
Change compileRuleList to return compiled result as the raw Vectors rather than as
a CompiledContentExtension, since that class is now abstract. It is up to the caller
to copy the data into its final home.

* contentextensions/ContentExtensionRule.cpp:
(WebCore::ContentExtensions::Action::deserialize):
* contentextensions/ContentExtensionRule.h:
Switch Action::deserialize to take pointer/length rather than a Vector.

* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForURL):
Pull getting the serialized actions from the compiled extension out of the loop
to avoid calling the virtual function multiple times. Pass the bytecode and actions
as pointer/length pairs rather than Vectors.

* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::getBits):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
* contentextensions/DFABytecodeInterpreter.h:
(WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):
Switch the interpreter to take pointer/length rather than a Vector.

* page/UserContentController.cpp:
(WebCore::UserContentController::addUserContentExtension):
(WebCore::UserContentController::removeUserContentExtension):
(WebCore::UserContentController::removeAllUserContentExtensions):
(WebCore::UserContentController::addUserContentFilter): Deleted.
(WebCore::UserContentController::removeUserContentFilter): Deleted.
(WebCore::UserContentController::removeAllUserContentFilters): Deleted.
* page/UserContentController.h:
Unify terminology to use the term UserContentExtension rather than UserContentFilter.

Source/WebKit2:

* Shared/API/APIObject.h:
Rename UserContentFilter type to UserContentExtension to match new unified naming.

* Shared/WebCompiledContentExtension.cpp: Added.
(WebKit::WebCompiledContentExtension::create):
(WebKit::WebCompiledContentExtension::WebCompiledContentExtension):
(WebKit::WebCompiledContentExtension::~WebCompiledContentExtension):
(WebKit::WebCompiledContentExtension::bytecode):
(WebKit::WebCompiledContentExtension::bytecodeLength):
(WebKit::WebCompiledContentExtension::actions):
(WebKit::WebCompiledContentExtension::actionsLength):
* Shared/WebCompiledContentExtension.h: Added.
Add new WebKit2 implementation of CompiledContentExtension. Right now it is the same as the old
WebCore based CompiledContentExtension, but in subsequent patches, it will use shared/file backed
memory.

* Shared/WebCompiledContentExtensionData.cpp: Added.
(WebKit::WebCompiledContentExtensionData::encode):
(WebKit::WebCompiledContentExtensionData::decode):
* Shared/WebCompiledContentExtensionData.h: Added.
Add encodable/decodable holder for the compiled content extension data for use in IPC. Right
now it is doing the naive thing and always copying the data, but in subsequent patches, it will
use shared/file backed memory.

* Shared/WebPageGroupData.cpp:
(WebKit::WebPageGroupData::encode):
(WebKit::WebPageGroupData::decode):
* Shared/WebPageGroupData.h:
Rename member to match new unification on the name userContentExtension. Change the value from
the serialized JSON (as a String) to WebCompiledContentExtensionData.

* UIProcess/API/APIUserContentExtension.cpp: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.cpp.
(API::UserContentExtension::UserContentExtension):
(API::UserContentExtension::~UserContentExtension):
(API::UserContentFilter::UserContentFilter): Deleted.
(API::UserContentFilter::~UserContentFilter): Deleted.
* UIProcess/API/APIUserContentExtension.h: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.h.
* UIProcess/API/APIUserContentFilter.cpp: Removed.
* UIProcess/API/APIUserContentFilter.h: Removed.
Renamed UserContentFilter to APIUserContentExtension. Updated to store the compiled extension (as a WebCompiledContentExtension)
rather than the serialized JSON.

* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupAddUserContentFilter):
(WKPageGroupRemoveUserContentFilter):
(WKPageGroupRemoveAllUserContentFilters):
* UIProcess/API/C/WKUserContentControllerRef.cpp:
(WKUserContentControllerAddUserContentFilter):
(WKUserContentControllerRemoveAllUserContentFilters):
* UIProcess/API/Cocoa/WKUserContentController.mm:
(-[WKUserContentController _addUserContentFilter:]):
(-[WKUserContentController _removeUserContentFilter:]):
(-[WKUserContentController _removeAllUserContentFilters]):
Update for rename of APIUserContentFilter -> UserContentExtension.

* UIProcess/API/C/WKUserContentFilterRef.cpp:
(WKUserContentFilterGetTypeID):
(WKUserContentFilterCreate):
Update for rename of APIUserContentFilter -> UserContentExtension. Also make WKUserContentFilterCreate eagerly
compile rule list to a WebCompiledContentExtensionData.

* UIProcess/API/Cocoa/_WKUserContentFilter.mm:
(-[_WKUserContentFilter initWithName:serializedRules:]):
(-[_WKUserContentFilter dealloc]):
(-[_WKUserContentFilter _apiObject]):
Update for rename of APIUserContentFilter -> UserContentExtension. Also make initWithName:serializedRules: eagerly
compile rule list to a WebCompiledContentExtensionData.

* UIProcess/API/Cocoa/_WKUserContentFilterInternal.h:
(WebKit::wrapper):
Update for rename of APIUserContentFilter -> UserContentExtension.

* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::addProcess):
(WebKit::WebUserContentControllerProxy::addUserContentExtension):
(WebKit::WebUserContentControllerProxy::removeUserContentExtension):
(WebKit::WebUserContentControllerProxy::removeAllUserContentExtensions):
(WebKit::WebUserContentControllerProxy::addUserContentFilter): Deleted.
(WebKit::WebUserContentControllerProxy::removeUserContentFilter): Deleted.
(WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): Deleted.
* UIProcess/UserContent/WebUserContentControllerProxy.h:
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::addUserContentExtension):
(WebKit::WebPageGroup::removeUserContentExtension):
(WebKit::WebPageGroup::removeAllUserContentExtensions):
(WebKit::WebPageGroup::addUserContentFilter): Deleted.
(WebKit::WebPageGroup::removeUserContentFilter): Deleted.
(WebKit::WebPageGroup::removeAllUserContentFilters): Deleted.
* UIProcess/WebPageGroup.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/UserContent/WebUserContentController.cpp:
(WebKit::WebUserContentController::addUserContentExtensions):
(WebKit::WebUserContentController::removeUserContentExtension):
(WebKit::WebUserContentController::removeAllUserContentExtensions):
(WebKit::WebUserContentController::addUserContentFilters): Deleted.
(WebKit::WebUserContentController::removeUserContentFilter): Deleted.
(WebKit::WebUserContentController::removeAllUserContentFilters): Deleted.
* WebProcess/UserContent/WebUserContentController.h:
* WebProcess/UserContent/WebUserContentController.messages.in:
* WebProcess/WebPage/WebPageGroupProxy.cpp:
(WebKit::WebPageGroupProxy::WebPageGroupProxy):
(WebKit::WebPageGroupProxy::addUserContentExtension):
(WebKit::WebPageGroupProxy::removeUserContentExtension):
(WebKit::WebPageGroupProxy::removeAllUserContentExtensions):
(WebKit::WebPageGroupProxy::addUserContentFilter): Deleted.
(WebKit::WebPageGroupProxy::removeUserContentFilter): Deleted.
(WebKit::WebPageGroupProxy::removeAllUserContentFilters): Deleted.
* WebProcess/WebPage/WebPageGroupProxy.h:
* WebProcess/WebPage/WebPageGroupProxy.messages.in:
Pipe the compiled extension from the UIProcess to the WebProcess.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Copied from Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp.
(TestWebKitAPI::InMemoryCompiledContentExtension::create):
(TestWebKitAPI::InMemoryCompiledContentExtension::~InMemoryCompiledContentExtension):
(TestWebKitAPI::InMemoryCompiledContentExtension::InMemoryCompiledContentExtension):
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/ContentFilter.cpp: Removed.
Update test for new name (ContentFilter -> ContentExtensions) and API (CompiledContentExtension
is now abstract).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181200 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/CompiledContentExtension.cpp
Source/WebCore/contentextensions/CompiledContentExtension.h
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionCompiler.h
Source/WebCore/contentextensions/ContentExtensionRule.cpp
Source/WebCore/contentextensions/ContentExtensionRule.h
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
Source/WebCore/contentextensions/DFABytecodeInterpreter.h
Source/WebCore/page/UserContentController.cpp
Source/WebCore/page/UserContentController.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/APIObject.h
Source/WebKit2/Shared/WebCompiledContentExtension.cpp [new file with mode: 0644]
Source/WebKit2/Shared/WebCompiledContentExtension.h [new file with mode: 0644]
Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp [new file with mode: 0644]
Source/WebKit2/Shared/WebCompiledContentExtensionData.h [new file with mode: 0644]
Source/WebKit2/Shared/WebPageGroupData.cpp
Source/WebKit2/Shared/WebPageGroupData.h
Source/WebKit2/UIProcess/API/APIUserContentExtension.cpp [moved from Source/WebKit2/UIProcess/API/APIUserContentFilter.cpp with 79% similarity]
Source/WebKit2/UIProcess/API/APIUserContentExtension.h [moved from Source/WebKit2/UIProcess/API/APIUserContentFilter.h with 64% similarity]
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp
Source/WebKit2/UIProcess/API/C/WKUserContentControllerRef.cpp
Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.cpp
Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm
Source/WebKit2/UIProcess/API/Cocoa/_WKUserContentFilter.mm
Source/WebKit2/UIProcess/API/Cocoa/_WKUserContentFilterInternal.h
Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp
Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h
Source/WebKit2/UIProcess/WebPageGroup.cpp
Source/WebKit2/UIProcess/WebPageGroup.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/UserContent/WebUserContentController.cpp
Source/WebKit2/WebProcess/UserContent/WebUserContentController.h
Source/WebKit2/WebProcess/UserContent/WebUserContentController.messages.in
Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp
Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h
Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp [moved from Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp with 70% similarity]