#ifndef WebIconDatabase_h
#define WebIconDatabase_h
#include "APIObject.h"
#include "Connection.h"
#include "WebIconDatabaseClient.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/IntSize.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;
class DataReference;
class MessageID;
}
namespace WebCore {
class IconDatabase;
class Image;
}
namespace WebKit {
class WebContext;
class WebIconDatabase : public APIObject, public WebCore::IconDatabaseClient {
public:
static const Type APIType = TypeIconDatabase;
static PassRefPtr<WebIconDatabase> create(WebContext*);
virtual ~WebIconDatabase();
void invalidate();
void clearContext() { m_webContext = 0; }
void setDatabasePath(const String&);
void enableDatabaseCleanup();
void retainIconForPageURL(const String&);
void releaseIconForPageURL(const String&);
void setIconURLForPageURL(const String&, const String&);
void setIconDataForIconURL(const CoreIPC::DataReference&, const String&);
void synchronousIconDataForPageURL(const String&, CoreIPC::DataReference&);
void synchronousIconURLForPageURL(const String&, String&);
void synchronousIconDataKnownForIconURL(const String&, bool&) const;
void synchronousLoadDecisionForIconURL(const String&, int&) const;
void getLoadDecisionForIconURL(const String&, uint64_t callbackID);
WebCore::Image* imageForPageURL(const String&, const WebCore::IntSize& iconSize = WebCore::IntSize(32, 32));
void removeAllIcons();
void checkIntegrityBeforeOpening();
void close();
void initializeIconDatabaseClient(const WKIconDatabaseClient*);
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*);
void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
private:
WebIconDatabase(WebContext*);
virtual Type type() const { return APIType; }
void didReceiveWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didReceiveSyncWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
WebContext* m_webContext;
OwnPtr<WebCore::IconDatabase> m_iconDatabaseImpl;
bool m_urlImportCompleted;
bool m_databaseCleanupDisabled;
HashMap<uint64_t, String> m_pendingLoadDecisionURLMap;
WebIconDatabaseClient m_iconDatabaseClient;
};
}
#endif // WebIconDatabase_h