Split some logic out of VisitedLinkStore and make it reusable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Sep 2017 21:14:09 +0000 (21:14 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Sep 2017 21:14:09 +0000 (21:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177575

Reviewed by Alex Christensen.

Source/WebCore:

Rename LinkHash to SharedStringHash to make it more reusable.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.cpp:
* dom/VisitedLinkState.cpp:
(WebCore::linkHashForElement):
(WebCore::VisitedLinkState::invalidateStyleForLink):
(WebCore::VisitedLinkState::determineLinkStateSlowCase):
* dom/VisitedLinkState.h:
* html/HTMLAnchorElement.h:
(WebCore::HTMLAnchorElement::visitedLinkHash const):
* loader/EmptyClients.cpp:
* loader/HistoryController.cpp:
(WebCore::addVisitedLink):
* page/Page.cpp:
(WebCore::Page::invalidateStylesForLink):
* page/Page.h:
* page/VisitedLinkStore.cpp:
(WebCore::VisitedLinkStore::invalidateStylesForLink):
* page/VisitedLinkStore.h:
* platform/SharedStringHash.cpp: Renamed from Source/WebCore/platform/LinkHash.cpp.
(WebCore::needsTrailingSlash):
(WebCore::computeSharedStringHashInline):
(WebCore::computeSharedStringHash):
* platform/SharedStringHash.h: Renamed from Source/WebCore/platform/LinkHash.h.
(WebCore::SharedStringHashHash::hash):
(WebCore::SharedStringHashHash::equal):
(WebCore::SharedStringHashHash::avoidDeletedValue):

Source/WebKit:

Split some logic out of VisitedLinkStore and make it reusable for other purposes than
visited links and from other processes than the UIProcess.

The plan is to reuse the new SharedStringHashStore for Service Worker registration
on StorageProcess side and querying on WebContent process side.

* CMakeLists.txt:
* Shared/SharedStringHashStore.cpp: Added.
(WebKit::nextPowerOf2):
(WebKit::tableSizeForKeyCount):
(WebKit::SharedStringHashStore::SharedStringHashStore):
(WebKit::SharedStringHashStore::createSharedMemoryHandle):
(WebKit::SharedStringHashStore::add):
(WebKit::SharedStringHashStore::clear):
(WebKit::SharedStringHashStore::resizeTable):
(WebKit::SharedStringHashStore::pendingSharedStringHashesTimerFired):
* Shared/SharedStringHashStore.h: Copied from Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.h.
(WebKit::SharedStringHashStore::Client::~Client):
(WebKit::SharedStringHashStore::isEmpty const):
* Shared/SharedStringHashTable.cpp: Renamed from Source/WebKit/Shared/VisitedLinkTable.cpp.
(WebKit::SharedStringHashTable::SharedStringHashTable):
(WebKit::SharedStringHashTable::~SharedStringHashTable):
(WebKit::SharedStringHashTable::setSharedMemory):
(WebKit::SharedStringHashTable::add):
(WebKit::SharedStringHashTable::contains const):
(WebKit::SharedStringHashTable::clear):
* Shared/SharedStringHashTable.h: Renamed from Source/WebKit/Shared/VisitedLinkTable.h.
* UIProcess/API/C/WKContext.cpp:
(WKContextAddVisitedLink):
* UIProcess/API/Cocoa/_WKVisitedLinkStore.mm:
(-[_WKVisitedLinkStore addVisitedLinkWithURL:]):
* UIProcess/VisitedLinkStore.cpp:
(WebKit::VisitedLinkStore::VisitedLinkStore):
(WebKit::VisitedLinkStore::addProcess):
(WebKit::VisitedLinkStore::addVisitedLinkHash):
(WebKit::VisitedLinkStore::removeAll):
(WebKit::VisitedLinkStore::addVisitedLinkHashFromPage):
(WebKit::VisitedLinkStore::sendStoreHandleToProcess):
(WebKit::VisitedLinkStore::didInvalidateSharedMemory):
(WebKit::VisitedLinkStore::didAddSharedStringHashes):
* UIProcess/VisitedLinkStore.h:
* UIProcess/WebProcessPool.cpp:
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/VisitedLinkTableController.cpp:
(WebKit::VisitedLinkTableController::isLinkVisited):
(WebKit::VisitedLinkTableController::addVisitedLink):
(WebKit::VisitedLinkTableController::visitedLinkStateChanged):
* WebProcess/WebPage/VisitedLinkTableController.h:
* WebProcess/WebPage/VisitedLinkTableController.messages.in:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebVisitedLinkStore.h:
* WebCoreSupport/WebVisitedLinkStore.mm:
(WebVisitedLinkStore::addVisitedLink):
(WebVisitedLinkStore::removeVisitedLink):
(WebVisitedLinkStore::isLinkVisited):
(WebVisitedLinkStore::addVisitedLinkHash):

Source/WebKitLegacy/win:

* WebCoreSupport/WebVisitedLinkStore.cpp:
(WebVisitedLinkStore::addVisitedLink):
(WebVisitedLinkStore::isLinkVisited):
(WebVisitedLinkStore::addVisitedLinkHash):
* WebCoreSupport/WebVisitedLinkStore.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222664 268f45cc-cd09-0410-ab3c-d52691b4dbfc

38 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/VisitedLinkState.cpp
Source/WebCore/dom/VisitedLinkState.h
Source/WebCore/html/HTMLAnchorElement.h
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/VisitedLinkStore.cpp
Source/WebCore/page/VisitedLinkStore.h
Source/WebCore/platform/SharedStringHash.cpp [moved from Source/WebCore/platform/LinkHash.cpp with 83% similarity]
Source/WebCore/platform/SharedStringHash.h [moved from Source/WebCore/platform/LinkHash.h with 75% similarity]
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/Shared/SharedStringHashStore.cpp [new file with mode: 0644]
Source/WebKit/Shared/SharedStringHashStore.h [new file with mode: 0644]
Source/WebKit/Shared/SharedStringHashTable.cpp [moved from Source/WebKit/Shared/VisitedLinkTable.cpp with 74% similarity]
Source/WebKit/Shared/SharedStringHashTable.h [moved from Source/WebKit/Shared/VisitedLinkTable.h with 76% similarity]
Source/WebKit/UIProcess/API/C/WKContext.cpp
Source/WebKit/UIProcess/API/Cocoa/_WKVisitedLinkStore.mm
Source/WebKit/UIProcess/VisitedLinkStore.cpp
Source/WebKit/UIProcess/VisitedLinkStore.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.cpp
Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.h
Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebVisitedLinkStore.h
Source/WebKitLegacy/mac/WebCoreSupport/WebVisitedLinkStore.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebVisitedLinkStore.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebVisitedLinkStore.h

index 35a58f6..8886e14 100644 (file)
@@ -2324,7 +2324,6 @@ set(WebCore_SOURCES
     platform/LengthBox.cpp
     platform/LengthPoint.cpp
     platform/LengthSize.cpp
-    platform/LinkHash.cpp
     platform/LocalizedStrings.cpp
     platform/Logging.cpp
     platform/LowPowerModeNotifier.cpp
@@ -2348,6 +2347,7 @@ set(WebCore_SOURCES
     platform/ScrollbarThemeComposite.cpp
     platform/SharedBuffer.cpp
     platform/SharedBufferChunkReader.cpp
+    platform/SharedStringHash.cpp
     platform/StaticPasteboard.cpp
     platform/Theme.cpp
     platform/ThreadGlobalData.cpp
index 93bf701..788f6b7 100644 (file)
@@ -1,3 +1,40 @@
+2017-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Split some logic out of VisitedLinkStore and make it reusable
+        https://bugs.webkit.org/show_bug.cgi?id=177575
+
+        Reviewed by Alex Christensen.
+
+        Rename LinkHash to SharedStringHash to make it more reusable.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/StyleResolver.cpp:
+        * dom/VisitedLinkState.cpp:
+        (WebCore::linkHashForElement):
+        (WebCore::VisitedLinkState::invalidateStyleForLink):
+        (WebCore::VisitedLinkState::determineLinkStateSlowCase):
+        * dom/VisitedLinkState.h:
+        * html/HTMLAnchorElement.h:
+        (WebCore::HTMLAnchorElement::visitedLinkHash const):
+        * loader/EmptyClients.cpp:
+        * loader/HistoryController.cpp:
+        (WebCore::addVisitedLink):
+        * page/Page.cpp:
+        (WebCore::Page::invalidateStylesForLink):
+        * page/Page.h:
+        * page/VisitedLinkStore.cpp:
+        (WebCore::VisitedLinkStore::invalidateStylesForLink):
+        * page/VisitedLinkStore.h:
+        * platform/SharedStringHash.cpp: Renamed from Source/WebCore/platform/LinkHash.cpp.
+        (WebCore::needsTrailingSlash):
+        (WebCore::computeSharedStringHashInline):
+        (WebCore::computeSharedStringHash):
+        * platform/SharedStringHash.h: Renamed from Source/WebCore/platform/LinkHash.h.
+        (WebCore::SharedStringHashHash::hash):
+        (WebCore::SharedStringHashHash::equal):
+        (WebCore::SharedStringHashHash::avoidDeletedValue):
+
 2017-09-29  Don Olmstead  <don.olmstead@sony.com>
 
         [WinCairo] Fix build after rev 222610
index b34e13b..803a725 100644 (file)
                8348BFAB1B85729800912F36 /* ClassCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8348BFA91B85729500912F36 /* ClassCollection.cpp */; };
                8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8348BFAA1B85729500912F36 /* ClassCollection.h */; };
                834DD4F41BE08989002C9C3E /* PageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 834DD4F31BE08989002C9C3E /* PageMac.mm */; };
+               834DFACF1F7DAE5D00C2725B /* SharedStringHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834DFACE1F7DAE5700C2725B /* SharedStringHash.cpp */; };
+               834DFAD01F7DAE5D00C2725B /* SharedStringHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 834DFACC1F7DAE5600C2725B /* SharedStringHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */; };
                835657C71ECAB10700CDE72D /* JSDOMMatrixInit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835657C61ECAB0E800CDE72D /* JSDOMMatrixInit.cpp */; };
                8358CB6F1C53277200E0C2D8 /* JSXMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */; };
                A79BADA3161E7F3F00C2E652 /* RuleSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A79BAD9F161E7F3F00C2E652 /* RuleSet.cpp */; };
                A79BADA4161E7F3F00C2E652 /* RuleSet.h in Headers */ = {isa = PBXBuildFile; fileRef = A79BADA0161E7F3F00C2E652 /* RuleSet.h */; };
                A7A78CD51532BA62006C21E4 /* ContainerNodeAlgorithms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A78CD41532BA62006C21E4 /* ContainerNodeAlgorithms.cpp */; };
