Commit 3b040610 authored by beidson@apple.com's avatar beidson@apple.com

https://bugs.webkit.org/show_bug.cgi?id=57058

Hookup the UIProcess WebIconDatabase to a WebCore::IconDatabase as its implementation

Reviewed by Sam Weinig.

../WebCore: 

* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::synchronousLoadDecisionForIconURL): Only add the DocumentLoader to the set if it's non-zero.
(WebCore::IconDatabase::IconDatabase): Add more logging.
(WebCore::IconDatabase::performURLImport): Dispatch the "didFinishURLImport" client callback using the following 3 methods.
(WebCore::FinishedURLImport::FinishedURLImport):
(WebCore::FinishedURLImport::performWork):
(WebCore::IconDatabase::dispatchDidFinishURLImportOnMainThread):

* loader/icon/IconDatabase.h:
(WebCore::IconDatabase::create): Expose a PassOwnPtr<> creator.

* WebCore.exp.in:

../WebKit2: 

* UIProcess/WebIconDatabase.cpp:
(WebKit::WebIconDatabase::WebIconDatabase):
(WebKit::WebIconDatabase::setDatabasePath): Create a new WebCore::IconDatabase and open it to this path.
(WebKit::WebIconDatabase::retainIconForPageURL): Actually retain the url, using the impl.
(WebKit::WebIconDatabase::releaseIconForPageURL): Actually release the url, using the impl.
(WebKit::WebIconDatabase::setIconURLForPageURL): Actually set the url, using the impl.
(WebKit::WebIconDatabase::setIconDataForIconURL): Actually set the data, using the impl.
(WebKit::WebIconDatabase::getLoadDecisionForIconURL): Actually ask for a load decision to call back with.
(WebKit::WebIconDatabase::performImport):
(WebKit::WebIconDatabase::didImportIconURLForPageURL):
(WebKit::WebIconDatabase::didImportIconDataForPageURL):
(WebKit::WebIconDatabase::didChangeIconForPageURL):
(WebKit::WebIconDatabase::didRemoveAllIcons):
(WebKit::WebIconDatabase::didFinishURLImport): Notify all the pending callbacks what their load decisions
  are now that they're available.
* UIProcess/WebIconDatabase.h:

Add an IconDatabase logging channel:
* Platform/Logging.cpp:
(WebKit::initializeLogChannelsIfNecessary):
* Platform/Logging.h:

* UIProcess/WebContext.cpp:
(WebKit::WebContext::setIconDatabasePath): Pass the new path on to the WebIconDatabase, possibly
  opening it.
