[wk2] IconDatabase images should be decoded in the WebProcess

https://bugs.webkit.org/show_bug.cgi?id=112524
<rdar://problem/10133914>

Reviewed by Oliver Hunt.

In the interests of keeping decoding of data coming in from the greater Internet
in the WebProcess, move decoding of favicons from the UIProcess to the WebProcess.

* UIProcess/WebIconDatabase.cpp:
(WebKit::WebIconDatabase::setIconBitmapForIconURL):
Receive a ShareableBitmap handle from the WebProcess instead of a DataReference.
Use the new setIconBitmapForIconURL IconDatabase method.

* UIProcess/WebIconDatabase.h:
(WebIconDatabase):
Rename setIconDataForIconURL to setIconBitmapForIconURL.

* UIProcess/WebIconDatabase.messages.in: Ditto.

* WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
(WebKit::WebIconDatabaseProxy::setIconDataForIconURL):
In the WebProcess, decode the incoming icon and draw it into a ShareableBitmap.

No testable behavior change.

* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::updateIconRecord):
Added updateIconRecord, which factors most of setIconDataForIconURL out so it can
be shared with setIconBitmapForIconURL. This function will set either a bitmap or
raw image data for the given icon URL.

(WebCore::IconDatabase::setIconBitmapForIconURL):
Added; make a copy of the bitmap for thread-safety purposes, and call updateIconRecord.

(WebCore::IconDatabase::setIconDataForIconURL):
Factored out of what is now updateIconRecord.

* loader/icon/IconDatabase.h:
(IconDatabase): Add setIconBitmapForIconURL and updateIconRecord.