-               A7AD2F870EC89D07008AB002 /* LinkHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7AD2F850EC89D07008AB002 /* LinkHash.cpp */; };
-               A7AD2F880EC89D07008AB002 /* LinkHash.h in Headers */ = {isa = PBXBuildFile; fileRef = A7AD2F860EC89D07008AB002 /* LinkHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A7B6E69F0B291A9600D0529F /* DragData.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B6E69D0B291A9600D0529F /* DragData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A7BBE26611AFB3F20005EA03 /* JSHTMLMeterElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BBE26411AFB3F20005EA03 /* JSHTMLMeterElement.cpp */; };
                A7BBE26711AFB3F20005EA03 /* JSHTMLMeterElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BBE26511AFB3F20005EA03 /* JSHTMLMeterElement.h */; };
                834B86A81C56E93E00F3F0E3 /* JSHTMLDataElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLDataElement.h; sourceTree = "<group>"; };
                834B86A91C56E93E00F3F0E3 /* JSHTMLDataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDataElement.cpp; sourceTree = "<group>"; };
                834DD4F31BE08989002C9C3E /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = "<group>"; };
+               834DFACC1F7DAE5600C2725B /* SharedStringHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedStringHash.h; sourceTree = "<group>"; };
+               834DFACE1F7DAE5700C2725B /* SharedStringHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedStringHash.cpp; sourceTree = "<group>"; };
                8350C3E71DA59B6200356446 /* ScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollToOptions.h; sourceTree = "<group>"; };
                8350C3E81DA59B6200356446 /* ScrollToOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollToOptions.idl; sourceTree = "<group>"; };
                83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = "<group>"; };
                A79BAD9F161E7F3F00C2E652 /* RuleSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleSet.cpp; sourceTree = "<group>"; };
                A79BADA0161E7F3F00C2E652 /* RuleSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleSet.h; sourceTree = "<group>"; };
                A7A78CD41532BA62006C21E4 /* ContainerNodeAlgorithms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContainerNodeAlgorithms.cpp; sourceTree = "<group>"; };
-               A7AD2F850EC89D07008AB002 /* LinkHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinkHash.cpp; sourceTree = "<group>"; };
-               A7AD2F860EC89D07008AB002 /* LinkHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkHash.h; sourceTree = "<group>"; };
                A7B4EA6814C9348400C8F5BF /* JSMallocStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMallocStatistics.cpp; sourceTree = "<group>"; };
                A7B4EA6914C9348400C8F5BF /* JSMallocStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMallocStatistics.h; sourceTree = "<group>"; };
                A7B4EA7814C9348400C8F5BF /* JSInternalSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInternalSettings.cpp; sourceTree = "<group>"; };
                                0F87166E1C869D83004FF0DE /* LengthPoint.h */,
                                0FEF20CD1BD4A24100128E5D /* LengthSize.cpp */,
                                BCFF64900EAD15C200C1D6F7 /* LengthSize.h */,
-                               A7AD2F850EC89D07008AB002 /* LinkHash.cpp */,
-                               A7AD2F860EC89D07008AB002 /* LinkHash.h */,
                                5143B2621DDD14900014FAC6 /* LinkIcon.h */,
                                C046E1AB1208A9FE00BA2CF7 /* LocalizedStrings.cpp */,
                                935207BD09BD410A00F2038D /* LocalizedStrings.h */,
                                077AF13E18F4AE400001ED61 /* SerializedPlatformRepresentation.h */,
                                1A4A954B0B4EDCCB002D8C3C /* SharedBuffer.cpp */,
                                1A4A954C0B4EDCCB002D8C3C /* SharedBuffer.h */,
+                               834DFACE1F7DAE5700C2725B /* SharedStringHash.cpp */,
+                               834DFACC1F7DAE5600C2725B /* SharedStringHash.h */,
                                93309EA0099EB78C0056E581 /* SharedTimer.h */,
                                F587866202DE3B1101EA4122 /* SSLKeyGenerator.h */,
                                F433E9041DBBDBC200EF0D14 /* StaticPasteboard.cpp */,
                                89B5EAA211E8003D00F2367E /* LineEnding.h in Headers */,
                                FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */,
                                FFDBC047183D27B700407109 /* LineWidth.h in Headers */,
-                               A7AD2F880EC89D07008AB002 /* LinkHash.h in Headers */,
                                CBA9DC0B1DF44DF40005675C /* LinkHeader.h in Headers */,
                                5143B2631DDD15200014FAC6 /* LinkIcon.h in Headers */,
                                1A4DA4221CDD3A8300F4473C /* LinkIconCollector.h in Headers */,
                                FD45A952175D3F3E00C21EC8 /* ShapeOutsideInfo.h in Headers */,
                                FD1AF1501656F15100C6D4F7 /* ShapeValue.h in Headers */,
                                1A4A954E0B4EDCCB002D8C3C /* SharedBuffer.h in Headers */,
+                               834DFAD01F7DAE5D00C2725B /* SharedStringHash.h in Headers */,
                                93309EA3099EB78C0056E581 /* SharedTimer.h in Headers */,
                                E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */,
                                11E067EE1E6246E500162D16 /* SimpleLineLayoutCoverage.h in Headers */,
                                89B5EAA111E8003D00F2367E /* LineEnding.cpp in Sources */,
                                FFB698CF183402BB00158A31 /* LineInfo.cpp in Sources */,
                                FFDBC048183D27B700407109 /* LineWidth.cpp in Sources */,
-                               A7AD2F870EC89D07008AB002 /* LinkHash.cpp in Sources */,
                                CBA9DC0A1DF44DF10005675C /* LinkHeader.cpp in Sources */,
                                1A4DA4211CDD3A8300F4473C /* LinkIconCollector.cpp in Sources */,
                                98CE4326129E00BD005821DC /* LinkLoader.cpp in Sources */,
                                1A4A954D0B4EDCCB002D8C3C /* SharedBuffer.cpp in Sources */,
                                512DD8E30D91E2B4000F89EE /* SharedBufferCF.cpp in Sources */,
                                1A4A95520B4EDCFF002D8C3C /* SharedBufferCocoa.mm in Sources */,
+                               834DFACF1F7DAE5D00C2725B /* SharedStringHash.cpp in Sources */,
                                163E88F7118A39D200ED9231 /* SimpleFontDataCoreText.cpp in Sources */,
                                E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */,
                                11E067EC1E62461300162D16 /* SimpleLineLayoutCoverage.cpp in Sources */,
index 3500a01..1963622 100644 (file)
@@ -66,7 +66,6 @@
 #include "HTMLTextAreaElement.h"
 #include "InspectorInstrumentation.h"
 #include "KeyframeList.h"
-#include "LinkHash.h"
 #include "Logging.h"
 #include "MathMLElement.h"
 #include "MathMLNames.h"
@@ -89,6 +88,7 @@
 #include "SVGURIReference.h"
 #include "Settings.h"
 #include "ShadowRoot.h"
+#include "SharedStringHash.h"
 #include "StyleBuilder.h"
 #include "StyleColor.h"
 #include "StyleCachedImage.h"
index 5920bda..c3993d6 100644 (file)
@@ -66,16 +66,16 @@ void VisitedLinkState::invalidateStyleForAllLinks()
     }
 }
 
-inline static LinkHash linkHashForElement(Document& document, const Element& element)
+inline static SharedStringHash linkHashForElement(Document& document, const Element& element)
 {
     if (is<HTMLAnchorElement>(element))
         return downcast<HTMLAnchorElement>(element).visitedLinkHash();
     if (const AtomicString* attribute = linkAttribute(element))
-        return WebCore::visitedLinkHash(document.baseURL(), *attribute);
+        return WebCore::computeSharedStringHash(document.baseURL(), *attribute);
     return 0;
 }
 
-void VisitedLinkState::invalidateStyleForLink(LinkHash linkHash)
+void VisitedLinkState::invalidateStyleForLink(SharedStringHash linkHash)
 {
     if (!m_linksCheckedForVisitedState.contains(linkHash))
         return;
@@ -98,11 +98,11 @@ EInsideLink VisitedLinkState::determineLinkStateSlowCase(const Element& element)
     if (attribute->isEmpty())
         return InsideVisitedLink;
 
-    LinkHash hash;
+    SharedStringHash hash;
     if (is<HTMLAnchorElement>(element))
         hash = downcast<HTMLAnchorElement>(element).visitedLinkHash();
     else
-        hash = WebCore::visitedLinkHash(element.document().baseURL(), *attribute);
+        hash = WebCore::computeSharedStringHash(element.document().baseURL(), *attribute);
 
     if (!hash)
         return InsideUnvisitedLink;
index 2a142ad..cc9e5ec 100644 (file)
@@ -29,8 +29,8 @@
 #pragma once
 
 #include "Element.h"
-#include "LinkHash.h"
 #include "RenderStyleConstants.h"
+#include "SharedStringHash.h"
 #include <wtf/HashSet.h>
 
 namespace WebCore {
@@ -43,14 +43,14 @@ public:
     explicit VisitedLinkState(Document&);
 
     void invalidateStyleForAllLinks();
-    void invalidateStyleForLink(LinkHash);
+    void invalidateStyleForLink(SharedStringHash);
     EInsideLink determineLinkState(const Element&);
 
 private:
     EInsideLink determineLinkStateSlowCase(const Element&);
 
     Document& m_document;
-    HashSet<LinkHash, LinkHashHash> m_linksCheckedForVisitedState;
+    HashSet<SharedStringHash, SharedStringHashHash> m_linksCheckedForVisitedState;
 };
 
 inline EInsideLink VisitedLinkState::determineLinkState(const Element& element)
index a7bc609..e4e4a3d 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "HTMLElement.h"
 #include "HTMLNames.h"
-#include "LinkHash.h"
+#include "SharedStringHash.h"
 #include "URLUtils.h"
 #include <wtf/OptionSet.h>
 
@@ -62,7 +62,7 @@ public:
 
     bool hasRel(Relation) const;
     
-    LinkHash visitedLinkHash() const;
+    SharedStringHash visitedLinkHash() const;
     void invalidateCachedVisitedLinkHash() { m_cachedVisitedLinkHash = 0; }
 
     WEBCORE_EXPORT DOMTokenList& relList();
@@ -104,15 +104,15 @@ private:
     bool m_hasRootEditableElementForSelectionOnMouseDown;
     bool m_wasShiftKeyDownOnMouseDown;
     OptionSet<Relation> m_linkRelations;
-    mutable LinkHash m_cachedVisitedLinkHash;
+    mutable SharedStringHash m_cachedVisitedLinkHash;
 
     std::unique_ptr<DOMTokenList> m_relList;
 };
 
