[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 13:36:35 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit eb9927deaf8f2da54bfa751e82ee93c1fc2bfa1c
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Sep 21 13:05:51 2010 +0000
2010-09-21 Andras Becsi <abecsi at inf.u-szeged.hu>
Reviewed by Csaba Osztrogonác.
[Qt] QtWebProcess should clean up shared memory map files on close
https://bugs.webkit.org/show_bug.cgi?id=45984
Relocate MappedMemory struct code to it's own header and implement
a singleton pool class (MappedMemoryPool) which tracks shared memory
to be able to clean up map files from disk if RunLoop stops.
* Shared/qt/MappedMemory.h: Added.
(WebKit::MappedMemory::markUsed):
(WebKit::MappedMemory::markFree):
(WebKit::MappedMemory::isFree):
* Shared/qt/MappedMemoryPool.cpp: Added.
(WebKit::MappedMemoryPool::MappedMemoryPool):
(WebKit::MappedMemoryPool::instance):
(WebKit::MappedMemoryPool::size):
(WebKit::MappedMemoryPool::at):
(WebKit::MappedMemoryPool::append):
(WebKit::MappedMemoryPool::cleanUp):
* Shared/qt/UpdateChunk.cpp:
(WebKit::mapMemory):
(WebKit::mapFile):
* Shared/qt/UpdateChunk.h:
* WebKit2.pro:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67945 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index faf5dbd..fa29800 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,31 @@
+2010-09-21 Andras Becsi <abecsi at inf.u-szeged.hu>
+
+ Reviewed by Csaba Osztrogonác.
+
+ [Qt] QtWebProcess should clean up shared memory map files on close
+ https://bugs.webkit.org/show_bug.cgi?id=45984
+
+ Relocate MappedMemory struct code to it's own header and implement
+ a singleton pool class (MappedMemoryPool) which tracks shared memory
+ to be able to clean up map files from disk if RunLoop stops.
+
+ * Shared/qt/MappedMemory.h: Added.
+ (WebKit::MappedMemory::markUsed):
+ (WebKit::MappedMemory::markFree):
+ (WebKit::MappedMemory::isFree):
+ * Shared/qt/MappedMemoryPool.cpp: Added.
+ (WebKit::MappedMemoryPool::MappedMemoryPool):
+ (WebKit::MappedMemoryPool::instance):
+ (WebKit::MappedMemoryPool::size):
+ (WebKit::MappedMemoryPool::at):
+ (WebKit::MappedMemoryPool::append):
+ (WebKit::MappedMemoryPool::cleanUp):
+ * Shared/qt/UpdateChunk.cpp:
+ (WebKit::mapMemory):
+ (WebKit::mapFile):
+ * Shared/qt/UpdateChunk.h:
+ * WebKit2.pro:
+
2010-09-20 Philippe Normand <pnormand at igalia.com>
Reviewed by Eric Carlson.
diff --git a/WebKit2/Shared/qt/MappedMemory.h b/WebKit2/Shared/qt/MappedMemory.h
new file mode 100644
index 0000000..79a5167
--- /dev/null
+++ b/WebKit2/Shared/qt/MappedMemory.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2010 University of Szeged
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MappedMemory_h
+#define MappedMemory_h
+
+#include <QCoreApplication>
+#include <QFile>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+struct MappedMemory {
+ QFile* file;
+ uchar* data;
+ size_t size;
+ void markUsed() { *reinterpret_cast<uint64_t*>(data) = 0; }
+ void markFree() { *reinterpret_cast<uint64_t*>(data) = 0xdeadbeef; }
+ bool isFree() { return *reinterpret_cast<uint64_t*>(data) == 0xdeadbeef; }
+};
+
+class MappedMemoryPool : public QObject {
+ Q_OBJECT
+public:
+ static MappedMemoryPool* instance();
+ size_t size() const;
+ MappedMemory& at(size_t i);
+ MappedMemory& append(const MappedMemory&);
+
+private:
+ MappedMemoryPool();
+ Q_SLOT void cleanUp();
+
+ Vector<MappedMemory> m_pool;
+};
+} // namespace WebKit
+#endif // MappedMemory_h
diff --git a/WebKit2/Shared/qt/MappedMemoryPool.cpp b/WebKit2/Shared/qt/MappedMemoryPool.cpp
new file mode 100644
index 0000000..ed47d3b
--- /dev/null
+++ b/WebKit2/Shared/qt/MappedMemoryPool.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 University of Szeged
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "MappedMemory.h"
+
+#include "StdLibExtras.h"
+
+namespace WebKit {
+
+MappedMemoryPool::MappedMemoryPool()
+{
+ connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(cleanUp()));
+}
+
+MappedMemoryPool* MappedMemoryPool::instance()
+{
+ DEFINE_STATIC_LOCAL(MappedMemoryPool, singleton, ());
+ return &singleton;
+}
+
+size_t MappedMemoryPool::size() const
+{
+ return m_pool.size();
+}
+
+MappedMemory& MappedMemoryPool::at(size_t i)
+{
+ return m_pool.at(i);
+}
+
+MappedMemory& MappedMemoryPool::append(const MappedMemory& newMap)
+{
+ m_pool.append(newMap);
+ return m_pool.last();
+}
+
+void MappedMemoryPool::cleanUp()
+{
+ size_t size = m_pool.size();
+
+ for (size_t i = 0; i < size; ++i) {
+ MappedMemory& chunk = m_pool.at(i);
+ if (!chunk.isFree())
+ chunk.file->unmap(chunk.data);
+ chunk.file->remove();
+ }
+
+ delete this;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/qt/UpdateChunk.cpp b/WebKit2/Shared/qt/UpdateChunk.cpp
index 2940adc..c58dfb7 100644
--- a/WebKit2/Shared/qt/UpdateChunk.cpp
+++ b/WebKit2/Shared/qt/UpdateChunk.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2010 University of Szeged
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,36 +32,22 @@
#include "Attachment.h"
#include "WebCoreArgumentCoders.h"
#include <QDebug>
-#include <QFile>
+#include <QDir>
#include <QImage>
#include <QTemporaryFile>
#include <WebCore/FloatRect.h>
#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
using namespace WebCore;
using namespace std;
namespace WebKit {
-
-struct MappedMemory {
- QFile* file;
- uchar* data;
- size_t size;
- void markUsed() { *reinterpret_cast<uint64_t*>(data) = 0; }
- void markFree() { *reinterpret_cast<uint64_t*>(data) = 0xdeadbeef; }
- bool isFree() { return *reinterpret_cast<uint64_t*>(data) == 0xdeadbeef; }
-};
-
-static Vector<MappedMemory>* mmapPool;
-
+
static MappedMemory* mapMemory(size_t size)
{
- if (!mmapPool)
- mmapPool = new Vector<MappedMemory>;
-
- for (unsigned n = 0; n < mmapPool->size(); ++n) {
- MappedMemory& current = mmapPool->at(n);
+ MappedMemoryPool* pool = MappedMemoryPool::instance();
+ for (unsigned n = 0; n < pool->size(); ++n) {
+ MappedMemory& current = pool->at(n);
if (current.size >= size && current.isFree()) {
current.markUsed();
return ¤t;
@@ -68,23 +55,20 @@ static MappedMemory* mapMemory(size_t size)
}
MappedMemory newMap;
newMap.size = size;
- // FIXME: Clean up or reuse leftover map files from the disk.
- newMap.file = new QTemporaryFile("WebKit2UpdateChunk");
+ newMap.file = new QTemporaryFile(QDir::tempPath() + "/WebKit2UpdateChunk");
newMap.file->open(QIODevice::ReadWrite);
newMap.file->resize(newMap.size);
newMap.data = newMap.file->map(0, newMap.size);
newMap.file->close();
newMap.markUsed();
- mmapPool->append(newMap);
- return &mmapPool->last();
+ return &pool->append(newMap);
}
static MappedMemory* mapFile(QString fileName, size_t size)
{
- if (!mmapPool)
- mmapPool = new Vector<MappedMemory>;
- for (unsigned n = 0; n < mmapPool->size(); ++n) {
- MappedMemory& current = mmapPool->at(n);
+ MappedMemoryPool* pool = MappedMemoryPool::instance();
+ for (unsigned n = 0; n < pool->size(); ++n) {
+ MappedMemory& current = pool->at(n);
if (current.file->fileName() == fileName) {
ASSERT(!current.isFree());
return ¤t;
@@ -97,8 +81,7 @@ static MappedMemory* mapFile(QString fileName, size_t size)
newMap.data = newMap.file->map(0, size);
ASSERT(!newMap.isFree());
newMap.file->close();
- mmapPool->append(newMap);
- return &mmapPool->last();
+ return &pool->append(newMap);
}
UpdateChunk::UpdateChunk()
diff --git a/WebKit2/Shared/qt/UpdateChunk.h b/WebKit2/Shared/qt/UpdateChunk.h
index ffe1ba4..0c9286e 100644
--- a/WebKit2/Shared/qt/UpdateChunk.h
+++ b/WebKit2/Shared/qt/UpdateChunk.h
@@ -27,6 +27,7 @@
#ifndef UpdateChunk_h
#define UpdateChunk_h
+#include "MappedMemory.h"
#include <QImage>
#include <WebCore/IntRect.h>
@@ -37,8 +38,6 @@ class ArgumentDecoder;
namespace WebKit {
-class MappedMemory;
-
class UpdateChunk {
public:
UpdateChunk();
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index 55cab07..fc8f6a5 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -162,7 +162,9 @@ HEADERS += \
Shared/MutableArray.h \
Shared/MutableDictionary.h \
Shared/NotImplemented.h \
+ Shared/qt/MappedMemory.h \
Shared/qt/PlatformCertificateInfo.h \
+ Shared/qt/UpdateChunk.h \
Shared/qt/WebEventFactoryQt.h \
Shared/UserMessageCoders.h \
Shared/VisitedLinkTable.h \
@@ -292,6 +294,7 @@ SOURCES += \
Shared/WebPreferencesStore.cpp \
Shared/WebURLRequest.cpp \
Shared/WebURLResponse.cpp \
+ Shared/qt/MappedMemoryPool.cpp \
Shared/qt/UpdateChunk.cpp \
Shared/qt/WebEventFactoryQt.cpp \
Shared/qt/WebCoreArgumentCodersQt.cpp \
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list