summaryrefslogtreecommitdiff
path: root/Source/WebCore/fileapi
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
commit5ef7c8a6a70875d4430752d146bdcb069605d71d (patch)
treef6256640b6c46d7da221435803cae65326817ba2 /Source/WebCore/fileapi
parentdecad929f578d8db641febc8740649ca6c574638 (diff)
downloadqtwebkit-5ef7c8a6a70875d4430752d146bdcb069605d71d.tar.gz
Imported WebKit commit 356d83016b090995d08ad568f2d2c243aa55e831 (http://svn.webkit.org/repository/webkit/trunk@126147)
New snapshot including various build fixes for newer Qt 5
Diffstat (limited to 'Source/WebCore/fileapi')
-rw-r--r--Source/WebCore/fileapi/Blob.cpp10
-rw-r--r--Source/WebCore/fileapi/File.cpp16
-rw-r--r--Source/WebCore/fileapi/File.h10
-rw-r--r--Source/WebCore/fileapi/WebKitBlobBuilder.cpp11
-rw-r--r--Source/WebCore/fileapi/WebKitBlobBuilder.h8
5 files changed, 50 insertions, 5 deletions
diff --git a/Source/WebCore/fileapi/Blob.cpp b/Source/WebCore/fileapi/Blob.cpp
index d1dcb51ab..431f1764b 100644
--- a/Source/WebCore/fileapi/Blob.cpp
+++ b/Source/WebCore/fileapi/Blob.cpp
@@ -34,6 +34,7 @@
#include "BlobURL.h"
#include "File.h"
#include "HistogramSupport.h"
+#include "ScriptCallStack.h"
#include "ScriptExecutionContext.h"
#include "ThreadableBlobRegistry.h"
@@ -137,9 +138,14 @@ PassRefPtr<Blob> Blob::sliceInternal(long long start, long long end, const Strin
long long length = end - start;
OwnPtr<BlobData> blobData = BlobData::create();
blobData->setContentType(contentType);
- if (isFile())
+ if (isFile()) {
+#if ENABLE(FILE_SYSTEM)
+ if (!toFile(this)->fileSystemURL().isEmpty())
+ blobData->appendURL(toFile(this)->fileSystemURL(), start, length, modificationTime);
+ else
+#endif
blobData->appendFile(toFile(this)->path(), start, length, modificationTime);
- else
+ } else
blobData->appendBlob(m_internalURL, start, length);
return Blob::create(blobData.release(), length);
diff --git a/Source/WebCore/fileapi/File.cpp b/Source/WebCore/fileapi/File.cpp
index 087895710..692bde1ac 100644
--- a/Source/WebCore/fileapi/File.cpp
+++ b/Source/WebCore/fileapi/File.cpp
@@ -75,6 +75,14 @@ static PassOwnPtr<BlobData> createBlobDataForFileWithMetadata(const String& file
blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.modificationTime);
return blobData.release();
}
+
+static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSystemURL, const FileMetadata& metadata)
+{
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), File::WellKnownContentTypes));
+ blobData->appendURL(fileSystemURL, 0, metadata.length, metadata.modificationTime);
+ return blobData.release();
+}
#endif
#if ENABLE(DIRECTORY_UPLOAD)
@@ -131,6 +139,14 @@ File::File(const String& name, const FileMetadata& metadata)
, m_snapshotModificationTime(metadata.modificationTime)
{
}
+
+File::File(const KURL& fileSystemURL, const FileMetadata& metadata)
+ : Blob(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.length)
+ , m_fileSystemURL(fileSystemURL)
+ , m_snapshotSize(metadata.length)
+ , m_snapshotModificationTime(metadata.modificationTime)
+{
+}
#endif
double File::lastModifiedDate() const
diff --git a/Source/WebCore/fileapi/File.h b/Source/WebCore/fileapi/File.h
index 864c4388a..b915902d4 100644
--- a/Source/WebCore/fileapi/File.h
+++ b/Source/WebCore/fileapi/File.h
@@ -68,6 +68,13 @@ public:
{
return adoptRef(new File(name, metadata));
}
+
+ static PassRefPtr<File> createForFileSystemFile(const KURL& url, const FileMetadata& metadata)
+ {
+ return adoptRef(new File(url, metadata));
+ }
+
+ KURL fileSystemURL() const { return m_fileSystemURL; }
#endif
// Create a file with a name exposed to the author (via File.name and associated DOM properties) that differs from the one provided in the path.
@@ -104,6 +111,7 @@ private:
# if ENABLE(FILE_SYSTEM)
File(const String& name, const FileMetadata&);
+ File(const KURL& fileSystemURL, const FileMetadata&);
// Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >= 0).
bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; }
@@ -113,6 +121,8 @@ private:
String m_name;
#if ENABLE(FILE_SYSTEM)
+ KURL m_fileSystemURL;
+
// If m_snapshotSize is negative (initialized to -1 by default), the snapshot metadata is invalid and we retrieve the latest metadata synchronously in size(), lastModifiedTime() and webkitSlice().
// Otherwise, the snapshot metadata are used directly in those methods.
const long long m_snapshotSize;
diff --git a/Source/WebCore/fileapi/WebKitBlobBuilder.cpp b/Source/WebCore/fileapi/WebKitBlobBuilder.cpp
index 5c54c4b6f..c08e5fab7 100644
--- a/Source/WebCore/fileapi/WebKitBlobBuilder.cpp
+++ b/Source/WebCore/fileapi/WebKitBlobBuilder.cpp
@@ -37,6 +37,7 @@
#include "File.h"
#include "HistogramSupport.h"
#include "LineEnding.h"
+#include "ScriptCallStack.h"
#include "ScriptExecutionContext.h"
#include "TextEncoding.h"
#include <wtf/ArrayBuffer.h>
@@ -141,6 +142,11 @@ void WebKitBlobBuilder::append(Blob* blob)
file->captureSnapshot(snapshotSize, snapshotModificationTime);
m_size += snapshotSize;
+#if ENABLE(FILE_SYSTEM)
+ if (!file->fileSystemURL().isEmpty())
+ m_items.append(BlobDataItem(file->fileSystemURL(), 0, snapshotSize, snapshotModificationTime));
+ else
+#endif
m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotModificationTime));
} else {
long long blobSize = static_cast<long long>(blob->size());
@@ -149,7 +155,6 @@ void WebKitBlobBuilder::append(Blob* blob)
}
}
-
void WebKitBlobBuilder::appendBytesData(const void* data, size_t length)
{
Vector<char>& buffer = getBuffer();
@@ -158,8 +163,10 @@ void WebKitBlobBuilder::appendBytesData(const void* data, size_t length)
m_size += buffer.size() - oldSize;
}
-PassRefPtr<Blob> WebKitBlobBuilder::getBlob(const String& contentType)
+PassRefPtr<Blob> WebKitBlobBuilder::getBlob(const String& contentType, BlobConstructionReason constructionReason)
{
+ HistogramSupport::histogramEnumeration("WebCore.BlobBuilder.getBlob", constructionReason, BlobConstructionReasonMax);
+
OwnPtr<BlobData> blobData = BlobData::create();
blobData->setContentType(contentType);
blobData->swapItems(m_items);
diff --git a/Source/WebCore/fileapi/WebKitBlobBuilder.h b/Source/WebCore/fileapi/WebKitBlobBuilder.h
index c0b5e128b..b869defb2 100644
--- a/Source/WebCore/fileapi/WebKitBlobBuilder.h
+++ b/Source/WebCore/fileapi/WebKitBlobBuilder.h
@@ -43,6 +43,12 @@ class TextEncoding;
typedef int ExceptionCode;
+enum BlobConstructionReason {
+ BlobConstructedByBlobBuilder,
+ BlobConstructedByConstructor,
+ BlobConstructionReasonMax,
+};
+
class WebKitBlobBuilder : public RefCounted<WebKitBlobBuilder> {
public:
// Called when BlobBuilder is instantiated in JS API. We show deprecate warning message.
@@ -59,7 +65,7 @@ public:
void append(ArrayBufferView*);
#endif
- PassRefPtr<Blob> getBlob(const String& contentType = String());
+ PassRefPtr<Blob> getBlob(const String& contentType = String(), BlobConstructionReason = BlobConstructedByBlobBuilder);
private:
WebKitBlobBuilder();