-inline LinkHash HTMLAnchorElement::visitedLinkHash() const
+inline SharedStringHash HTMLAnchorElement::visitedLinkHash() const
 {
     if (!m_cachedVisitedLinkHash)
-        m_cachedVisitedLinkHash = WebCore::visitedLinkHash(document().baseURL(), attributeWithoutSynchronization(HTMLNames::hrefAttr));
+        m_cachedVisitedLinkHash = WebCore::computeSharedStringHash(document().baseURL(), attributeWithoutSynchronization(HTMLNames::hrefAttr));
     return m_cachedVisitedLinkHash; 
 }
 
index 1b9989c..1318330 100644 (file)
@@ -567,8 +567,8 @@ class EmptyUserContentProvider final : public UserContentProvider {
 };
 
 class EmptyVisitedLinkStore final : public VisitedLinkStore {
-    bool isLinkVisited(Page&, LinkHash, const URL&, const AtomicString&) final { return false; }
-    void addVisitedLink(Page&, LinkHash) final { }
+    bool isLinkVisited(Page&, SharedStringHash, const URL&, const AtomicString&) final { return false; }
+    void addVisitedLink(Page&, SharedStringHash) final { }
 };
 
 RefPtr<PopupMenu> EmptyChromeClient::createPopupMenu(PopupMenuClient&) const
index 03c653b..2bac8a8 100644 (file)
 #include "FrameTree.h"
 #include "FrameView.h"
 #include "HistoryItem.h"
-#include "LinkHash.h"
 #include "Logging.h"
 #include "MainFrame.h"
 #include "Page.h"
 #include "PageCache.h"
 #include "ScrollingCoordinator.h"
 #include "SerializedScriptValue.h"
+#include "SharedStringHash.h"
 #include "VisitedLinkStore.h"
 #include <wtf/text/CString.h>
 
@@ -55,7 +55,7 @@ namespace WebCore {
 
 static inline void addVisitedLink(Page& page, const URL& url)
 {
-    page.visitedLinkStore().addVisitedLink(page, visitedLinkHash(url.string()));
+    page.visitedLinkStore().addVisitedLink(page, computeSharedStringHash(url.string()));
 }
 
 HistoryController::HistoryController(Frame& frame)
index 9182bc9..dbe2851 100644 (file)
@@ -1201,7 +1201,7 @@ void Page::invalidateStylesForAllLinks()
     }
 }
 
