Look up already existing VisitedLinkTableController objects by identifier
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Feb 2014 18:09:04 +0000 (18:09 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Feb 2014 18:09:04 +0000 (18:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129431

Reviewed by Dan Bernstein.

* WebProcess/WebPage/VisitedLinkTableController.cpp:
(WebKit::visitedLinkTableControllers):
(WebKit::VisitedLinkTableController::getOrCreate):
(WebKit::VisitedLinkTableController::VisitedLinkTableController):
(WebKit::VisitedLinkTableController::~VisitedLinkTableController):
* WebProcess/WebPage/VisitedLinkTableController.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.cpp
Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 2732d1c..30cd3f2 100644 (file)
@@ -1,3 +1,19 @@
+2014-02-27  Anders Carlsson  <andersca@apple.com>
+
+        Look up already existing VisitedLinkTableController objects by identifier
+        https://bugs.webkit.org/show_bug.cgi?id=129431
+
+        Reviewed by Dan Bernstein.
+
+        * WebProcess/WebPage/VisitedLinkTableController.cpp:
+        (WebKit::visitedLinkTableControllers):
+        (WebKit::VisitedLinkTableController::getOrCreate):
+        (WebKit::VisitedLinkTableController::VisitedLinkTableController):
+        (WebKit::VisitedLinkTableController::~VisitedLinkTableController):
+        * WebProcess/WebPage/VisitedLinkTableController.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+
 2014-02-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK][WK2] Blocks when fetching plugins information
index 088a196..d7721bb 100644 (file)
 #include "VisitedLinkTableController.h"
 
 #include "WebProcess.h"
+#include <wtf/NeverDestroyed.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
-PassRefPtr<VisitedLinkTableController> VisitedLinkTableController::create()
+static HashMap<uint64_t, VisitedLinkTableController*>& visitedLinkTableControllers()
 {
-    return adoptRef(new VisitedLinkTableController);
+    static NeverDestroyed<HashMap<uint64_t, VisitedLinkTableController*>> visitedLinkTableControllers;
+
+    return visitedLinkTableControllers;
 }
 
-VisitedLinkTableController::VisitedLinkTableController()
+PassRefPtr<VisitedLinkTableController> VisitedLinkTableController::getOrCreate(uint64_t identifier)
+{
+    auto& visitedLinkTableControllerPtr = visitedLinkTableControllers().add(identifier, nullptr).iterator->value;
+    if (visitedLinkTableControllerPtr)
+        return visitedLinkTableControllerPtr;
+
+    RefPtr<VisitedLinkTableController> visitedLinkTableController = adoptRef(new VisitedLinkTableController(identifier));
+    visitedLinkTableControllerPtr = visitedLinkTableController.get();
+
+    return visitedLinkTableController.release();
+}
+
+VisitedLinkTableController::VisitedLinkTableController(uint64_t identifier)
+    : m_identifier(identifier)
 {
 }
 
 VisitedLinkTableController::~VisitedLinkTableController()
 {
+    ASSERT(visitedLinkTableControllers().contains(m_identifier));
+
+    visitedLinkTableControllers().remove(m_identifier);
 }
 
 bool VisitedLinkTableController::isLinkVisited(Page&, LinkHash linkHash, const URL&, const AtomicString&)
index 226e99c..0be6c60 100644 (file)
@@ -32,14 +32,16 @@ namespace WebKit {
 
 class VisitedLinkTableController final : public WebCore::VisitedLinkStore {
 public:
-    static PassRefPtr<VisitedLinkTableController> create();
+    static PassRefPtr<VisitedLinkTableController> getOrCreate(uint64_t identifier);
     virtual ~VisitedLinkTableController();
 
 private:
-    VisitedLinkTableController();
+    explicit VisitedLinkTableController(uint64_t identifier);
 
     virtual bool isLinkVisited(WebCore::Page&, WebCore::LinkHash, const WebCore::URL& baseURL, const AtomicString& attributeURL) override;
     virtual void addVisitedLink(WebCore::Page&, WebCore::LinkHash) override;
+
+    uint64_t m_identifier;
 };
 
 } // namepsace WebKit
index fdbffca..d86667a 100644 (file)
@@ -325,7 +325,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     pageClients.loaderClientForMainFrame = new WebFrameLoaderClient;
     pageClients.progressTrackerClient = new WebProgressTrackerClient(*this);
 
-    pageClients.visitedLinkStore = VisitedLinkTableController::create();
+    pageClients.visitedLinkStore = VisitedLinkTableController::getOrCreate(parameters.visitedLinkTableID);
 
     m_page = adoptPtr(new Page(pageClients));