2011-03-22 Brady Eidson <beidson@apple.com>
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Mar 2011 17:26:32 +0000 (17:26 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Mar 2011 17:26:32 +0000 (17:26 +0000)
        Reviewed by Sam Weinig.

        Add asynchronous load decision call to WebKit2 IconDatabase
        https://bugs.webkit.org/show_bug.cgi?id=56887

        Clear the callback when it's made:
        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::continueIconLoadWithDecision):

        Don't load icons when using new-style icon database if in private browsing:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::continueIconLoadWithDecision):

        Enhance the IconDatabase callbacks to have an ID and inherit from a common base:
        * loader/icon/IconDatabaseBase.h:
        (WebCore::CallbackBase::~CallbackBase):
        (WebCore::CallbackBase::callbackID):
        (WebCore::CallbackBase::CallbackBase):
        (WebCore::CallbackBase::context):
        (WebCore::CallbackBase::generateCallbackID):
        (WebCore::EnumCallback::performCallback):
        (WebCore::EnumCallback::EnumCallback):
        (WebCore::ObjectCallback::performCallback):
        (WebCore::ObjectCallback::ObjectCallback):
2011-03-22  Brady Eidson  <beidson@apple.com>

        Reviewed by Sam Weinig.

        Add asynchronous load decision call to WebKit2 IconDatabase
        https://bugs.webkit.org/show_bug.cgi?id=56887

        * UIProcess/WebIconDatabase.cpp:
        (WebKit::WebIconDatabase::getLoadDecisionForIconURL): In the future, get the actual load decision from the database.
          For now, always message "IconLoadNo" back to the WebProcess.
        * UIProcess/WebIconDatabase.h:
        * UIProcess/WebIconDatabase.messages.in:

        * WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
        (WebKit::WebIconDatabaseProxy::loadDecisionForIconURL): Message the UIProcess for the load decision.
        (WebKit::WebIconDatabaseProxy::receivedIconLoadDecision): Callback into WebCore with the received load decision.
        * WebProcess/IconDatabase/WebIconDatabaseProxy.h:
        * WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/icon/IconDatabaseBase.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebIconDatabase.cpp
Source/WebKit2/UIProcess/WebIconDatabase.h
Source/WebKit2/UIProcess/WebIconDatabase.messages.in
Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp
Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.h
Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in

index 9b9a4fa9aac1852294c263bcb9eefc9761f62f8e..5ed34f4ab05e7981d1639cea9595c819ec011bbe 100644 (file)
@@ -1,3 +1,30 @@
+2011-03-22  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Add asynchronous load decision call to WebKit2 IconDatabase
+        https://bugs.webkit.org/show_bug.cgi?id=56887
+
+        Clear the callback when it's made:
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::continueIconLoadWithDecision):
+
+        Don't load icons when using new-style icon database if in private browsing:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::continueIconLoadWithDecision):
+        
+        Enhance the IconDatabase callbacks to have an ID and inherit from a common base:
+        * loader/icon/IconDatabaseBase.h:
+        (WebCore::CallbackBase::~CallbackBase):
+        (WebCore::CallbackBase::callbackID):
+        (WebCore::CallbackBase::CallbackBase):
+        (WebCore::CallbackBase::context):
+        (WebCore::CallbackBase::generateCallbackID):
+        (WebCore::EnumCallback::performCallback):
+        (WebCore::EnumCallback::EnumCallback):
+        (WebCore::ObjectCallback::performCallback):
+        (WebCore::ObjectCallback::ObjectCallback):
+
 2011-03-21  Pavel Podivilov  <podivilov@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index 601ddfca54378d0124654d91b2a77ea777a0b21d..121045b5b99ffa079b6059f7e197add4d3dbc3d2 100644 (file)
@@ -858,6 +858,8 @@ void DocumentLoader::getIconLoadDecisionForIconURL(const String& urlString)
 
 void DocumentLoader::continueIconLoadWithDecision(IconLoadDecision decision)
 {
+    ASSERT(m_iconLoadDecisionCallback);
+    m_iconLoadDecisionCallback = 0;
     if (m_frame)
         m_frame->loader()->continueIconLoadWithDecision(decision);
 }