-void Page::invalidateStylesForLink(LinkHash linkHash)
+void Page::invalidateStylesForLink(SharedStringHash linkHash)
 {
     for (Frame* frame = &m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) {
         if (!frame->document())
index 24f50db..023a2b0 100644 (file)
@@ -131,7 +131,7 @@ class ActivityStateChangeObserver;
 class VisitedLinkStore;
 class WebGLStateTracker;
 
-typedef uint64_t LinkHash;
+typedef uint64_t SharedStringHash;
 
 enum FindDirection {
     FindDirectionForward,
@@ -398,7 +398,7 @@ public:
     JSC::Debugger* debugger() const { return m_debugger; }
 
     WEBCORE_EXPORT void invalidateStylesForAllLinks();
-    WEBCORE_EXPORT void invalidateStylesForLink(LinkHash);
+    WEBCORE_EXPORT void invalidateStylesForLink(SharedStringHash);
 
     void invalidateInjectedStyleSheetCacheInAllFrames();
 
index 973b78e..d7a58b5 100644 (file)
@@ -59,7 +59,7 @@ void VisitedLinkStore::invalidateStylesForAllLinks()
         page->invalidateStylesForAllLinks();
 }
 
-void VisitedLinkStore::invalidateStylesForLink(LinkHash linkHash)
+void VisitedLinkStore::invalidateStylesForLink(SharedStringHash linkHash)
 {
     for (auto& page : m_pages)
         page->invalidateStylesForLink(linkHash);
index 441306a..43c3513 100644 (file)
@@ -31,7 +31,7 @@
 
 namespace WebCore {
 
-typedef uint64_t LinkHash;
+typedef uint64_t SharedStringHash;
 class Page;
 class URL;
 
@@ -41,14 +41,14 @@ public:
     WEBCORE_EXPORT virtual ~VisitedLinkStore();
 
     // FIXME: These two members should only take the link hash.
-    virtual bool isLinkVisited(Page&, LinkHash, const URL& baseURL, const AtomicString& attributeURL) = 0;
-    virtual void addVisitedLink(Page&, LinkHash) = 0;
+    virtual bool isLinkVisited(Page&, SharedStringHash, const URL& baseURL, const AtomicString& attributeURL) = 0;
+    virtual void addVisitedLink(Page&, SharedStringHash) = 0;
 
     void addPage(Page&);
     void removePage(Page&);
 
     WEBCORE_EXPORT void invalidateStylesForAllLinks();
-    WEBCORE_EXPORT void invalidateStylesForLink(LinkHash);
+    WEBCORE_EXPORT void invalidateStylesForLink(SharedStringHash);
 
 private:
     HashSet<Page*> m_pages;
similarity index 83%
rename from Source/WebCore/platform/LinkHash.cpp
rename to Source/WebCore/platform/SharedStringHash.cpp
index c833e4b..9190c0d 100644 (file)
@@ -22,8 +22,9 @@
  */
 
 #include "config.h"
+#include "SharedStringHash.h"
+
 #include "URL.h"
-#include "LinkHash.h"
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/StringView.h>
@@ -183,13 +184,9 @@ static inline bool needsTrailingSlash(const CharacterType* characters, unsigned
 {
     if (length < 6)
         return false;
-    if (!matchLetter(characters[0], 'h')
-            || !matchLetter(characters[1], 't')
-            || !matchLetter(characters[2], 't')
-            || !matchLetter(characters[3], 'p'))
+    if (!matchLetter(characters[0], 'h') || !matchLetter(characters[1], 't') || !matchLetter(characters[2], 't') || !matchLetter(characters[3], 'p'))
         return false;
-    if (!(characters[4] == ':'
-            || (matchLetter(characters[4], 's') && characters[5] == ':')))
+    if (!(characters[4] == ':' || (matchLetter(characters[4], 's') && characters[5] == ':')))
         return false;
 
     unsigned pos = characters[4] == ':' ? 5 : 6;
@@ -206,26 +203,26 @@ static inline bool needsTrailingSlash(const CharacterType* characters, unsigned
 }
 
 template <typename CharacterType>
-static ALWAYS_INLINE LinkHash visitedLinkHashInline(const CharacterType* url, unsigned length)
+static ALWAYS_INLINE SharedStringHash computeSharedStringHashInline(const CharacterType* url, unsigned length)
 {
     return AlreadyHashed::avoidDeletedValue(StringHasher::computeHash(url, length));
 }
 
-LinkHash visitedLinkHash(const String& url)
+SharedStringHash computeSharedStringHash(const String& url)
 {
     unsigned length = url.length();
     if (!length || url.is8Bit())
-        return visitedLinkHashInline(url.characters8(), length);
-    return visitedLinkHashInline(url.characters16(), length);
+        return computeSharedStringHashInline(url.characters8(), length);
+    return computeSharedStringHashInline(url.characters16(), length);
 }
 
-LinkHash visitedLinkHash(const UChar* url, unsigned length)
+SharedStringHash computeSharedStringHash(const UChar* url, unsigned length)
 {
-    return visitedLinkHashInline(url, length);
+    return computeSharedStringHashInline(url, length);
 }
 
 template <typename CharacterType>
-static ALWAYS_INLINE void visitedURLInline(const URL& base, const CharacterType* characters, unsigned length, Vector<CharacterType, 512>& buffer)
+static ALWAYS_INLINE void computeSharedStringHashInline(const URL& base, const CharacterType* characters, unsigned length, Vector<CharacterType, 512>& buffer)
 {
     if (!length)
         return;
@@ -261,15 +258,15 @@ static ALWAYS_INLINE void visitedURLInline(const URL& base, const CharacterType*
         append(buffer, base.string());
     else {
         switch (characters[0]) {
-            case '/':
-                append(buffer, StringView(base.string()).substring(0, base.pathStart()));
-                break;
-            case '#':
-                append(buffer, StringView(base.string()).substring(0, base.pathEnd()));
-                break;
-            default:
-                append(buffer, StringView(base.string()).substring(0, base.pathAfterLastSlash()));
-                break;
+        case '/':
+            append(buffer, StringView(base.string()).substring(0, base.pathStart()));
+            break;
+        case '#':
+            append(buffer, StringView(base.string()).substring(0, base.pathEnd()));
+            break;
+        default:
+            append(buffer, StringView(base.string()).substring(0, base.pathAfterLastSlash()));
+            break;
         }
     }
     buffer.append(characters, length);
@@ -283,28 +280,28 @@ static ALWAYS_INLINE void visitedURLInline(const URL& base, const CharacterType*
     return;
 }
 
-LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL)
+SharedStringHash computeSharedStringHash(const URL& base, const AtomicString& attributeURL)
 {
     if (attributeURL.isEmpty())
         return 0;
 
     if (!base.string().isEmpty() && base.string().is8Bit() && attributeURL.is8Bit()) {
         Vector<LChar, 512> url;
-        visitedURLInline(base, attributeURL.characters8(), attributeURL.length(), url);
+        computeSharedStringHashInline(base, attributeURL.characters8(), attributeURL.length(), url);
         if (url.isEmpty())
             return 0;
 
-        return visitedLinkHashInline(url.data(), url.size());
+        return computeSharedStringHashInline(url.data(), url.size());
     }
 
     Vector<UChar, 512> url;
     auto upconvertedCharacters = StringView(attributeURL.string()).upconvertedCharacters();
     const UChar* characters = upconvertedCharacters;
-    visitedURLInline(base, characters, attributeURL.length(), url);
+    computeSharedStringHashInline(base, characters, attributeURL.length(), url);
     if (url.isEmpty())
         return 0;
 
-    return visitedLinkHashInline(url.data(), url.size());
+    return computeSharedStringHashInline(url.data(), url.size());
 }
 
-}  // namespace WebCore
+} // namespace WebCore
similarity index 75%
rename from Source/WebCore/platform/LinkHash.h
rename to Source/WebCore/platform/SharedStringHash.h
index 165995f..3a033c3 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef LinkHash_h
-#define LinkHash_h
+#pragma once
 
 #include <wtf/Forward.h>
 #include <wtf/text/StringHash.h>
@@ -33,16 +32,16 @@ namespace WebCore {
 
 class URL;
 
-typedef uint64_t LinkHash;
+typedef uint64_t SharedStringHash;
 
-// Use the low 32-bits of the 64-bit LinkHash as the key for HashSets.
-struct LinkHashHash {
-    static unsigned hash(LinkHash key) { return static_cast<unsigned>(key); }
-    static bool equal(LinkHash a, LinkHash b) { return a == b; }
+// Use the low 32-bits of the 64-bit SharedStringHash as the key for HashSets.
+struct SharedStringHashHash {
+    static unsigned hash(SharedStringHash key) { return static_cast<unsigned>(key); }
+    static bool equal(SharedStringHash a, SharedStringHash b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 
     // See AlreadyHashed::avoidDeletedValue.
-    static unsigned avoidDeletedValue(LinkHash hash64)
+    static unsigned avoidDeletedValue(SharedStringHash hash64)
     {
         ASSERT(hash64);
         unsigned hash = static_cast<unsigned>(hash64);
@@ -54,15 +53,13 @@ struct LinkHashHash {
 };
 
 // Returns the hash of the string that will be used for visited link coloring.
-WEBCORE_EXPORT LinkHash visitedLinkHash(const String& url);
-WEBCORE_EXPORT LinkHash visitedLinkHash(const UChar* url, unsigned length);
+WEBCORE_EXPORT SharedStringHash computeSharedStringHash(const String& url);
+WEBCORE_EXPORT SharedStringHash computeSharedStringHash(const UChar* url, unsigned length);
 
 // Resolves the potentially relative URL "attributeURL" relative to the given
 // base URL, and returns the hash of the string that will be used for visited
 // link coloring. It will return the special value of 0 if attributeURL does not
 // look like a relative URL.
-LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL);
+SharedStringHash computeSharedStringHash(const URL& base, const AtomicString& attributeURL);
 
-}  // namespace WebCore
-
-#endif  // LinkHash_h
+} // namespace WebCore
index d9e0a4b..6131aa7 100644 (file)
@@ -180,10 +180,11 @@ set(WebKit_SOURCES
     Shared/SessionTracker.cpp
     Shared/ShareableBitmap.cpp
     Shared/ShareableResource.cpp
+    Shared/SharedStringHashStore.cpp
+    Shared/SharedStringHashTable.cpp
     Shared/StatisticsData.cpp
     Shared/UpdateInfo.cpp
     Shared/UserData.cpp
-    Shared/VisitedLinkTable.cpp
     Shared/WebBackForwardListItem.cpp
     Shared/WebCompiledContentRuleList.cpp
     Shared/WebCompiledContentRuleListData.cpp
index 4962a9b..9aee86d 100644 (file)
@@ -1,3 +1,62 @@
+2017-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Split some logic out of VisitedLinkStore and make it reusable
+        https://bugs.webkit.org/show_bug.cgi?id=177575
+
+        Reviewed by Alex Christensen.
+
+        Split some logic out of VisitedLinkStore and make it reusable for other purposes than
+        visited links and from other processes than the UIProcess.
+
+        The plan is to reuse the new SharedStringHashStore for Service Worker registration
+        on StorageProcess side and querying on WebContent process side.
+
+        * CMakeLists.txt:
+        * Shared/SharedStringHashStore.cpp: Added.
+        (WebKit::nextPowerOf2):
+        (WebKit::tableSizeForKeyCount):
+        (WebKit::SharedStringHashStore::SharedStringHashStore):
+        (WebKit::SharedStringHashStore::createSharedMemoryHandle):
+        (WebKit::SharedStringHashStore::add):
+        (WebKit::SharedStringHashStore::clear):
+        (WebKit::SharedStringHashStore::resizeTable):
+        (WebKit::SharedStringHashStore::pendingSharedStringHashesTimerFired):
+        * Shared/SharedStringHashStore.h: Copied from Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.h.
+        (WebKit::SharedStringHashStore::Client::~Client):
+        (WebKit::SharedStringHashStore::isEmpty const):
+        * Shared/SharedStringHashTable.cpp: Renamed from Source/WebKit/Shared/VisitedLinkTable.cpp.
+        (WebKit::SharedStringHashTable::SharedStringHashTable):
+        (WebKit::SharedStringHashTable::~SharedStringHashTable):
+        (WebKit::SharedStringHashTable::setSharedMemory):
+        (WebKit::SharedStringHashTable::add):
+        (WebKit::SharedStringHashTable::contains const):
+        (WebKit::SharedStringHashTable::clear):
+        * Shared/SharedStringHashTable.h: Renamed from Source/WebKit/Shared/VisitedLinkTable.h.
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextAddVisitedLink):
+        * UIProcess/API/Cocoa/_WKVisitedLinkStore.mm:
+        (-[_WKVisitedLinkStore addVisitedLinkWithURL:]):
+        * UIProcess/VisitedLinkStore.cpp:
+        (WebKit::VisitedLinkStore::VisitedLinkStore):
+        (WebKit::VisitedLinkStore::addProcess):
+        (WebKit::VisitedLinkStore::addVisitedLinkHash):
+        (WebKit::VisitedLinkStore::removeAll):
+        (WebKit::VisitedLinkStore::addVisitedLinkHashFromPage):
+        (WebKit::VisitedLinkStore::sendStoreHandleToProcess):
+        (WebKit::VisitedLinkStore::didInvalidateSharedMemory):
+        (WebKit::VisitedLinkStore::didAddSharedStringHashes):
+        * UIProcess/VisitedLinkStore.h:
+        * UIProcess/WebProcessPool.cpp:
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebProcessProxy.h:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/VisitedLinkTableController.cpp:
+        (WebKit::VisitedLinkTableController::isLinkVisited):
+        (WebKit::VisitedLinkTableController::addVisitedLink):
+        (WebKit::VisitedLinkTableController::visitedLinkStateChanged):
+        * WebProcess/WebPage/VisitedLinkTableController.h:
+        * WebProcess/WebPage/VisitedLinkTableController.messages.in:
+
 2017-09-28  Alex Christensen  <achristensen@webkit.org>
 
         Add WKWebViewConfiguration SPI equivalent to WKPageConfigurationSetBackgroundCPULimit
diff --git a/Source/WebKit/Shared/SharedStringHashStore.cpp b/Source/WebKit/Shared/SharedStringHashStore.cpp
new file mode 100644 (file)
index 0000000..0592030
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SharedStringHashStore.h"
+
+namespace WebKit {
+
+using namespace WebCore;
+
+const unsigned sharedStringHashTableMaxLoad = 2;
+
+static unsigned nextPowerOf2(unsigned v)
+{
+    // Taken from http://www.cs.utk.edu/~vose/c-stuff/bithacks.html
+    // Devised by Sean Anderson, Sepember 14, 2001
+
+    v--;
+    v |= v >> 1;
+    v |= v >> 2;
+    v |= v >> 4;
+    v |= v >> 8;
+    v |= v >> 16;
+    v++;
+
+    return v;
+}
+
+static unsigned tableSizeForKeyCount(unsigned keyCount)
+{
+    // We want the table to be at least half empty.
+    unsigned tableSize = nextPowerOf2(keyCount * sharedStringHashTableMaxLoad);
+
+    // Ensure that the table size is at least the size of a page.
+    size_t minimumTableSize = SharedMemory::systemPageSize() / sizeof(SharedStringHash);
+    if (tableSize < minimumTableSize)
+        return minimumTableSize;
+
+    return tableSize;
+}
+
+SharedStringHashStore::SharedStringHashStore(Client& client)
+    : m_client(client)
+    , m_pendingSharedStringHashesTimer(RunLoop::main(), this, &SharedStringHashStore::pendingSharedStringHashesTimerFired)
+{
+}
+
+bool SharedStringHashStore::createSharedMemoryHandle(SharedMemory::Handle& handle)
+{
+    return m_table.sharedMemory()->createHandle(handle, SharedMemory::Protection::ReadOnly);
+}
+
+void SharedStringHashStore::add(SharedStringHash sharedStringHash)
+{
+    m_pendingSharedStringHashes.add(sharedStringHash);
+
+    if (!m_pendingSharedStringHashesTimer.isActive())
+        m_pendingSharedStringHashesTimer.startOneShot(0_s);
+}
+
+void SharedStringHashStore::clear()
+{
+    m_pendingSharedStringHashesTimer.stop();
+    m_pendingSharedStringHashes.clear();
+    m_keyCount = 0;
+    m_tableSize = 0;
+    m_table.clear();
+}
+
+void SharedStringHashStore::resizeTable(unsigned newTableSize)
+{
+    auto newTableMemory = SharedMemory::allocate(newTableSize * sizeof(SharedStringHash));
+    if (!newTableMemory) {
+        LOG_ERROR("Could not allocate shared memory for SharedStringHash table");
+        return;
+    }
+
+    memset(newTableMemory->data(), 0, newTableMemory->size());
+
+    RefPtr<SharedMemory> currentTableMemory = m_table.sharedMemory();
+    unsigned currentTableSize = m_tableSize;
+
+    m_table.setSharedMemory(newTableMemory.releaseNonNull());
+    m_tableSize = newTableSize;
+
+    if (currentTableMemory) {
+        ASSERT_UNUSED(currentTableSize, currentTableMemory->size() == currentTableSize * sizeof(SharedStringHash));
+
+        // Go through the current hash table and re-add all entries to the new hash table.
+        const SharedStringHash* currentSharedStringHashes = static_cast<const SharedStringHash*>(currentTableMemory->data());
+        for (unsigned i = 0; i < currentTableSize; ++i) {
+            auto sharedStringHash = currentSharedStringHashes[i];
+            if (!sharedStringHash)
+                continue;
+
+            bool didAddSharedStringHash = m_table.add(sharedStringHash);
+
+            // It should always be possible to add the SharedStringHash to a new table.
+            ASSERT_UNUSED(didAddSharedStringHash, didAddSharedStringHash);
+        }
+    }
+
+    for (auto& sharedStringHash : m_pendingSharedStringHashes) {
+        if (m_table.add(sharedStringHash))
+            ++m_keyCount;
+    }
+    m_pendingSharedStringHashes.clear();
+
+    m_client.didInvalidateSharedMemory();
+}
+
+void SharedStringHashStore::pendingSharedStringHashesTimerFired()
+{
+    unsigned currentTableSize = m_tableSize;
+    unsigned newTableSize = tableSizeForKeyCount(m_keyCount + m_pendingSharedStringHashes.size());
+
+    newTableSize = std::max(currentTableSize, newTableSize);
+
+    if (currentTableSize != newTableSize) {
+        resizeTable(newTableSize);
+        return;
+    }
+
+    Vector<SharedStringHash> addedSharedStringHashes;
+    addedSharedStringHashes.reserveInitialCapacity(m_pendingSharedStringHashes.size());
+    for (auto& sharedStringHash : m_pendingSharedStringHashes) {
+        if (m_table.add(sharedStringHash)) {
+            addedSharedStringHashes.uncheckedAppend(sharedStringHash);
+            ++m_keyCount;
+        }
+    }
+
+    m_pendingSharedStringHashes.clear();
+
+    if (!addedSharedStringHashes.isEmpty())
+        m_client.didAddSharedStringHashes(addedSharedStringHashes);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/Shared/SharedStringHashStore.h b/Source/WebKit/Shared/SharedStringHashStore.h
new file mode 100644 (file)
index 0000000..b548393
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "SharedMemory.h"
+#include "SharedStringHashTable.h"
+#include <WebCore/SharedStringHash.h>
+#include <wtf/HashSet.h>
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+class SharedStringHashStore {
+public:
+    class Client {
+    public:
+        virtual ~Client() { }
+
+        virtual void didInvalidateSharedMemory() = 0;
+        virtual void didAddSharedStringHashes(const Vector<WebCore::SharedStringHash>&) = 0;
+    };
+
+    SharedStringHashStore(Client&);
+
+    bool createSharedMemoryHandle(SharedMemory::Handle&);
+    void add(WebCore::SharedStringHash);
+    void clear();
+
+    bool isEmpty() const { return !m_keyCount; }
+
+private:
+    void resizeTable(unsigned newTableSize);
+    void pendingSharedStringHashesTimerFired();
+
+    Client& m_client;
+    unsigned m_keyCount { 0 };
+    unsigned m_tableSize { 0 };
+    SharedStringHashTable m_table;
+    HashSet<WebCore::SharedStringHash, WebCore::SharedStringHashHash> m_pendingSharedStringHashes;
+    RunLoop::Timer<SharedStringHashStore> m_pendingSharedStringHashesTimer;
+};
+
+} // namespace WebKit
similarity index 74%
rename from Source/WebKit/Shared/VisitedLinkTable.cpp
rename to Source/WebKit/Shared/SharedStringHashTable.cpp
index 62b11b7..66bef94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -24,7 +24,7 @@
  */
 
 #include "config.h"
-#include "VisitedLinkTable.h"
+#include "SharedStringHashTable.h"
 
 #include "SharedMemory.h"
 
@@ -32,14 +32,11 @@ using namespace WebCore;
 
 namespace WebKit {
 
-VisitedLinkTable::VisitedLinkTable()
-    : m_tableSize(0)
-    , m_tableSizeMask(0)
-    , m_table(nullptr)
+SharedStringHashTable::SharedStringHashTable()
 {
 }
 
-VisitedLinkTable::~VisitedLinkTable()
+SharedStringHashTable::~SharedStringHashTable()
 {
 }
 
@@ -52,15 +49,15 @@ static inline bool isPowerOf2(unsigned v)
 }
 #endif
 
-void VisitedLinkTable::setSharedMemory(Ref<SharedMemory>&& sharedMemory)
+void SharedStringHashTable::setSharedMemory(Ref<SharedMemory>&& sharedMemory)
 {
     m_sharedMemory = WTFMove(sharedMemory);
     
     ASSERT(m_sharedMemory);
-    ASSERT(!(m_sharedMemory->size() % sizeof(LinkHash)));
+    ASSERT(!(m_sharedMemory->size() % sizeof(SharedStringHash)));
 
-    m_table = static_cast<LinkHash*>(m_sharedMemory->data());
-    m_tableSize = m_sharedMemory->size() / sizeof(LinkHash);
+    m_table = static_cast<SharedStringHash*>(m_sharedMemory->data());
+    m_tableSize = m_sharedMemory->size() / sizeof(SharedStringHash);
     ASSERT(isPowerOf2(m_tableSize));
     
     m_tableSizeMask = m_tableSize - 1;
@@ -76,17 +73,17 @@ static inline unsigned doubleHash(unsigned key)
     return key;
 }
     
-bool VisitedLinkTable::addLinkHash(LinkHash linkHash)
+bool SharedStringHashTable::add(SharedStringHash sharedStringHash)
 {
     ASSERT(m_sharedMemory);
 
     int k = 0;
-    LinkHash* table = m_table;
+    SharedStringHash* table = m_table;
     int sizeMask = m_tableSizeMask;
-    unsigned h = static_cast<unsigned>(linkHash);
+    unsigned h = static_cast<unsigned>(sharedStringHash);
     int i = h & sizeMask;
-  
-    LinkHash* entry;
+
+    SharedStringHash* entry;
     while (1) {
         entry = table + i;
 
@@ -95,7 +92,7 @@ bool VisitedLinkTable::addLinkHash(LinkHash linkHash)
             break;
 
         // Check if the same link hash is in the table already.
-        if (*entry == linkHash)
+        if (*entry == sharedStringHash)
             return false;
 
         if (!k)
@@ -103,22 +100,22 @@ bool VisitedLinkTable::addLinkHash(LinkHash linkHash)
         i = (i + k) & sizeMask;
     }
 
-    *entry = linkHash;
+    *entry = sharedStringHash;
     return true;
 }
 
-bool VisitedLinkTable::isLinkVisited(LinkHash linkHash) const
+bool SharedStringHashTable::contains(SharedStringHash sharedStringHash) const
 {
     if (!m_sharedMemory)
         return false;
 
     int k = 0;
-    LinkHash* table = m_table;
+    SharedStringHash* table = m_table;
     int sizeMask = m_tableSizeMask;
-    unsigned h = static_cast<unsigned>(linkHash);
+    unsigned h = static_cast<unsigned>(sharedStringHash);
     int i = h & sizeMask;
     
-    LinkHash* entry;
+    SharedStringHash* entry;
     while (1) {
         entry = table + i;
 
@@ -126,7 +123,7 @@ bool VisitedLinkTable::isLinkVisited(LinkHash linkHash) const
         if (!*entry)
             break;
         
-        if (*entry == linkHash)
+        if (*entry == sharedStringHash)
             return true;
         
         if (!k)
@@ -137,7 +134,7 @@ bool VisitedLinkTable::isLinkVisited(LinkHash linkHash) const
     return false;
 }
 
-void VisitedLinkTable::clear()
+void SharedStringHashTable::clear()
 {
     m_tableSize = 0;
     m_tableSizeMask = 0;
similarity index 76%
rename from Source/WebKit/Shared/VisitedLinkTable.h
rename to Source/WebKit/Shared/SharedStringHashTable.h
index 1d91267..9cd2d3e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef VisitedLinkTable_h
-#define VisitedLinkTable_h
+#pragma once
 
-#include <WebCore/LinkHash.h>
+#include <WebCore/SharedStringHash.h>
 #include <wtf/RefPtr.h>
 
 namespace WebKit {
 
 class SharedMemory;
 
-class VisitedLinkTable {
+class SharedStringHashTable {
 public:
-    VisitedLinkTable();
-    ~VisitedLinkTable();
+    SharedStringHashTable();
+    ~SharedStringHashTable();
 
     void setSharedMemory(Ref<SharedMemory>&&);
 
-    // This should only be called from the UI process.
-    bool addLinkHash(WebCore::LinkHash);
+    // Can only be called if the underlying shared memory is in read / write mode.
+    bool add(WebCore::SharedStringHash);
 
-    bool isLinkVisited(WebCore::LinkHash) const;
+    bool contains(WebCore::SharedStringHash) const;
 
     SharedMemory* sharedMemory() const { return m_sharedMemory.get(); }
     void clear();
@@ -51,11 +50,9 @@ public:
 private:
     RefPtr<SharedMemory> m_sharedMemory;
 
-    unsigned m_tableSize;
-    unsigned m_tableSizeMask;
-    WebCore::LinkHash* m_table;
+    unsigned m_tableSize { 0 };
+    unsigned m_tableSizeMask { 0 };
+    WebCore::SharedStringHash* m_table { nullptr };
 };
 
 }
-
-#endif // VisitedLinkTable_h
index 7048bbe..a6c41e8 100644 (file)
@@ -315,7 +315,7 @@ void WKContextAddVisitedLink(WKContextRef contextRef, WKStringRef visitedURL)
     if (visitedURLString.isEmpty())
         return;
 
-    toImpl(contextRef)->visitedLinkStore().addVisitedLinkHash(visitedLinkHash(visitedURLString));
+    toImpl(contextRef)->visitedLinkStore().addVisitedLinkHash(computeSharedStringHash(visitedURLString));
 }
 
 void WKContextClearVisitedLinks(WKContextRef contextRef)
index c56f02c..fadf808 100644 (file)
@@ -29,7 +29,7 @@
 #if WK_API_ENABLED
 
 #import "VisitedLinkStore.h"
-#import <WebCore/LinkHash.h>
+#import <WebCore/SharedStringHash.h>
 
 @implementation _WKVisitedLinkStore
 
@@ -52,7 +52,7 @@
 
 - (void)addVisitedLinkWithURL:(NSURL *)URL
 {
-    auto linkHash = WebCore::visitedLinkHash(URL.absoluteString);
+    auto linkHash = WebCore::computeSharedStringHash(URL.absoluteString);
 
     _visitedLinkStore->addVisitedLinkHash(linkHash);
 }
index bd002c0..1fdd1b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,9 +26,7 @@
 #include "config.h"
 #include "VisitedLinkStore.h"
 
-#include "SharedMemory.h"
 #include "VisitedLinkStoreMessages.h"
-#include "VisitedLinkTable.h"
 #include "VisitedLinkTableControllerMessages.h"
 #include "WebProcessMessages.h"
 #include "WebProcessPool.h"
@@ -38,8 +36,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static const int visitedLinkTableMaxLoad = 2;
-
 Ref<VisitedLinkStore> VisitedLinkStore::create()
 {
     return adoptRef(*new VisitedLinkStore);
@@ -54,9 +50,7 @@ VisitedLinkStore::~VisitedLinkStore()
 }
 
 VisitedLinkStore::VisitedLinkStore()
-    : m_keyCount(0)
-    , m_tableSize(0)
-    , m_pendingVisitedLinksTimer(RunLoop::main(), this, &VisitedLinkStore::pendingVisitedLinksTimerFired)
+    : m_linkHashStore(*this)
 {
 }
 
@@ -69,12 +63,10 @@ void VisitedLinkStore::addProcess(WebProcessProxy& process)
 
     process.addMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier(), *this);
 
-    if (!m_keyCount)
+    if (m_linkHashStore.isEmpty())
         return;
 
-    ASSERT(m_table.sharedMemory());
-
-    sendTable(process);
+    sendStoreHandleToProcess(process);
 }
 
 void VisitedLinkStore::removeProcess(WebProcessProxy& process)
@@ -85,21 +77,14 @@ void VisitedLinkStore::removeProcess(WebProcessProxy& process)
     process.removeMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier());
 }
 
-void VisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
+void VisitedLinkStore::addVisitedLinkHash(SharedStringHash linkHash)
 {
-    m_pendingVisitedLinks.add(linkHash);
-
-    if (!m_pendingVisitedLinksTimer.isActive())
-        m_pendingVisitedLinksTimer.startOneShot(0_s);
+    m_linkHashStore.add(linkHash);
 }
 
 void VisitedLinkStore::removeAll()
 {
-    m_pendingVisitedLinksTimer.stop();
-    m_pendingVisitedLinks.clear();
-    m_keyCount = 0;
-    m_tableSize = 0;
-    m_table.clear();
+    m_linkHashStore.clear();
 
     for (WebProcessProxy* process : m_processes) {
         ASSERT(process->processPool().processes().contains(process));
@@ -117,9 +102,9 @@ void VisitedLinkStore::webProcessDidCloseConnection(WebProcessProxy&, IPC::Conne
     // FIXME: Implement.
 }
 
-void VisitedLinkStore::addVisitedLinkHashFromPage(uint64_t pageID, LinkHash linkHash)
+void VisitedLinkStore::addVisitedLinkHashFromPage(uint64_t pageID, SharedStringHash linkHash)
 {
-    if (WebPageProxy* webPageProxy = WebProcessProxy::webPage(pageID)) {
+    if (auto* webPageProxy = WebProcessProxy::webPage(pageID)) {
         if (!webPageProxy->addsVisitedLinks())
             return;
     }
@@ -127,125 +112,35 @@ void VisitedLinkStore::addVisitedLinkHashFromPage(uint64_t pageID, LinkHash link
     addVisitedLinkHash(linkHash);
 }
 
-static unsigned nextPowerOf2(unsigned v)
+void VisitedLinkStore::sendStoreHandleToProcess(WebProcessProxy& process)
 {
-    // Taken from http://www.cs.utk.edu/~vose/c-stuff/bithacks.html
-    // Devised by Sean Anderson, Sepember 14, 2001
-    
-    v--;
-    v |= v >> 1;
-    v |= v >> 2;
-    v |= v >> 4;
-    v |= v >> 8;
-    v |= v >> 16;
-    v++;
-    
-    return v;
+    ASSERT(process.processPool().processes().contains(&process));
+
+    SharedMemory::Handle handle;
+    if (!m_linkHashStore.createSharedMemoryHandle(handle))
+        return;
+
+    process.send(Messages::VisitedLinkTableController::SetVisitedLinkTable(handle), identifier());
 }
 
-static unsigned tableSizeForKeyCount(unsigned keyCount)
+void VisitedLinkStore::didInvalidateSharedMemory()
 {
-    // We want the table to be at least half empty.
-    unsigned tableSize = nextPowerOf2(keyCount * visitedLinkTableMaxLoad);
-
-    // Ensure that the table size is at least the size of a page.
-    size_t minimumTableSize = SharedMemory::systemPageSize() / sizeof(LinkHash);
-    if (tableSize < minimumTableSize)
-        return minimumTableSize;
-    
-    return tableSize;
+    for (WebProcessProxy* process : m_processes)
+        sendStoreHandleToProcess(*process);
 }
 
-void VisitedLinkStore::pendingVisitedLinksTimerFired()
+void VisitedLinkStore::didAddSharedStringHashes(const Vector<WebCore::SharedStringHash>& linkHashes)
 {
-    unsigned currentTableSize = m_tableSize;
-    unsigned newTableSize = tableSizeForKeyCount(m_keyCount + m_pendingVisitedLinks.size());
-
-    newTableSize = std::max(currentTableSize, newTableSize);
-
-    if (currentTableSize != newTableSize) {
-        resizeTable(newTableSize);
-        return;
-    }
-
-    Vector<WebCore::LinkHash> addedVisitedLinks;
-
-    for (auto& linkHash : m_pendingVisitedLinks) {
-        if (m_table.addLinkHash(linkHash)) {
-            addedVisitedLinks.append(linkHash);
-            ++m_keyCount;
-        }
-    }
-
-    m_pendingVisitedLinks.clear();
-
-    if (addedVisitedLinks.isEmpty())
-        return;
+    ASSERT(!linkHashes.isEmpty());
 
     for (WebProcessProxy* process : m_processes) {
         ASSERT(process->processPool().processes().contains(process));
 
-        if (addedVisitedLinks.size() > 20)
+        if (linkHashes.size() > 20)
             process->send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), identifier());
         else
-            process->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedVisitedLinks), identifier());
-    }
-}
-
-void VisitedLinkStore::resizeTable(unsigned newTableSize)
-{
-    auto newTableMemory = SharedMemory::allocate(newTableSize * sizeof(LinkHash));
-
-    if (!newTableMemory) {
-        LOG_ERROR("Could not allocate shared memory for visited link table");
-        return;
-    }
-
-    memset(newTableMemory->data(), 0, newTableMemory->size());
-
-    RefPtr<SharedMemory> currentTableMemory = m_table.sharedMemory();
-    unsigned currentTableSize = m_tableSize;
-
-    m_table.setSharedMemory(newTableMemory.releaseNonNull());
-    m_tableSize = newTableSize;
-
-    if (currentTableMemory) {
-        ASSERT_UNUSED(currentTableSize, currentTableMemory->size() == currentTableSize * sizeof(LinkHash));
-
-        // Go through the current hash table and re-add all entries to the new hash table.
-        const LinkHash* currentLinkHashes = static_cast<const LinkHash*>(currentTableMemory->data());
-        for (unsigned i = 0; i < currentTableSize; ++i) {
-            LinkHash linkHash = currentLinkHashes[i];
-
-            if (!linkHash)
-                continue;
-
-            bool didAddLinkHash = m_table.addLinkHash(linkHash);
-
-            // It should always be possible to add the link hash to a new table.
-            ASSERT_UNUSED(didAddLinkHash, didAddLinkHash);
-        }
-    }
-
-    for (auto& linkHash : m_pendingVisitedLinks) {
-        if (m_table.addLinkHash(linkHash))
-            m_keyCount++;
+            process->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(linkHashes), identifier());
     }
-    m_pendingVisitedLinks.clear();
-
-    for (WebProcessProxy* process : m_processes)
-        sendTable(*process);
-}
-
-void VisitedLinkStore::sendTable(WebProcessProxy& process)
-{
-    ASSERT(process.processPool().processes().contains(&process));
-
-    SharedMemory::Handle handle;
-    if (!m_table.sharedMemory()->createHandle(handle, SharedMemory::Protection::ReadOnly))
-        return;
-
-    process.send(Messages::VisitedLinkTableController::SetVisitedLinkTable(handle), identifier());
 }
 
 } // namespace WebKit
index 5c6ad8d..728cdc9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef VisitedLinkStore_h
-#define VisitedLinkStore_h
+#pragma once
 
 #include "APIObject.h"
 #include "MessageReceiver.h"
-#include "VisitedLinkTable.h"
+#include "SharedStringHashStore.h"
 #include "WebPageProxy.h"
 #include "WebProcessLifetimeObserver.h"
-#include <WebCore/LinkHash.h>
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
 #include <wtf/Identified.h>
 #include <wtf/RefCounted.h>
-#include <wtf/RunLoop.h>
 
 namespace WebKit {
 
 class WebPageProxy;
 class WebProcessProxy;
     
-class VisitedLinkStore final : public API::ObjectImpl<API::Object::Type::VisitedLinkStore>, private IPC::MessageReceiver, public WebProcessLifetimeObserver, public Identified<VisitedLinkStore>  {
+class VisitedLinkStore final : public API::ObjectImpl<API::Object::Type::VisitedLinkStore>, private IPC::MessageReceiver, public WebProcessLifetimeObserver, public Identified<VisitedLinkStore>, private SharedStringHashStore::Client {
 public:
     static Ref<VisitedLinkStore> create();
 
@@ -53,34 +50,27 @@ public:
     void addProcess(WebProcessProxy&);
     void removeProcess(WebProcessProxy&);
 
-    void addVisitedLinkHash(WebCore::LinkHash);
+    void addVisitedLinkHash(WebCore::SharedStringHash);
     void removeAll();
 
 private:
     // IPC::MessageReceiver
-    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
 
     // WebProcessLifetimeObserver
-    void webProcessWillOpenConnection(WebProcessProxy&, IPC::Connection&) override;
-    void webProcessDidCloseConnection(WebProcessProxy&, IPC::Connection&) override;
+    void webProcessWillOpenConnection(WebProcessProxy&, IPC::Connection&) final;
+    void webProcessDidCloseConnection(WebProcessProxy&, IPC::Connection&) final;
 
-    void addVisitedLinkHashFromPage(uint64_t pageID, WebCore::LinkHash);
+    // SharedStringHashStore::Client
+    void didInvalidateSharedMemory() final;
+    void didAddSharedStringHashes(const Vector<WebCore::SharedStringHash>&) final;
 
-    void pendingVisitedLinksTimerFired();
+    void addVisitedLinkHashFromPage(uint64_t pageID, WebCore::SharedStringHash);
 
-    void resizeTable(unsigned newTableSize);
-    void sendTable(WebProcessProxy&);
+    void sendStoreHandleToProcess(WebProcessProxy&);
 
     HashSet<WebProcessProxy*> m_processes;
-
-    unsigned m_keyCount;
-    unsigned m_tableSize;
-    VisitedLinkTable m_table;
-
-    HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_pendingVisitedLinks;
-    RunLoop::Timer<VisitedLinkStore> m_pendingVisitedLinksTimer;
+    SharedStringHashStore m_linkHashStore;
 };
 
 } // namespace WebKit
-
-#endif // VisitedLinkStore_h
index 2620863..e310651 100644 (file)
@@ -72,7 +72,6 @@
 #include "WebsiteDataStore.h"
 #include "WebsiteDataStoreParameters.h"
 #include <WebCore/ApplicationCacheStorage.h>
-#include <WebCore/LinkHash.h>
 #include <WebCore/LogInitialization.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/URLParser.h>
index ad5b0c6..7c7a8ec 100644 (file)
@@ -44,7 +44,7 @@
 #include "WebContextClient.h"
 #include "WebContextConnectionClient.h"
 #include "WebProcessProxy.h"
-#include <WebCore/LinkHash.h>
+#include <WebCore/SharedStringHash.h>
 #include <pal/SessionID.h>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
index fa5f7e5..d51f0c2 100644 (file)
@@ -38,7 +38,7 @@
 #include "VisibleWebPageCounter.h"
 #include "WebConnectionToWebProcess.h"
 #include "WebProcessProxyMessages.h"
-#include <WebCore/LinkHash.h>
+#include <WebCore/SharedStringHash.h>
 #include <memory>
 #include <pal/SessionID.h>
 #include <wtf/Forward.h>
index c28cc11..638d670 100644 (file)
                1A0EC907124C0AB8007EF4A5 /* PluginProcessConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0EC905124C0AB8007EF4A5 /* PluginProcessConnection.cpp */; };
                1A0EC90F124C0AF5007EF4A5 /* PluginProcessConnectionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC90D124C0AF5007EF4A5 /* PluginProcessConnectionManager.h */; };
                1A0EC910124C0AF5007EF4A5 /* PluginProcessConnectionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0EC90E124C0AF5007EF4A5 /* PluginProcessConnectionManager.cpp */; };
-               1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */; };
-               1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */; };
                1A0F29E3120B44420053D1B9 /* VisitedLinkStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F29E1120B44420053D1B9 /* VisitedLinkStore.cpp */; };
                1A0F29E4120B44420053D1B9 /* VisitedLinkStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29E2120B44420053D1B9 /* VisitedLinkStore.h */; };
                1A14F8E11D74C834006CBEC6 /* FrameInfoData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A14F8DF1D74C834006CBEC6 /* FrameInfoData.cpp */; };
                83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83048AE51ACA45DC0082C832 /* ProcessThrottlerClient.h */; };
                8310428B1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 831042891BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.h */; };
                8310428C1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8310428A1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp */; };