* UIProcess/WebContext.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@81920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d2eda92e
2011-03-24 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig.
https://bugs.webkit.org/show_bug.cgi?id=57058
Hookup the UIProcess WebIconDatabase to a WebCore::IconDatabase as its implementation
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::synchronousLoadDecisionForIconURL): Only add the DocumentLoader to the set if it's non-zero.
(WebCore::IconDatabase::IconDatabase): Add more logging.
(WebCore::IconDatabase::performURLImport): Dispatch the "didFinishURLImport" client callback using the following 3 methods.
(WebCore::FinishedURLImport::FinishedURLImport):
(WebCore::FinishedURLImport::performWork):
(WebCore::IconDatabase::dispatchDidFinishURLImportOnMainThread):
* loader/icon/IconDatabase.h:
(WebCore::IconDatabase::create): Expose a PassOwnPtr<> creator.
* WebCore.exp.in:
2011-03-23 Jer Noble <jer.noble@apple.com>
Reviewed by Maciej Stachowiak.
......@@ -262,6 +262,7 @@ __ZN7WebCore12IconDatabase25setPrivateBrowsingEnabledEb
__ZN7WebCore12IconDatabase27checkIntegrityBeforeOpeningEv
__ZN7WebCore12IconDatabase5closeEv
__ZN7WebCore12IconDatabase9setClientEPNS_18IconDatabaseClientE
__ZN7WebCore12IconDatabaseC1Ev
__ZN7WebCore12PopupMenuMacC1EPNS_15PopupMenuClientE
__ZN7WebCore12PrintContext12pagePropertyEPNS_5FrameEPKci
__ZN7WebCore12PrintContext13numberOfPagesEPNS_5FrameERKNS_9FloatSizeE
......@@ -288,6 +289,7 @@ __ZN7WebCore12SharedBuffer12createNSDataEv
__ZN7WebCore12SharedBuffer24createWithContentsOfFileERKN3WTF6StringE
__ZN7WebCore12SharedBuffer6appendEPKcj
__ZN7WebCore12SharedBufferC1EPKci
__ZN7WebCore12SharedBufferC1EPKhi
__ZN7WebCore12SharedBufferC1Ev
__ZN7WebCore12SharedBufferD1Ev
__ZN7WebCore12SpellChecker8didCheckEiRKN3WTF6VectorINS_19SpellCheckingResultELm0EEE
......@@ -321,6 +323,7 @@ __ZN7WebCore13ResourceErrorC1EP7NSError
__ZN7WebCore13ResourceErrorC1EP9__CFError
__ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8DocumentE
__ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE
__ZN7WebCore13directoryNameERKN3WTF6StringE
__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
__ZN7WebCore13toHTMLElementEPNS_21FormAssociatedElementE
__ZN7WebCore13toJSDOMWindowEN3JSC7JSValueE
......@@ -417,6 +420,7 @@ __ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontE
__ZN7WebCore15VisiblePositionC1ERKNS_8PositionENS_9EAffinityE
__ZN7WebCore15defaultLanguageEv
__ZN7WebCore15localizedStringEPKc
__ZN7WebCore15pathGetFileNameERKN3WTF6StringE
__ZN7WebCore15reportExceptionEPN3JSC9ExecStateENS0_7JSValueE
__ZN7WebCore15visitedLinkHashEPKtj
__ZN7WebCore16AbstractDatabase14setIsAvailableEb
......
......@@ -662,7 +662,8 @@ IconLoadDecision IconDatabase::synchronousLoadDecisionForIconURL(const String& i
// Otherwise - since we refuse to perform I/O on the main thread to find out for sure - we return the answer that says
// "You might be asked to load this later, so flag that"
LOG(IconDatabase, "Don't know if we should load %s or not - adding %p to the set of document loaders waiting on a decision", iconURL.ascii().data(), notificationDocumentLoader);
m_loadersPendingDecision.add(notificationDocumentLoader);
if (notificationDocumentLoader)
m_loadersPendingDecision.add(notificationDocumentLoader);
return IconLoadUnknown;
}
......@@ -770,6 +771,7 @@ IconDatabase::IconDatabase()
, m_imported(false)
, m_isImportedSet(false)
{
LOG(IconDatabase, "Creating IconDatabase %p", this);
ASSERT(isMainThread());
}
......@@ -1287,7 +1289,6 @@ void IconDatabase::performURLImport()
// Loop through the urls pending import
// Remove unretained ones if database cleanup is allowed
// Keep a set of ones that are retained and pending notification
{
MutexLocker locker(m_urlAndIconLock);
......@@ -1333,6 +1334,9 @@ void IconDatabase::performURLImport()
pool.cycle();
}
// Notify the client that the URL import is complete in case it's managing its own pending notifications.
dispatchDidFinishURLImportOnMainThread();
// Notify all DocumentLoaders that were waiting for an icon load decision on the main thread
callOnMainThread(notifyPendingLoadDecisionsOnMainThread, this);
}
......@@ -2178,6 +2182,20 @@ public:
}
};
class FinishedURLImport : public ClientWorkItem {
public:
FinishedURLImport(IconDatabaseClient* client)
: ClientWorkItem(client)
{ }
virtual void performWork()
{
ASSERT(m_client);
m_client->didFinishURLImport();
m_client = 0;
}
};
static void performWorkItem(void* context)
{
ClientWorkItem* item = static_cast<ClientWorkItem*>(context);
......@@ -2209,6 +2227,14 @@ void IconDatabase::dispatchDidRemoveAllIconsOnMainThread()
callOnMainThread(performWorkItem, work);
}
void IconDatabase::dispatchDidFinishURLImportOnMainThread()
{
ASSERT_ICON_SYNC_THREAD();
FinishedURLImport* work = new FinishedURLImport(m_client);
callOnMainThread(performWorkItem, work);
}
} // namespace WebCore
......
......@@ -73,6 +73,9 @@ class IconDatabase : public IconDatabaseBase {
// *** Main Thread Only ***
public:
static PassOwnPtr<IconDatabase> create() { return new IconDatabase; }
~IconDatabase();
virtual void setClient(IconDatabaseClient*);
virtual bool open(const String& directory, const String& filename);
......@@ -112,7 +115,6 @@ public:
private:
IconDatabase();
~IconDatabase();
friend IconDatabaseBase& iconDatabase();
static void notifyPendingLoadDecisionsOnMainThread(void*);
......@@ -219,6 +221,7 @@ private:
void dispatchDidImportIconURLForPageURLOnMainThread(const String&);
void dispatchDidImportIconDataForPageURLOnMainThread(const String&);
void dispatchDidRemoveAllIconsOnMainThread();
void dispatchDidFinishURLImportOnMainThread();
// The client is set by the main thread before the thread starts, and from then on is only used by the sync thread
IconDatabaseClient* m_client;
......
2011-03-24 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig.
https://bugs.webkit.org/show_bug.cgi?id=57058
Hookup the UIProcess WebIconDatabase to a WebCore::IconDatabase as its implementation
* UIProcess/WebIconDatabase.cpp:
(WebKit::WebIconDatabase::WebIconDatabase):
(WebKit::WebIconDatabase::setDatabasePath): Create a new WebCore::IconDatabase and open it to this path.
(WebKit::WebIconDatabase::retainIconForPageURL): Actually retain the url, using the impl.
(WebKit::WebIconDatabase::releaseIconForPageURL): Actually release the url, using the impl.
(WebKit::WebIconDatabase::setIconURLForPageURL): Actually set the url, using the impl.
(WebKit::WebIconDatabase::setIconDataForIconURL): Actually set the data, using the impl.
(WebKit::WebIconDatabase::getLoadDecisionForIconURL): Actually ask for a load decision to call back with.
(WebKit::WebIconDatabase::performImport):
(WebKit::WebIconDatabase::didImportIconURLForPageURL):
(WebKit::WebIconDatabase::didImportIconDataForPageURL):
(WebKit::WebIconDatabase::didChangeIconForPageURL):
(WebKit::WebIconDatabase::didRemoveAllIcons):
(WebKit::WebIconDatabase::didFinishURLImport): Notify all the pending callbacks what their load decisions
are now that they're available.
* UIProcess/WebIconDatabase.h:
Add an IconDatabase logging channel:
* Platform/Logging.cpp:
(WebKit::initializeLogChannelsIfNecessary):
* Platform/Logging.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::setIconDatabasePath): Pass the new path on to the WebIconDatabase, possibly
opening it.
* UIProcess/WebContext.h:
2011-03-24 Andy Estes <aestes@apple.com>
Reviewed by Darin Adler.
......
......@@ -34,6 +34,7 @@ WTFLogChannel LogSessionState = { 0x00000001, "WebKit2LogLevel", WTFLogChannelOf
WTFLogChannel LogContextMenu = { 0x00000002, "WebKit2LogLevel", WTFLogChannelOff };
WTFLogChannel LogTextInput = { 0x00000004, "WebKit2LogLevel", WTFLogChannelOff };
WTFLogChannel LogView = { 0x00000008, "WebKit2LogLevel", WTFLogChannelOff };
WTFLogChannel LogIconDatabase = { 0x00000010, "WebKit2LogLevel", WTFLogChannelOff };
#if !PLATFORM(MAC)
void initializeLogChannel(WTFLogChannel* channel)
......@@ -50,6 +51,7 @@ void initializeLogChannelsIfNecessary()
haveInitializedLogChannels = true;
initializeLogChannel(&LogContextMenu);
initializeLogChannel(&LogIconDatabase);
initializeLogChannel(&LogSessionState);
initializeLogChannel(&LogTextInput);
initializeLogChannel(&LogView);
......
......@@ -37,6 +37,7 @@
namespace WebKit {
extern WTFLogChannel LogContextMenu;
extern WTFLogChannel LogIconDatabase;
extern WTFLogChannel LogSessionState;
extern WTFLogChannel LogTextInput;
extern WTFLogChannel LogView;
......
......@@ -771,6 +771,12 @@ String WebContext::databaseDirectory() const
return platformDefaultDatabaseDirectory();
}
void WebContext::setIconDatabasePath(const String& path)
{
m_overrideIconDatabasePath = path;
m_iconDatabase->setDatabasePath(path);
}
String WebContext::iconDatabasePath() const
{
if (!m_overrideIconDatabasePath.isEmpty())
......
......@@ -158,7 +158,7 @@ public:
static Statistics& statistics();
void setDatabaseDirectory(const String& dir) { m_overrideDatabaseDirectory = dir; }
void setIconDatabasePath(const String& path) { m_overrideIconDatabasePath = path; }
void setIconDatabasePath(const String&);
void setLocalStorageDirectory(const String& dir) { m_overrideLocalStorageDirectory = dir; }
void ensureWebProcess();
......
......@@ -27,10 +27,16 @@
#include "WebIconDatabase.h"
#include "DataReference.h"
#include "Logging.h"
#include "WebContext.h"
#include "WebIconDatabaseProxyMessages.h"
#include <WebCore/FileSystem.h>
#include <WebCore/IconDatabase.h>
#include <WebCore/IconDatabaseBase.h>
#include <wtf/text/WTFString.h>
using namespace WebCore;
namespace WebKit {
PassRefPtr<WebIconDatabase> WebIconDatabase::create(WebContext* context)
......@@ -44,6 +50,7 @@ WebIconDatabase::~WebIconDatabase()
WebIconDatabase::WebIconDatabase(WebContext* context)
: m_webContext(context)
, m_urlImportCompleted(false)
{
}
......@@ -51,20 +58,53 @@ void WebIconDatabase::invalidate()
{
}
void WebIconDatabase::retainIconForPageURL(const String&)
void WebIconDatabase::setDatabasePath(const String& path)
{
if (m_iconDatabaseImpl && m_iconDatabaseImpl->isOpen()) {
LOG_ERROR("Icon database already has a path and is already open. We don't currently support changing its path and reopening.");
return;
}
m_iconDatabaseImpl = IconDatabase::create();
m_iconDatabaseImpl->setClient(this);
m_iconDatabaseImpl->setEnabled(true);
if (!m_iconDatabaseImpl->open(directoryName(path), pathGetFileName(path))) {
LOG_ERROR("Unable to open WebKit2 icon database on disk");
m_iconDatabaseImpl.clear();
setGlobalIconDatabase(0);
}
setGlobalIconDatabase(m_iconDatabaseImpl.get());
}
void WebIconDatabase::retainIconForPageURL(const String& pageURL)
{
LOG(IconDatabase, "WK2 UIProcess retaining icon for page URL %s", pageURL.ascii().data());
if (m_iconDatabaseImpl)
m_iconDatabaseImpl->retainIconForPageURL(pageURL);
}
void WebIconDatabase::releaseIconForPageURL(const String&)
void WebIconDatabase::releaseIconForPageURL(const String& pageURL)
{
LOG(IconDatabase, "WK2 UIProcess releasing icon for page URL %s", pageURL.ascii().data());
if (m_iconDatabaseImpl)
m_iconDatabaseImpl->releaseIconForPageURL(pageURL);
}
void WebIconDatabase::setIconURLForPageURL(const String&, const String&)
void WebIconDatabase::setIconURLForPageURL(const String& iconURL, const String& pageURL)
{
LOG(IconDatabase, "WK2 UIProcess setting icon URL %s for page URL %s", iconURL.ascii().data(), pageURL.ascii().data());
if (m_iconDatabaseImpl)
m_iconDatabaseImpl->setIconURLForPageURL(iconURL, pageURL);
}
void WebIconDatabase::setIconDataForIconURL(const CoreIPC::DataReference&, const String&)
void WebIconDatabase::setIconDataForIconURL(const CoreIPC::DataReference& iconData, const String& iconURL)
{
LOG(IconDatabase, "WK2 UIProcess setting icon data (%i bytes) for page URL %s", (int)iconData.size(), iconURL.ascii().data());
if (!m_iconDatabaseImpl)
return;
RefPtr<SharedBuffer> buffer = SharedBuffer::create(iconData.data(), iconData.size());
m_iconDatabaseImpl->setIconDataForIconURL(buffer.release(), iconURL);
}
void WebIconDatabase::synchronousIconDataForPageURL(const String&, CoreIPC::DataReference& iconData)
......@@ -84,17 +124,86 @@ void WebIconDatabase::synchronousIconDataKnownForIconURL(const String&, bool& ic
void WebIconDatabase::synchronousLoadDecisionForIconURL(const String&, int& loadDecision) const
{
loadDecision = static_cast<int>(WebCore::IconLoadNo);
loadDecision = static_cast<int>(IconLoadNo);
}
void WebIconDatabase::getLoadDecisionForIconURL(const String& iconURL, uint64_t callbackID)
{
LOG(IconDatabase, "WK2 UIProcess getting load decision for icon URL %s with callback ID %lli", iconURL.ascii().data(), callbackID);
if (!m_webContext)
return;
if (!m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || iconURL.isEmpty()) {
m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(IconLoadNo), callbackID), 0);
return;
}
// If the decision hasn't been read from disk yet, set this url and callback ID aside to be notifed later
IconLoadDecision decision = m_iconDatabaseImpl->synchronousLoadDecisionForIconURL(iconURL, 0);
if (decision == IconLoadUnknown) {
// We should never get an unknown load decision after the URL import has completed.
ASSERT(!m_urlImportCompleted);
m_pendingLoadDecisionURLMap.set(callbackID, iconURL);
return;
}
m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision((int)decision, callbackID), 0);
}
// WebCore::IconDatabaseClient
bool WebIconDatabase::performImport()
{
// WebKit2 icon database doesn't currently support importing any old icon database formats.
return true;
}
void WebIconDatabase::didImportIconURLForPageURL(const String&)
{
// Send a WK2 client notification out here.
}
void WebIconDatabase::didImportIconDataForPageURL(const String&)
{
// Send a WK2 client notification out here.
}
void WebIconDatabase::didChangeIconForPageURL(const String&)
{
// Send a WK2 client notification out here.
}
void WebIconDatabase::didRemoveAllIcons()
{
// Send a WK2 client notification out here.
}
void WebIconDatabase::didFinishURLImport()
{
if (!m_webContext)
return;
ASSERT(!m_urlImportCompleted);
LOG(IconDatabase, "WK2 UIProcess URL import complete, notifying all %i pending page URL load decisions", m_pendingLoadDecisionURLMap.size());
// FIXME: Hookup to the real IconDatabase implementation.
HashMap<uint64_t, String>::iterator i = m_pendingLoadDecisionURLMap.begin();
HashMap<uint64_t, String>::iterator end = m_pendingLoadDecisionURLMap.end();
for (; i != end; ++i) {
LOG(IconDatabase, "WK2 UIProcess performing delayed callback on callback ID %i for page url %s", (int)i->first, i->second.ascii().data());
IconLoadDecision decision = m_iconDatabaseImpl->synchronousLoadDecisionForIconURL(i->second, 0);
// Decisions should never be unknown after the inital import is complete
ASSERT(decision != IconLoadUnknown);
m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(decision), i->first), 0);
}
m_pendingLoadDecisionURLMap.clear();
m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(WebCore::IconLoadNo), callbackID), 0);
m_urlImportCompleted = true;
}
void WebIconDatabase::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* decoder)
......
......@@ -29,11 +29,12 @@
#include "APIObject.h"
#include "Connection.h"
#include <WebCore/IconDatabaseBase.h>
#include <WebCore/IconDatabaseClient.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
namespace CoreIPC {
class ArgumentDecoder;
......@@ -41,11 +42,15 @@ class DataReference;
class MessageID;
}
namespace WebCore {
class IconDatabase;
}
namespace WebKit {
class WebContext;
class WebIconDatabase : public APIObject {
class WebIconDatabase : public APIObject, public WebCore::IconDatabaseClient {
public:
static const Type APIType = TypeIconDatabase;
......@@ -54,6 +59,7 @@ public:
void invalidate();
void clearContext() { m_webContext = 0; }
void setDatabasePath(const String&);
void retainIconForPageURL(const String&);
void releaseIconForPageURL(const String&);
......@@ -67,6 +73,14 @@ public:
void getLoadDecisionForIconURL(const String&, uint64_t callbackID);
// WebCore::IconDatabaseClient
virtual bool performImport();
virtual void didImportIconURLForPageURL(const String&);
virtual void didImportIconDataForPageURL(const String&);
virtual void didChangeIconForPageURL(const String&);
virtual void didRemoveAllIcons();
virtual void didFinishURLImport();
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
......@@ -79,6 +93,11 @@ private:
CoreIPC::SyncReplyMode didReceiveSyncWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
WebContext* m_webContext;
OwnPtr<WebCore::IconDatabase> m_iconDatabaseImpl;
bool m_urlImportCompleted;
HashMap<uint64_t, String> m_pendingLoadDecisionURLMap;
};
} // namespace WebKit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment