summaryrefslogtreecommitdiffstats
path: root/WebCore/loader/icon
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/loader/icon
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/loader/icon')
-rw-r--r--WebCore/loader/icon/IconDatabase.cpp14
-rw-r--r--WebCore/loader/icon/IconDatabaseClient.h3
-rw-r--r--WebCore/loader/icon/IconFetcher.cpp20
-rw-r--r--WebCore/loader/icon/IconLoader.cpp16
-rw-r--r--WebCore/loader/icon/IconRecord.cpp3
5 files changed, 30 insertions, 26 deletions
diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp
index 72e57fe..5705f7a 100644
--- a/WebCore/loader/icon/IconDatabase.cpp
+++ b/WebCore/loader/icon/IconDatabase.cpp
@@ -40,9 +40,10 @@
#include "PageURLRecord.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
-#include "SystemTime.h"
#include <runtime/InitializeThreading.h>
+#include <wtf/CurrentTime.h>
#include <wtf/MainThread.h>
+#include <wtf/StdLibExtras.h>
#if PLATFORM(WIN_OS)
#include <windows.h>
@@ -56,8 +57,6 @@
#include <pthread.h>
#endif
-#include <errno.h>
-
// For methods that are meant to support API from the main thread - should not be called internally
#define ASSERT_NOT_SYNC_THREAD() ASSERT(!m_syncThreadRunning || !IS_ICON_SYNC_THREAD())
@@ -180,6 +179,9 @@ void IconDatabase::close()
m_syncThreadRunning = false;
m_threadTerminationRequested = false;
m_removeIconsRequested = false;
+
+ m_syncDB.close();
+ ASSERT(!isOpen());
}
void IconDatabase::removeAllIcons()
@@ -385,7 +387,7 @@ static inline void loadDefaultIconRecord(IconRecord* defaultIconRecord)
0x00, 0x00, 0x01, 0x52, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x0A,
0xFC, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x0A, 0xFC, 0x80, 0x00, 0x00, 0x27, 0x10 };
- static RefPtr<SharedBuffer> defaultIconBuffer(SharedBuffer::create(defaultIconData, sizeof(defaultIconData)));
+ DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, defaultIconBuffer, (SharedBuffer::create(defaultIconData, sizeof(defaultIconData))));
defaultIconRecord->setImageData(defaultIconBuffer);
}
#endif
@@ -855,7 +857,7 @@ String IconDatabase::databasePath() const
String IconDatabase::defaultDatabaseFilename()
{
- static String defaultDatabaseFilename = "WebpageIcons.db";
+ DEFINE_STATIC_LOCAL(String, defaultDatabaseFilename, ("WebpageIcons.db"));
return defaultDatabaseFilename.copy();
}
@@ -1359,7 +1361,7 @@ void* IconDatabase::syncThreadMainLoop()
bool didWrite = writeToDatabase();
if (shouldStopThreadActivity())
break;
-
+
didAnyWork = readFromDatabase();
if (shouldStopThreadActivity())
break;
diff --git a/WebCore/loader/icon/IconDatabaseClient.h b/WebCore/loader/icon/IconDatabaseClient.h
index e642895..8806406 100644
--- a/WebCore/loader/icon/IconDatabaseClient.h
+++ b/WebCore/loader/icon/IconDatabaseClient.h
@@ -41,8 +41,9 @@ public:
virtual ~IconDatabaseClient() { }
virtual bool performImport() { return true; }
virtual void dispatchDidRemoveAllIcons() { }
- virtual void dispatchDidAddIconForPageURL(const String& pageURL) { }
+ virtual void dispatchDidAddIconForPageURL(const String& /*pageURL*/) { }
};
} // namespace WebCore
+
#endif
diff --git a/WebCore/loader/icon/IconFetcher.cpp b/WebCore/loader/icon/IconFetcher.cpp
index efa7e14..69eeb7c 100644
--- a/WebCore/loader/icon/IconFetcher.cpp
+++ b/WebCore/loader/icon/IconFetcher.cpp
@@ -26,16 +26,12 @@
#include "config.h"
#include "IconFetcher.h"
-#include "Document.h"
#include "Frame.h"
#include "HTMLHeadElement.h"
#include "HTMLLinkElement.h"
#include "HTMLNames.h"
-#include "MIMETypeRegistry.h"
#include "ResourceHandle.h"
#include "ResourceRequest.h"
-#include "SharedBuffer.h"
-#include <wtf/PassRefPtr.h>
namespace WebCore {
@@ -164,7 +160,7 @@ void IconFetcher::cancel()
if (m_handle)
m_handle->cancel();
}
-
+
PassRefPtr<SharedBuffer> IconFetcher::createIcon()
{
ASSERT(!m_entries.isEmpty());
@@ -172,8 +168,7 @@ PassRefPtr<SharedBuffer> IconFetcher::createIcon()
// For now, just return the data of the first entry.
return m_entries.first().buffer();
}
-
-
+
void IconFetcher::loadEntry()
{
ASSERT(m_currentEntry < m_entries.size());
@@ -191,7 +186,7 @@ void IconFetcher::loadFailed()
void IconFetcher::didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response)
{
- ASSERT(m_handle == handle);
+ ASSERT_UNUSED(handle, m_handle == handle);
int statusCode = response.httpStatusCode() / 100;
if (statusCode == 4 || statusCode == 5) {
@@ -200,16 +195,16 @@ void IconFetcher::didReceiveResponse(ResourceHandle* handle, const ResourceRespo
}
}
-void IconFetcher::didReceiveData(ResourceHandle* handle, const char* data, int length, int lengthReceived)
+void IconFetcher::didReceiveData(ResourceHandle* handle, const char* data, int length, int)
{
- ASSERT(m_handle == handle);
+ ASSERT_UNUSED(handle, m_handle == handle);
m_entries[m_currentEntry].buffer()->append(data, length);
}
void IconFetcher::didFinishLoading(ResourceHandle* handle)
{
- ASSERT(m_handle == handle);
+ ASSERT_UNUSED(handle, m_handle == handle);
if (m_currentEntry == m_entries.size() - 1) {
// We finished loading, create the icon
@@ -227,10 +222,9 @@ void IconFetcher::didFinishLoading(ResourceHandle* handle)
void IconFetcher::didFail(ResourceHandle* handle, const ResourceError&)
{
- ASSERT(m_handle == handle);
+ ASSERT_UNUSED(handle, m_handle == handle);
loadFailed();
}
-
} // namespace WebCore
diff --git a/WebCore/loader/icon/IconLoader.cpp b/WebCore/loader/icon/IconLoader.cpp
index 4337f51..b7bf115 100644
--- a/WebCore/loader/icon/IconLoader.cpp
+++ b/WebCore/loader/icon/IconLoader.cpp
@@ -36,6 +36,7 @@
#include "ResourceResponse.h"
#include "ResourceRequest.h"
#include "SubresourceLoader.h"
+#include <wtf/UnusedParam.h>
using namespace std;
@@ -101,9 +102,13 @@ void IconLoader::didReceiveResponse(SubresourceLoader* resourceLoader, const Res
}
}
-void IconLoader::didReceiveData(SubresourceLoader* loader, const char*, int size)
+void IconLoader::didReceiveData(SubresourceLoader* unusedLoader, const char*, int unusedSize)
{
- LOG(IconDatabase, "IconLoader::didReceiveData() - Loader %p, number of bytes %i", loader, size);
+#if LOG_DISABLED
+ UNUSED_PARAM(unusedLoader);
+ UNUSED_PARAM(unusedSize);
+#endif
+ LOG(IconDatabase, "IconLoader::didReceiveData() - Loader %p, number of bytes %i", unusedLoader, unusedSize);
}
void IconLoader::didFail(SubresourceLoader* resourceLoader, const ResourceError&)
@@ -121,7 +126,7 @@ void IconLoader::didFail(SubresourceLoader* resourceLoader, const ResourceError&
}
}
-void IconLoader::didReceiveAuthenticationChallenge(SubresourceLoader* resourceLoader, const AuthenticationChallenge& challenge)
+void IconLoader::didReceiveAuthenticationChallenge(SubresourceLoader*, const AuthenticationChallenge&)
{
// We don't ever want to prompt for authentication just for a site icon, so
// implement this method to cancel the resource load
@@ -153,9 +158,12 @@ void IconLoader::finishLoading(const KURL& iconURL, PassRefPtr<SharedBuffer> dat
// <rdar://problem/5463392> tracks that enhancement
if (!iconURL.isEmpty() && m_loadIsInProgress) {
- iconDatabase()->setIconDataForIconURL(data, iconURL.string());
LOG(IconDatabase, "IconLoader::finishLoading() - Committing iconURL %s to database", iconURL.string().ascii().data());
m_frame->loader()->commitIconURLToIconDatabase(iconURL);
+ // Setting the icon data only after committing to the database ensures that the data is
+ // kept in memory (so it does not have to be read from the database asynchronously), since
+ // there is a page URL referencing it.
+ iconDatabase()->setIconDataForIconURL(data, iconURL.string());
m_frame->loader()->client()->dispatchDidReceiveIcon();
}
diff --git a/WebCore/loader/icon/IconRecord.cpp b/WebCore/loader/icon/IconRecord.cpp
index f070cc9..ffea318 100644
--- a/WebCore/loader/icon/IconRecord.cpp
+++ b/WebCore/loader/icon/IconRecord.cpp
@@ -34,7 +34,6 @@
#include "Logging.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
-#include "SystemTime.h"
#include <limits.h>
@@ -53,7 +52,7 @@ IconRecord::~IconRecord()
LOG(IconDatabase, "Destroying IconRecord for icon url %s", m_iconURL.ascii().data());
}
-Image* IconRecord::image(const IntSize& size)
+Image* IconRecord::image(const IntSize&)
{
// FIXME rdar://4680377 - For size right now, we are returning our one and only image and the Bridge
// is resizing it in place. We need to actually store all the original representations here and return a native