+               8313F7EB1F7DAE0800B944EB /* SharedStringHashStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8313F7EA1F7DAE0400B944EB /* SharedStringHashStore.cpp */; };
+               8313F7EC1F7DAE0800B944EB /* SharedStringHashStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 8313F7E91F7DAE0300B944EB /* SharedStringHashStore.h */; };
+               8313F7ED1F7DAE0800B944EB /* SharedStringHashTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8313F7E81F7DAE0300B944EB /* SharedStringHashTable.cpp */; };
+               8313F7EE1F7DAE0800B944EB /* SharedStringHashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 8313F7E71F7DAE0300B944EB /* SharedStringHashTable.h */; };
                831EEBBD1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 831EEBBB1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.h */; };
                831EEBBE1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 831EEBBC1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.cpp */; };
                832AE2521BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 832AE2501BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.h */; };
                1A0EC905124C0AB8007EF4A5 /* PluginProcessConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessConnection.cpp; sourceTree = "<group>"; };
                1A0EC90D124C0AF5007EF4A5 /* PluginProcessConnectionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessConnectionManager.h; sourceTree = "<group>"; };
                1A0EC90E124C0AF5007EF4A5 /* PluginProcessConnectionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessConnectionManager.cpp; sourceTree = "<group>"; };
-               1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkTable.cpp; sourceTree = "<group>"; };
-               1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkTable.h; sourceTree = "<group>"; };
                1A0F29E1120B44420053D1B9 /* VisitedLinkStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkStore.cpp; sourceTree = "<group>"; };
                1A0F29E2120B44420053D1B9 /* VisitedLinkStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkStore.h; sourceTree = "<group>"; };
                1A14F8DF1D74C834006CBEC6 /* FrameInfoData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameInfoData.cpp; sourceTree = "<group>"; };
                83048AE51ACA45DC0082C832 /* ProcessThrottlerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessThrottlerClient.h; sourceTree = "<group>"; };
                831042891BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheSubresourcesEntry.h; sourceTree = "<group>"; };
                8310428A1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheSubresourcesEntry.cpp; sourceTree = "<group>"; };
+               8313F7E71F7DAE0300B944EB /* SharedStringHashTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedStringHashTable.h; sourceTree = "<group>"; };
+               8313F7E81F7DAE0300B944EB /* SharedStringHashTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedStringHashTable.cpp; sourceTree = "<group>"; };
+               8313F7E91F7DAE0300B944EB /* SharedStringHashStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedStringHashStore.h; sourceTree = "<group>"; };
+               8313F7EA1F7DAE0400B944EB /* SharedStringHashStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedStringHashStore.cpp; sourceTree = "<group>"; };
                831EEBBB1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheSpeculativeLoad.h; sourceTree = "<group>"; };
                831EEBBC1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheSpeculativeLoad.cpp; sourceTree = "<group>"; };
                832AE2501BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheSpeculativeLoadManager.h; sourceTree = "<group>"; };
                                1A6420E312DCE2FF00CAAE2C /* ShareableBitmap.h */,
                                5121745E164C20E30037A5C1 /* ShareableResource.cpp */,
                                5121745F164C20E30037A5C1 /* ShareableResource.h */,
