Title: [218172] trunk/Source/WebKit2
Revision
218172
Author
carlo...@webkit.org
Date
2017-06-13 03:31:38 -0700 (Tue, 13 Jun 2017)

Log Message

[GTK] Use API::IconDatabaseClient in WebKitFaviconDatabase
https://bugs.webkit.org/show_bug.cgi?id=173146

Reviewed by Žan Doberšek.

* UIProcess/API/gtk/WebKitFaviconDatabase.cpp:
(_WebKitFaviconDatabasePrivate::~_WebKitFaviconDatabasePrivate):
(webkitFaviconDatabaseCreate):
(didChangeIconForPageURLCallback): Deleted.
(iconDataReadyForPageURLCallback): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218171 => 218172)


--- trunk/Source/WebKit2/ChangeLog	2017-06-13 10:30:26 UTC (rev 218171)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-13 10:31:38 UTC (rev 218172)
@@ -1,5 +1,18 @@
 2017-06-13  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [GTK] Use API::IconDatabaseClient in WebKitFaviconDatabase
+        https://bugs.webkit.org/show_bug.cgi?id=173146
+
+        Reviewed by Žan Doberšek.
+
+        * UIProcess/API/gtk/WebKitFaviconDatabase.cpp:
+        (_WebKitFaviconDatabasePrivate::~_WebKitFaviconDatabasePrivate):
+        (webkitFaviconDatabaseCreate):
+        (didChangeIconForPageURLCallback): Deleted.
+        (iconDataReadyForPageURLCallback): Deleted.
+
+2017-06-13  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK] Use API::InjectedBundle::PageLoaderClient in WebKitWebPage
         https://bugs.webkit.org/show_bug.cgi?id=173304
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp (218171 => 218172)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp	2017-06-13 10:30:26 UTC (rev 218171)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp	2017-06-13 10:31:38 UTC (rev 218172)
@@ -67,6 +67,11 @@
 typedef HashMap<String, PendingIconRequestVector*> PendingIconRequestMap;
 
 struct _WebKitFaviconDatabasePrivate {
+    ~_WebKitFaviconDatabasePrivate()
+    {
+        iconDatabase->setClient(nullptr);
+    }
+
     RefPtr<WebIconDatabase> iconDatabase;
     PendingIconRequestMap pendingIconRequests;
     HashMap<String, String> pageURLToIconURLMap;
@@ -179,49 +184,48 @@
     deletePendingIconRequests(database, pendingIconRequests, pageURL);
 }
 
-static void didChangeIconForPageURLCallback(WKIconDatabaseRef, WKURLRef wkPageURL, const void* clientInfo)
-{
-    WebKitFaviconDatabase* database = WEBKIT_FAVICON_DATABASE(clientInfo);
-    if (!database->priv->iconDatabase->isUrlImportCompleted())
-        return;
+class WebKitIconDatabaseClient final : public API::IconDatabaseClient {
+public:
+    explicit WebKitIconDatabaseClient(WebKitFaviconDatabase* database)
+        : m_database(database)
+    {
+    }
 
-    // Wait until there's an icon record in the database for this page URL.
-    String pageURL = toImpl(wkPageURL)->string();
-    WebCore::Image* iconImage = database->priv->iconDatabase->imageForPageURL(pageURL, WebCore::IntSize(1, 1));
-    if (!iconImage || iconImage->isNull())
-        return;
+private:
+    void didChangeIconForPageURL(WebIconDatabase&, const String& pageURL) override
+    {
+        if (!m_database->priv->iconDatabase->isUrlImportCompleted())
+            return;
 
-    String currentIconURL;
-    database->priv->iconDatabase->synchronousIconURLForPageURL(pageURL, currentIconURL);
-    const String& iconURL = database->priv->pageURLToIconURLMap.get(pageURL);
-    if (iconURL == currentIconURL)
-        return;
+        // Wait until there's an icon record in the database for this page URL.
+        WebCore::Image* iconImage = m_database->priv->iconDatabase->imageForPageURL(pageURL, WebCore::IntSize(1, 1));
+        if (!iconImage || iconImage->isNull())
+            return;
 
-    database->priv->pageURLToIconURLMap.set(pageURL, currentIconURL);
-    g_signal_emit(database, signals[FAVICON_CHANGED], 0, pageURL.utf8().data(), currentIconURL.utf8().data());
-}
+        String currentIconURL;
+        m_database->priv->iconDatabase->synchronousIconURLForPageURL(pageURL, currentIconURL);
+        const String& iconURL = m_database->priv->pageURLToIconURLMap.get(pageURL);
+        if (iconURL == currentIconURL)
+            return;
 
-static void iconDataReadyForPageURLCallback(WKIconDatabaseRef, WKURLRef wkPageURL, const void* clientInfo)
-{
-    ASSERT(RunLoop::isMain());
-    processPendingIconsForPageURL(WEBKIT_FAVICON_DATABASE(clientInfo), toImpl(wkPageURL)->string());
-}
+        m_database->priv->pageURLToIconURLMap.set(pageURL, currentIconURL);
+        g_signal_emit(m_database, signals[FAVICON_CHANGED], 0, pageURL.utf8().data(), currentIconURL.utf8().data());
+    }
 
+    void iconDataReadyForPageURL(WebIconDatabase&, const String& pageURL) override
+    {
+        ASSERT(RunLoop::isMain());
+        processPendingIconsForPageURL(m_database, pageURL);
+    }
+
+    WebKitFaviconDatabase* m_database;
+};
+
 WebKitFaviconDatabase* webkitFaviconDatabaseCreate(WebIconDatabase* iconDatabase)
 {
     WebKitFaviconDatabase* faviconDatabase = WEBKIT_FAVICON_DATABASE(g_object_new(WEBKIT_TYPE_FAVICON_DATABASE, NULL));
     faviconDatabase->priv->iconDatabase = iconDatabase;
-
-    WKIconDatabaseClientV1 wkIconDatabaseClient = {
-        {
-            1, // version
-            faviconDatabase, // clientInfo
-        },
-        didChangeIconForPageURLCallback,
-        0, // didRemoveAllIconsCallback
-        iconDataReadyForPageURLCallback,
-    };
-    WKIconDatabaseSetIconDatabaseClient(toAPI(iconDatabase), &wkIconDatabaseClient.base);
+    iconDatabase->setClient(std::make_unique<WebKitIconDatabaseClient>(faviconDatabase));
     return faviconDatabase;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to