[Content Extensions] Split parsing and compiling of content extensions into their...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2015 16:41:31 +0000 (16:41 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2015 16:41:31 +0000 (16:41 +0000)
commita510784005807a53037d0df29a420d3d610d6930
tree11fa2797b1b406794ab906a5cac24e64c94c1437
parentd808b5fad2b3b6e3044a3d77f7a080e03115838b
[Content Extensions] Split parsing and compiling of content extensions into their own files
https://bugs.webkit.org/show_bug.cgi?id=142259

Reviewed by Anders Carlsson.

Source/WebCore:

Added new unit test:
    ContentFilterTest.Basic

* WebCore.xcodeproj/project.pbxproj:
Add new files (CompiledContentExtension.h/cpp, ContentExtensionCompiler.h/cpp, and ContentExtensionParser.h/cpp)

* contentextensions/CompiledContentExtension.cpp: Added.
* contentextensions/CompiledContentExtension.h: Added.
Add new class for holding onto the compiled content extension itself. Make it ThreadSafeRefCounted so it is easy
to move between threads which will be important in a subsequent patch where we enable compilation on a background
thread.

* contentextensions/ContentExtensionCompiler.cpp: Added.
(WebCore::ContentExtensions::serializeActions):
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionCompiler.h: Added.
Moving compilation to its own file. Was previously in ContentExtensionsBackend. This is necessary because
we will want to be able to compile without the need of a backend.

* contentextensions/ContentExtensionParser.cpp: Copied from contentextensions/ContentExtensionsManager.cpp.
* contentextensions/ContentExtensionParser.h: Copied from contentextensions/ContentExtensionsManager.h.
Renamed ContentExtensionsManager to ContentExtensionParser, since that is all it is doing.

* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::addContentExtension):
(WebCore::ContentExtensions::ContentExtensionsBackend::removeContentExtension):
(WebCore::ContentExtensions::ContentExtensionsBackend::removeAllContentExtensions):
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForURL):
(WebCore::ContentExtensions::ContentExtensionsBackend::serializeActions): Deleted.
(WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): Deleted.
(WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): Deleted.
(WebCore::ContentExtensions::ContentExtensionsBackend::removeAllRuleLists): Deleted.
* contentextensions/ContentExtensionsBackend.h:
Change the backend to use the new CompiledContentExtension and change the terminology to
reference content extensions, rather than rule lists.

* page/UserContentController.cpp:
(WebCore::UserContentController::addUserContentFilter):
(WebCore::UserContentController::removeUserContentFilter):
(WebCore::UserContentController::removeAllUserContentFilters):
Update for new names and change addUserContentFilter to explicitly compile the JSON
rule list before handing it to the backend. In subsequent changes, addUserContentFilter
should be changed to take the compiled content extension, and it should become the responsibility
of the called (WebKit) to create them.

Tools:

Add basic unit test for the content filter compiler.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/ContentFilter.cpp: Added.
(WebCore::ContentExtensions::operator<<):
(TestWebKitAPI::ContentFilterTest::SetUp):
(TestWebKitAPI::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181000 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/contentextensions/CompiledContentExtension.cpp [new file with mode: 0644]
Source/WebCore/contentextensions/CompiledContentExtension.h [new file with mode: 0644]
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp [new file with mode: 0644]
Source/WebCore/contentextensions/ContentExtensionCompiler.h [new file with mode: 0644]
Source/WebCore/contentextensions/ContentExtensionParser.cpp [moved from Source/WebCore/contentextensions/ContentExtensionsManager.cpp with 97% similarity]
Source/WebCore/contentextensions/ContentExtensionParser.h [moved from Source/WebCore/contentextensions/ContentExtensionsManager.h with 83% similarity]
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/contentextensions/ContentExtensionsBackend.h
Source/WebCore/page/UserContentController.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp [new file with mode: 0644]