+                               8313F7EA1F7DAE0400B944EB /* SharedStringHashStore.cpp */,
+                               8313F7E91F7DAE0300B944EB /* SharedStringHashStore.h */,
+                               8313F7E81F7DAE0300B944EB /* SharedStringHashTable.cpp */,
+                               8313F7E71F7DAE0300B944EB /* SharedStringHashTable.h */,
                                5272B2881406985D0096A5D0 /* StatisticsData.cpp */,
                                5272B2891406985D0096A5D0 /* StatisticsData.h */,
                                1A5E4DA312D3BD3D0099A2BB /* TextCheckerState.h */,
                                1AC1336618565B5700F3EC05 /* UserData.h */,
                                2684054A18B866FF0022C38B /* VisibleContentRectUpdateInfo.cpp */,
                                2684054218B85A630022C38B /* VisibleContentRectUpdateInfo.h */,
-                               1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */,
-                               1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */,
                                518D2CAB12D5153B003BB93B /* WebBackForwardListItem.cpp */,
                                518D2CAC12D5153B003BB93B /* WebBackForwardListItem.h */,
                                BCF50726124329AA005955AE /* WebCertificateInfo.h */,
                                51217461164C20E30037A5C1 /* ShareableResource.h in Headers */,
                                1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
                                CD4B4D9D1E765E0000D27092 /* SharedRingBufferStorage.h in Headers */,