* loader/icon/IconDatabaseBase.h:
(WebCore::IconDatabaseBase::setIconBitmapForIconURL): Added.
* loader/icon/IconRecord.cpp:
(WebCore::IconRecord::setImage): Set the image for an icon record directly (as opposed
to setting the image data, which causes the image to be decoded in the WebProcess).
* loader/icon/IconRecord.h:
(IconRecord): Add setImage.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 81f8cd51
2013-04-09 Tim Horton <timothy_horton@apple.com>
[wk2] IconDatabase images should be decoded in the WebProcess
https://bugs.webkit.org/show_bug.cgi?id=112524
<rdar://problem/10133914>
Reviewed by Oliver Hunt.
No testable behavior change.
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::updateIconRecord):
Added updateIconRecord, which factors most of setIconDataForIconURL out so it can
be shared with setIconBitmapForIconURL. This function will set either a bitmap or
raw image data for the given icon URL.
(WebCore::IconDatabase::setIconBitmapForIconURL):
Added; make a copy of the bitmap for thread-safety purposes, and call updateIconRecord.
(WebCore::IconDatabase::setIconDataForIconURL):
Factored out of what is now updateIconRecord.
* loader/icon/IconDatabase.h:
(IconDatabase): Add setIconBitmapForIconURL and updateIconRecord.
* loader/icon/IconDatabaseBase.h:
(WebCore::IconDatabaseBase::setIconBitmapForIconURL): Added.
* loader/icon/IconRecord.cpp:
(WebCore::IconRecord::setImage): Set the image for an icon record directly (as opposed
to setting the image data, which causes the image to be decoded in the WebProcess).
* loader/icon/IconRecord.h:
(IconRecord): Add setImage.
2013-04-09 Chris Fleizach <cfleizach@apple.com>
AX: The bounding paths should be made available through accessibility
......@@ -29,11 +29,13 @@
#if ENABLE(ICONDATABASE)
#include "BitmapImage.h"
#include "DocumentLoader.h"
#include "FileSystem.h"
#include "IconDatabaseClient.h"
#include "IconRecord.h"
#include "Image.h"
#include "ImageBuffer.h"
#include "IntSize.h"
#include "Logging.h"
#include "SQLiteStatement.h"
......@@ -533,24 +535,15 @@ void IconDatabase::performReleaseIconForPageURL(const String& pageURLOriginal, i
delete pageRecord;
}
void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal, const String& iconURLOriginal)
{
ASSERT_NOT_SYNC_THREAD();
// Cannot do anything with dataOriginal or iconURLOriginal that would end up storing them without deep copying first
if (!isOpen() || iconURLOriginal.isEmpty())
return;
RefPtr<SharedBuffer> data = dataOriginal ? dataOriginal->copy() : PassRefPtr<SharedBuffer>(0);
if (data)
data->setMutexForVerifier(m_urlAndIconLock);
String iconURL = iconURLOriginal.isolatedCopy();
void IconDatabase::updateIconRecord(PassRefPtr<SharedBuffer> iconData, PassRefPtr<Image> iconBitmap, const String& iconURL)
{
// Only one of iconData or iconBitmap should be provided, never both.
ASSERT(!iconData != !iconBitmap);
Vector<String> pageURLs;
{
MutexLocker locker(m_urlAndIconLock);
// If this icon was pending a read, remove it from that set because this new data should override what is on disk
RefPtr<IconRecord> icon = m_iconURLToRecordMap.get(iconURL);
if (icon) {
......@@ -558,14 +551,17 @@ void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal,
m_iconsPendingReading.remove(icon.get());
} else
icon = getOrCreateIconRecord(iconURL);
// Update the data and set the time stamp
icon->setImageData(data.release());
// Update the image and set the time stamp
if (iconData)
icon->setImageData(iconData);
else if (iconBitmap)
icon->setImage(iconBitmap);
icon->setTimestamp((int)currentTime());
// Copy the current retaining pageURLs - if any - to notify them of the change
pageURLs.appendRange(icon->retainingPageURLs().begin(), icon->retainingPageURLs().end());
// Mark the IconRecord as requiring an update to the database only if private browsing is disabled
if (!m_privateBrowsingEnabled) {
MutexLocker locker(m_pendingSyncLock);
......@@ -587,7 +583,7 @@ void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal,
scheduleOrDeferSyncTimer();
// Informal testing shows that draining the autorelease pool every 25 iterations is about as low as we can go
// before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up
// before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up
AutodrainedPool pool(25);
for (unsigned i = 0; i < pageURLs.size(); ++i) {
......@@ -599,6 +595,51 @@ void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal,
}
}
void IconDatabase::setIconBitmapForIconURL(PassRefPtr<Image> imageOriginal, const String& iconURLOriginal)
{
ASSERT_NOT_SYNC_THREAD();
ASSERT(imageOriginal->isBitmapImage());
// Cannot do anything with imageOriginal or iconURLOriginal that would end up storing them without deep copying first
if (!isOpen() || iconURLOriginal.isEmpty())
return;
RefPtr<Image> image;
if (imageOriginal) {
OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageOriginal->size());
GraphicsContext* context = imageBuffer->context();
context->drawImage(imageOriginal.get(), ColorSpaceDeviceRGB, IntPoint());
image = imageBuffer->copyImage();
}
if (image)
image->setMutexForVerifier(m_urlAndIconLock);
String iconURL = iconURLOriginal.isolatedCopy();
updateIconRecord(0, image.release(), iconURL);
}
void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal, const String& iconURLOriginal)
{
ASSERT_NOT_SYNC_THREAD();
// Cannot do anything with dataOriginal or iconURLOriginal that would end up storing them without deep copying first
if (!isOpen() || iconURLOriginal.isEmpty())
return;
RefPtr<SharedBuffer> data = dataOriginal ? dataOriginal->copy() : PassRefPtr<SharedBuffer>(0);
if (data)
data->setMutexForVerifier(m_urlAndIconLock);
String iconURL = iconURLOriginal.isolatedCopy();
updateIconRecord(data.release(), 0, iconURL);
}
void IconDatabase::setIconURLForPageURL(const String& iconURLOriginal, const String& pageURLOriginal)
{
ASSERT_NOT_SYNC_THREAD();
......
......@@ -93,7 +93,8 @@ public:
virtual void retainIconForPageURL(const String&);
virtual void releaseIconForPageURL(const String&);
virtual void setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String&);
virtual void setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String&) OVERRIDE;
virtual void setIconBitmapForIconURL(PassRefPtr<Image>, const String&) OVERRIDE;
virtual void setIconURLForPageURL(const String& iconURL, const String& pageURL);
virtual Image* synchronousIconForPageURL(const String&, const IntSize&);
......@@ -128,6 +129,8 @@ private:
void wakeSyncThread();
void scheduleOrDeferSyncTimer();
void syncTimerFired(Timer<IconDatabase>*);
void updateIconRecord(PassRefPtr<SharedBuffer>, PassRefPtr<Image>, const String&);
Timer<IconDatabase> m_syncTimer;
ThreadIdentifier m_syncThread;
......
......@@ -26,6 +26,7 @@
#ifndef IconDatabaseBase_h
#define IconDatabaseBase_h
#include "Image.h"
#include "ImageSource.h"
#include "SharedBuffer.h"
......@@ -172,6 +173,7 @@ public:
virtual void setIconURLForPageURL(const String&, const String&) { }
virtual void setIconDataForIconURL(PassRefPtr<SharedBuffer>, const String&) { }
virtual void setIconBitmapForIconURL(PassRefPtr<Image>, const String&) { }
// Synchronous calls used internally by WebCore.
// Usage should be replaced by asynchronous calls.
......
......@@ -77,6 +77,12 @@ void IconRecord::setImageData(PassRefPtr<SharedBuffer> data)
m_dataSet = true;
}
void IconRecord::setImage(PassRefPtr<Image> image)
{
m_image = image;
m_dataSet = true;
}
void IconRecord::loadImageFromResource(const char* resource)
{
if (!resource)
......
......@@ -85,6 +85,7 @@ public:
void setTimestamp(time_t stamp) { m_stamp = stamp; }
void setImageData(PassRefPtr<SharedBuffer> data);
void setImage(PassRefPtr<Image> data);
Image* image(const IntSize&);
String iconURL() { return m_iconURL; }
......
2013-04-09 Tim Horton <timothy_horton@apple.com>
[wk2] IconDatabase images should be decoded in the WebProcess
https://bugs.webkit.org/show_bug.cgi?id=112524
<rdar://problem/10133914>
Reviewed by Oliver Hunt.
In the interests of keeping decoding of data coming in from the greater Internet
in the WebProcess, move decoding of favicons from the UIProcess to the WebProcess.
* UIProcess/WebIconDatabase.cpp:
(WebKit::WebIconDatabase::setIconBitmapForIconURL):
Receive a ShareableBitmap handle from the WebProcess instead of a DataReference.
Use the new setIconBitmapForIconURL IconDatabase method.
* UIProcess/WebIconDatabase.h:
(WebIconDatabase):
Rename setIconDataForIconURL to setIconBitmapForIconURL.
* UIProcess/WebIconDatabase.messages.in: Ditto.
* WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
(WebKit::WebIconDatabaseProxy::setIconDataForIconURL):
In the WebProcess, decode the incoming icon and draw it into a ShareableBitmap.
2013-04-09 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
[EFL] Declare TEST_THEME_DIR in a single place.
......@@ -121,14 +121,19 @@ void WebIconDatabase::setIconURLForPageURL(const String& iconURL, const String&
m_iconDatabaseImpl->setIconURLForPageURL(iconURL, pageURL);
}
void WebIconDatabase::setIconDataForIconURL(const CoreIPC::DataReference& iconData, const String& iconURL)
void WebIconDatabase::setIconBitmapForIconURL(const ShareableBitmap::Handle& bitmapHandle, const String& iconURL)
{
LOG(IconDatabase, "WK2 UIProcess setting icon data (%i bytes) for page URL %s", (int)iconData.size(), iconURL.ascii().data());
LOG(IconDatabase, "WK2 UIProcess setting icon bitmap for page URL %s", iconURL.ascii().data());
if (!m_iconDatabaseImpl)
return;
RefPtr<SharedBuffer> buffer = SharedBuffer::create(iconData.data(), iconData.size());
m_iconDatabaseImpl->setIconDataForIconURL(buffer.release(), iconURL);
if (bitmapHandle.isNull()) {
m_iconDatabaseImpl->setIconBitmapForIconURL(0, iconURL);
return;
}
RefPtr<ShareableBitmap> iconBitmap = ShareableBitmap::create(bitmapHandle, SharedMemory::ReadOnly);
m_iconDatabaseImpl->setIconBitmapForIconURL(iconBitmap->createImage(), iconURL);
}
void WebIconDatabase::synchronousIconDataForPageURL(const String&, CoreIPC::DataReference& iconData)
......
......@@ -29,6 +29,7 @@
#include "APIObject.h"
#include "Connection.h"
#include "ShareableBitmap.h"
#include "WebIconDatabaseClient.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/ImageSource.h>
......@@ -66,7 +67,7 @@ public:
void retainIconForPageURL(const String&);
void releaseIconForPageURL(const String&);
void setIconURLForPageURL(const String&, const String&);
void setIconDataForIconURL(const CoreIPC::DataReference&, const String&);
void setIconBitmapForIconURL(const ShareableBitmap::Handle&, const String&);
void synchronousIconDataForPageURL(const String&, CoreIPC::DataReference&);
void synchronousIconURLForPageURL(const String&, String&);
......
......@@ -24,7 +24,7 @@ messages -> WebIconDatabase {
RetainIconForPageURL(WTF::String pageURL)
ReleaseIconForPageURL(WTF::String pageURL)
SetIconURLForPageURL(WTF::String iconURL, WTF::String pageURL)
SetIconDataForIconURL(CoreIPC::DataReference iconData, WTF::String iconURL)
SetIconBitmapForIconURL(WebKit::ShareableBitmap::Handle bitmapHandle, WTF::String iconURL)
SynchronousIconDataForPageURL(WTF::String pageURL) -> (CoreIPC::DataReference iconData)
SynchronousIconURLForPageURL(WTF::String pageURL) -> (WTF::String iconURL)
......
......@@ -30,6 +30,9 @@
#include "WebIconDatabaseMessages.h"
#include "WebIconDatabaseProxyMessages.h"
#include "WebProcess.h"
#include <WebCore/BitmapImage.h>
#include <WebCore/GraphicsContext.h>
#include <WebCore/IntPoint.h>
#include <WebCore/SharedBuffer.h>
#include <wtf/text/WTFString.h>
......@@ -135,8 +138,18 @@ void WebIconDatabaseProxy::setIconURLForPageURL(const String& iconURL, const Str
void WebIconDatabaseProxy::setIconDataForIconURL(PassRefPtr<SharedBuffer> iconData, const String& iconURL)
{
CoreIPC::DataReference data(reinterpret_cast<const uint8_t*>(iconData ? iconData->data() : 0), iconData ? iconData->size() : 0);
m_process->connection()->send(Messages::WebIconDatabase::SetIconDataForIconURL(data, iconURL), 0);
RefPtr<Image> image = BitmapImage::create();
ShareableBitmap::Handle handle;
if (image->setData(iconData, true) && !image->size().isEmpty()) {
RefPtr<ShareableBitmap> shareableBitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
OwnPtr<GraphicsContext> bitmapContext = shareableBitmap->createGraphicsContext();
bitmapContext->drawImage(image.get(), ColorSpaceDeviceRGB, IntPoint());
shareableBitmap->createHandle(handle, SharedMemory::ReadOnly);
}
m_process->connection()->send(Messages::WebIconDatabase::SetIconBitmapForIconURL(handle, iconURL), 0);
}
void WebIconDatabaseProxy::urlImportFinished()
......
......@@ -345,7 +345,7 @@ void PDFPlugin::destroy()
{
m_pdfLayerController.get().delegate = 0;
if (webFrame()) {
if (webFrame() && webFrame()->coreFrame()) {
if (FrameView* frameView = webFrame()->coreFrame()->view())
frameView->removeScrollableArea(this);
}
......
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