index dde139262670ab78df12ea859bfe0c85625a7e79..045f45dd0fa4c8dec834c641780460c172399a91 100644 (file)
@@ -743,6 +743,10 @@ void FrameLoader::continueIconLoadWithDecision(IconLoadDecision iconLoadDecision
 {
     ASSERT(iconLoadDecision != IconLoadUnknown);
     
+    //  FIXME (<rdar://problem/9168605>) - We should support in-memory-only private browsing icons in asynchronous icon database mode.
+    if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()->privateBrowsingEnabled())
+        return;
+        
     if (iconLoadDecision == IconLoadNo) {
         KURL url(iconURL());
         String urlString(url.string());
index 1cf7a989002763db05c686d2f308fa65700de903..a9f844c44a227ea3af3e241b9dffa63b83b8a094 100644 (file)
@@ -45,8 +45,36 @@ enum IconLoadDecision {
     IconLoadUnknown
 };
 
+class CallbackBase : public RefCounted<CallbackBase> {
+public:
+    virtual ~CallbackBase()
+    {
+    }
+
+    uint64_t callbackID() const { return m_callbackID; }
+
+protected:
+    CallbackBase(void* context)
+        : m_context(context)
+        , m_callbackID(generateCallbackID())
+    {
+    }
+
+    void* context() const { return m_context; }
+
+private:
+    static uint64_t generateCallbackID()
+    {
+        static uint64_t uniqueCallbackID = 1;
+        return uniqueCallbackID++;
+    }
+
+    void* m_context;
+    uint64_t m_callbackID;
+};
+
 template<typename EnumType> 
-class EnumCallback : public RefCounted<EnumCallback<EnumType> > {
+class EnumCallback : public CallbackBase {
 public:
     typedef void (*CallbackFunction)(EnumType, void*);
 
@@ -63,7 +91,7 @@ public:
     void performCallback(EnumType result)
     {
         ASSERT(m_callback);
-        m_callback(result, m_context);
+        m_callback(result, context());
         m_callback = 0;
     }
     
@@ -75,17 +103,16 @@ public:
 
 private:
     EnumCallback(void* context, CallbackFunction callback)
-        : m_context(context)
+        : CallbackBase(context)
         , m_callback(callback)
     {
     }
 
-    void* m_context;
     CallbackFunction m_callback;
 };
 
 template<typename ObjectType> 
-class ObjectCallback : public RefCounted<ObjectCallback<ObjectType> > {
+class ObjectCallback : public CallbackBase {
 public:
     typedef void (*CallbackFunction)(ObjectType, void*);
 
@@ -102,7 +129,7 @@ public:
     void performCallback(ObjectType result)
     {
         ASSERT(m_callback);
-        m_callback(result, m_context);
+        m_callback(result, context());
         m_callback = 0;
     }
     
@@ -114,12 +141,11 @@ public:
 
 private:
     ObjectCallback(void* context, CallbackFunction callback)
-        : m_context(context)
+        : CallbackBase(context)
         , m_callback(callback)
     {
     }
 
-    void* m_context;
     CallbackFunction m_callback;
 };
 
index 1678a065e056cd40ced9a0e919d7ea652d2b6aac..a75f6bb09ce840dd40d2ce2a49d923966d264cde 100644 (file)
@@ -1,3 +1,22 @@
+2011-03-22  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Add asynchronous load decision call to WebKit2 IconDatabase
+        https://bugs.webkit.org/show_bug.cgi?id=56887
+
+        * UIProcess/WebIconDatabase.cpp:
+        (WebKit::WebIconDatabase::getLoadDecisionForIconURL): In the future, get the actual load decision from the database.
+          For now, always message "IconLoadNo" back to the WebProcess.
+        * UIProcess/WebIconDatabase.h:
+        * UIProcess/WebIconDatabase.messages.in:
+        
+        * WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
+        (WebKit::WebIconDatabaseProxy::loadDecisionForIconURL): Message the UIProcess for the load decision.
+        (WebKit::WebIconDatabaseProxy::receivedIconLoadDecision): Callback into WebCore with the received load decision.
+        * WebProcess/IconDatabase/WebIconDatabaseProxy.h:
+        * WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in:
+
 2011-03-23  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Darin Adler.
index e31cdccfe90da6dd4513b092377b276af1dd4fdb..f64c825bc085b0fa259310016c087a392086cbfe 100644 (file)
@@ -27,6 +27,8 @@
 #include "WebIconDatabase.h"
 
 #include "DataReference.h"
+#include "WebContext.h"
+#include "WebIconDatabaseProxyMessages.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
@@ -82,7 +84,17 @@ void WebIconDatabase::synchronousIconDataKnownForIconURL(const String&, bool& ic
 
 void WebIconDatabase::synchronousLoadDecisionForIconURL(const String&, int& loadDecision) const
 {
-    loadDecision = (int)WebCore::IconLoadNo;
+    loadDecision = static_cast<int>(WebCore::IconLoadNo);
+}
+
+void WebIconDatabase::getLoadDecisionForIconURL(const String& iconURL, uint64_t callbackID)
+{
+    if (!m_webContext)
+        return;
+
+    // FIXME: Hookup to the real IconDatabase implementation.
+    
+    m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(WebCore::IconLoadNo), callbackID), 0);
 }
 
 void WebIconDatabase::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* decoder)
index 5619f8db353960aa46e1863d35b3bbd2b35e6bf3..90606b29f80eea69879792504703f23b82b129fc 100644 (file)
@@ -64,6 +64,8 @@ public:
     void synchronousIconURLForPageURL(const String&, String&);
     void synchronousIconDataKnownForIconURL(const String&, bool&) const;
     void synchronousLoadDecisionForIconURL(const String&, int&) const;
+    
+    void getLoadDecisionForIconURL(const String&, uint64_t callbackID);
 
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
     CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
index 99db83762d6b493cbc1772ef398209cb552095c5..b68a0a74223c26b1e7ea9ae81b0ce9aa146fc04f 100644 (file)
@@ -30,4 +30,6 @@ messages -> WebIconDatabase {
     SynchronousIconURLForPageURL(WTF::String pageURL) -> (WTF::String iconURL)
     SynchronousIconDataKnownForIconURL(WTF::String iconURL) -> (bool dataKnown)
     SynchronousLoadDecisionForIconURL(WTF::String iconURL) -> (int loadDecision)
+    
+    GetLoadDecisionForIconURL(WTF::String iconURL, uint64_t callbackID)
 }
index 3fdb7844794995db15de54b2d2e95fe4e27a6e10..02077912b1bdf2ee2fa1ae8326cb8a27b74ab685 100644 (file)
@@ -111,6 +111,17 @@ bool WebIconDatabaseProxy::supportsAsynchronousMode()
 
 void WebIconDatabaseProxy::loadDecisionForIconURL(const String& iconURL, PassRefPtr<WebCore::IconLoadDecisionCallback> callback)
 {
+    uint64_t id = callback->callbackID();
+    m_iconLoadDecisionCallbacks.add(id, callback);
+    
+    m_process->connection()->send(Messages::WebIconDatabase::GetLoadDecisionForIconURL(iconURL, id), 0);
+}
+
+void WebIconDatabaseProxy::receivedIconLoadDecision(int decision, uint64_t callbackID)
+{
+    RefPtr<WebCore::IconLoadDecisionCallback> callback = m_iconLoadDecisionCallbacks.take(callbackID);
+    if (callback)
+        callback->performCallback(static_cast<WebCore::IconLoadDecision>(decision));
 }
 
 void WebIconDatabaseProxy::iconDataForIconURL(const String& iconURL, PassRefPtr<WebCore::IconDataCallback> callback)
index e5b53a158c48c0e172d3d8da08659de6c2508c5a..2096aba4cd311f925f74ed2f108e932a65955691 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <WebCore/IconDatabaseBase.h>
 
+#include <wtf/HashMap.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
@@ -66,6 +67,7 @@ public:
     // Asynchronous calls we should use to replace the above when supported.
     virtual bool supportsAsynchronousMode();
     virtual void loadDecisionForIconURL(const String&, PassRefPtr<WebCore::IconLoadDecisionCallback>);
+    void receivedIconLoadDecision(int decision, uint64_t callbackID);
     virtual void iconDataForIconURL(const String&, PassRefPtr<WebCore::IconDataCallback>);
         
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
@@ -78,6 +80,8 @@ private:
 
     bool m_isEnabled;
     WebProcess* m_process;
+    
+    HashMap<uint64_t, RefPtr<WebCore::IconLoadDecisionCallback> > m_iconLoadDecisionCallbacks;
 };
 
 } // namespace WebKit
index 6413d3d917064013c5c4037ad7e95f2d80aadb3a..049a0d91846a6830c8ed195d3a350b6d8b8b1867 100644 (file)
@@ -22,4 +22,5 @@
 
 messages -> WebIconDatabaseProxy {
     URLImportFinished()
+    ReceivedIconLoadDecision(int loadDecision, uint64_t callbackID)
 }