+                               8313F7EC1F7DAE0800B944EB /* SharedStringHashStore.h in Headers */,
+                               8313F7EE1F7DAE0800B944EB /* SharedStringHashTable.h in Headers */,
                                2DAF06D618BD1A470081CEB1 /* SmartMagnificationController.h in Headers */,
                                2DE6943E18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h in Headers */,
                                5272B28B1406985D0096A5D0 /* StatisticsData.h in Headers */,
                                2DD5A7291EBF08D5009BA597 /* VisibleWebPageCounter.h in Headers */,
                                1A0F29E4120B44420053D1B9 /* VisitedLinkStore.h in Headers */,
                                1A60224D18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h in Headers */,
-                               1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */,
                                1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */,
                                1A8E7D3D18C15149005A702A /* VisitedLinkTableControllerMessages.h in Headers */,
                                1AA9BAE1184FFAC7003B6BC6 /* WeakObjCPtr.h in Headers */,
                                51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
                                4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */,
                                CD4B4D9C1E765E0000D27092 /* SharedRingBufferStorage.cpp in Sources */,
+                               8313F7EB1F7DAE0800B944EB /* SharedStringHashStore.cpp in Sources */,
+                               8313F7ED1F7DAE0800B944EB /* SharedStringHashTable.cpp in Sources */,
                                2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */,
                                2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */,
                                5272B28A1406985D0096A5D0 /* StatisticsData.cpp in Sources */,
                                2684054C18B86C350022C38B /* VisibleContentRectUpdateInfo.cpp in Sources */,
                                1A0F29E3120B44420053D1B9 /* VisitedLinkStore.cpp in Sources */,
                                1A60224C18C16B9F00C3E8C9 /* VisitedLinkStoreMessageReceiver.cpp in Sources */,
-                               1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */,
                                1AF4CEEF18BC481800BC2D34 /* VisitedLinkTableController.cpp in Sources */,
                                1A8E7D3C18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp in Sources */,
                                CEDA12E2152CD1AE00D9E08D /* WebAlternativeTextClient.cpp in Sources */,
index 6e8b06d..ef71280 100644 (file)
@@ -71,14 +71,14 @@ VisitedLinkTableController::~VisitedLinkTableController()
     visitedLinkTableControllers().remove(m_identifier);
 }
 
-bool VisitedLinkTableController::isLinkVisited(Page&, LinkHash linkHash, const URL&, const AtomicString&)
+bool VisitedLinkTableController::isLinkVisited(Page&, SharedStringHash linkHash, const URL&, const AtomicString&)
 {
-    return m_visitedLinkTable.isLinkVisited(linkHash);
+    return m_visitedLinkTable.contains(linkHash);
 }
 
-void VisitedLinkTableController::addVisitedLink(Page& page, LinkHash linkHash)
+void VisitedLinkTableController::addVisitedLink(Page& page, SharedStringHash linkHash)
 {
-    if (m_visitedLinkTable.isLinkVisited(linkHash))
+    if (m_visitedLinkTable.contains(linkHash))
         return;
 
     WebPage* webPage = WebPage::fromCorePage(&page);
@@ -99,7 +99,7 @@ void VisitedLinkTableController::setVisitedLinkTable(const SharedMemory::Handle&
     invalidateStylesForAllLinks();
 }
 
-void VisitedLinkTableController::visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes)
+void VisitedLinkTableController::visitedLinkStateChanged(const Vector<WebCore::SharedStringHash>& linkHashes)
 {
     for (auto linkHash : linkHashes)
         invalidateStylesForLink(linkHash);
index d6e82bf..747e3d8 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "MessageReceiver.h"
 #include "SharedMemory.h"
-#include "VisitedLinkTable.h"
+#include "SharedStringHashTable.h"
 #include <WebCore/VisitedLinkStore.h>
 
 namespace WebKit {
@@ -41,19 +41,19 @@ private:
     explicit VisitedLinkTableController(uint64_t identifier);
 
     // WebCore::VisitedLinkStore.
-    bool isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
-    void addVisitedLink(WebCore::Page&, WebCore::LinkHash) override;
+    bool isLinkVisited(WebCore::Page&, WebCore::SharedStringHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
+    void addVisitedLink(WebCore::Page&, WebCore::SharedStringHash) override;
 
     // IPC::MessageReceiver.
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
     void setVisitedLinkTable(const SharedMemory::Handle&);
-    void visitedLinkStateChanged(const Vector<WebCore::LinkHash>&);
+    void visitedLinkStateChanged(const Vector<WebCore::SharedStringHash>&);
     void allVisitedLinkStateChanged();
     void removeAllVisitedLinks();
 
     uint64_t m_identifier;
-    VisitedLinkTable m_visitedLinkTable;
+    SharedStringHashTable m_visitedLinkTable;
 };
 
 } // namespace WebKit
index 039dd30..f916453 100644 (file)
@@ -22,7 +22,7 @@
 
 messages -> VisitedLinkTableController {
     SetVisitedLinkTable(WebKit::SharedMemory::Handle handle)
-    VisitedLinkStateChanged(Vector<WebCore::LinkHash> linkHashes)
+    VisitedLinkStateChanged(Vector<WebCore::SharedStringHash> linkHashes)
     AllVisitedLinkStateChanged()
     RemoveAllVisitedLinks()
 }
index 7c0cfe6..72a24f1 100644 (file)
@@ -1,3 +1,17 @@
+2017-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Split some logic out of VisitedLinkStore and make it reusable
+        https://bugs.webkit.org/show_bug.cgi?id=177575
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebVisitedLinkStore.h:
+        * WebCoreSupport/WebVisitedLinkStore.mm:
+        (WebVisitedLinkStore::addVisitedLink):
+        (WebVisitedLinkStore::removeVisitedLink):
+        (WebVisitedLinkStore::isLinkVisited):
+        (WebVisitedLinkStore::addVisitedLinkHash):
+
 2017-09-28  Jonathan Bedard  <jbedard@apple.com>
 
         Build fix for High Sierra 32 bit Mac
index 164fed1..aef4fc5 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef WebVisitedLinkStore_h
 #define WebVisitedLinkStore_h
 
-#import <WebCore/LinkHash.h>
+#import <WebCore/SharedStringHash.h>
 #import <WebCore/VisitedLinkStore.h>
 #import <wtf/Ref.h>
 
@@ -44,14 +44,14 @@ public:
 private:
     WebVisitedLinkStore();
 
-    bool isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
-    void addVisitedLink(WebCore::Page&, WebCore::LinkHash) override;
+    bool isLinkVisited(WebCore::Page&, WebCore::SharedStringHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
+    void addVisitedLink(WebCore::Page&, WebCore::SharedStringHash) override;
 
     void populateVisitedLinksIfNeeded(WebCore::Page&);
-    void addVisitedLinkHash(WebCore::LinkHash);
+    void addVisitedLinkHash(WebCore::SharedStringHash);
     void removeVisitedLinkHashes();
 
-    HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_visitedLinkHashes;
+    HashSet<WebCore::SharedStringHash, WebCore::SharedStringHashHash> m_visitedLinkHashes;
     bool m_visitedLinksPopulated;
 };
 
index a152933..b221d93 100644 (file)
@@ -84,19 +84,19 @@ void WebVisitedLinkStore::addVisitedLink(NSString *urlString)
     size_t length = urlString.length;
 
     if (const UChar* characters = CFStringGetCharactersPtr((__bridge CFStringRef)urlString)) {
-        addVisitedLinkHash(visitedLinkHash(characters, length));
+        addVisitedLinkHash(computeSharedStringHash(characters, length));
         return;
     }
 
     Vector<UChar, 512> buffer(length);
     [urlString getCharacters:buffer.data()];
 
-    addVisitedLinkHash(visitedLinkHash(buffer.data(), length));
+    addVisitedLinkHash(computeSharedStringHash(buffer.data(), length));
 }
 
 void WebVisitedLinkStore::removeVisitedLink(NSString *urlString)
 {
-    LinkHash linkHash = visitedLinkHash(urlString);
+    auto linkHash = computeSharedStringHash(urlString);
 
     ASSERT(m_visitedLinkHashes.contains(linkHash));
     m_visitedLinkHashes.remove(linkHash);
@@ -104,14 +104,14 @@ void WebVisitedLinkStore::removeVisitedLink(NSString *urlString)
     invalidateStylesForLink(linkHash);
 }
 
-bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
+bool WebVisitedLinkStore::isLinkVisited(Page& page, SharedStringHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
 {
     populateVisitedLinksIfNeeded(page);
 
     return m_visitedLinkHashes.contains(linkHash);
 }
 
-void WebVisitedLinkStore::addVisitedLink(Page& sourcePage, LinkHash linkHash)
+void WebVisitedLinkStore::addVisitedLink(Page& sourcePage, SharedStringHash linkHash)
 {
     if (!s_shouldTrackVisitedLinks)
         return;
@@ -143,7 +143,7 @@ void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page& page)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
+void WebVisitedLinkStore::addVisitedLinkHash(SharedStringHash linkHash)
 {
     ASSERT(s_shouldTrackVisitedLinks);
 
index 8df5d8c..b5b67eb 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Split some logic out of VisitedLinkStore and make it reusable
+        https://bugs.webkit.org/show_bug.cgi?id=177575
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebVisitedLinkStore.cpp:
+        (WebVisitedLinkStore::addVisitedLink):
+        (WebVisitedLinkStore::isLinkVisited):
+        (WebVisitedLinkStore::addVisitedLinkHash):
+        * WebCoreSupport/WebVisitedLinkStore.h:
+
 2017-09-25  Alex Christensen  <achristensen@webkit.org>
 
         Make PolicyAction an encodable enum class
index 6b43c11..2a7a7d7 100644 (file)
@@ -75,17 +75,17 @@ void WebVisitedLinkStore::removeAllVisitedLinks()
 
 void WebVisitedLinkStore::addVisitedLink(const String& urlString)
 {
-    addVisitedLinkHash(visitedLinkHash(urlString));
+    addVisitedLinkHash(computeSharedStringHash(urlString));
 }
 
-bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
+bool WebVisitedLinkStore::isLinkVisited(Page& page, SharedStringHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
 {
     populateVisitedLinksIfNeeded(page);
 
     return m_visitedLinkHashes.contains(linkHash);
 }
 
-void WebVisitedLinkStore::addVisitedLink(Page&, LinkHash linkHash)
+void WebVisitedLinkStore::addVisitedLink(Page&, SharedStringHash linkHash)
 {
     if (!s_shouldTrackVisitedLinks)
         return;
@@ -117,7 +117,7 @@ void WebVisitedLinkStore::populateVisitedLinksIfNeeded(Page& sourcePage)
     history->addVisitedLinksToVisitedLinkStore(*this);
 }
 
-void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
+void WebVisitedLinkStore::addVisitedLinkHash(SharedStringHash linkHash)
 {
     ASSERT(s_shouldTrackVisitedLinks);
     m_visitedLinkHashes.add(linkHash);
index e9e1244..6a7b992 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef WebVisitedLinkStore_h
 #define WebVisitedLinkStore_h
 
-#include <WebCore/LinkHash.h>
+#include <WebCore/SharedStringHash.h>
 #include <WebCore/VisitedLinkStore.h>
 
 class WebVisitedLinkStore final : public WebCore::VisitedLinkStore {
@@ -42,14 +42,14 @@ public:
 private:
     WebVisitedLinkStore();
 
-    bool isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
-    void addVisitedLink(WebCore::Page&, WebCore::LinkHash) override;
+    bool isLinkVisited(WebCore::Page&, WebCore::SharedStringHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
+    void addVisitedLink(WebCore::Page&, WebCore::SharedStringHash) override;
 
     void populateVisitedLinksIfNeeded(WebCore::Page&);
-    void addVisitedLinkHash(WebCore::LinkHash);
+    void addVisitedLinkHash(WebCore::SharedStringHash);
     void removeVisitedLinkHashes();
 
-    HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_visitedLinkHashes;
+    HashSet<WebCore::SharedStringHash, WebCore::SharedStringHashHash> m_visitedLinkHashes;
     bool m_visitedLinksPopulated;
 };