Diff
Modified: trunk/Source/WebCore/ChangeLog (198868 => 198869)
--- trunk/Source/WebCore/ChangeLog 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/ChangeLog 2016-03-31 01:21:04 UTC (rev 198869)
@@ -1,3 +1,83 @@
+2016-03-30 Brady Eidson <[email protected]>
+
+ Make BlobData use ThreadSafeSharedBuffer instead of RawData.
+ https://bugs.webkit.org/show_bug.cgi?id=156041
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No change in behavior).
+
+ * Modules/fetch/FetchBody.cpp:
+ (WebCore::FetchBody::consumeText):
+ (WebCore::FetchBody::extractFromText):
+ (WebCore::blobFromArrayBuffer):
+ * Modules/fetch/FetchBody.h:
+ * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
+ (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData):
+ * Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:
+ * Modules/websockets/WebSocket.cpp:
+ (WebCore::WebSocket::didReceiveBinaryData):
+ * Modules/websockets/WebSocket.h:
+ * Modules/websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::processFrame):
+ * Modules/websockets/WebSocketChannel.h:
+ * Modules/websockets/WebSocketChannelClient.h:
+ (WebCore::WebSocketChannelClient::didReceiveBinaryData):
+ * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
+ (WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData):
+ * Modules/websockets/WorkerThreadableWebSocketChannel.h:
+ * fileapi/Blob.cpp:
+ (WebCore::Blob::Blob):
+ * fileapi/Blob.h:
+ (WebCore::Blob::create):
+ * fileapi/WebKitBlobBuilder.h:
+ * platform/network/BlobData.cpp:
+ (WebCore::BlobData::BlobData):
+ (WebCore::BlobDataItem::length):
+ (WebCore::BlobData::appendData):
+ (WebCore::BlobData::setContentType): Deleted.
+ * platform/network/BlobData.h:
+ (WebCore::BlobDataItem::type):
+ (WebCore::BlobDataItem::data):
+ (WebCore::BlobDataItem::file):
+ (WebCore::BlobDataItem::BlobDataItem):
+ (WebCore::BlobData::create):
+ (WebCore::RawData::create): Deleted.
+ (WebCore::RawData::data): Deleted.
+ (WebCore::RawData::length): Deleted.
+ (WebCore::RawData::RawData): Deleted.
+ * platform/network/BlobPart.h:
+ (WebCore::BlobPart::BlobPart):
+ (WebCore::BlobPart::data):
+ (WebCore::BlobPart::moveData):
+ * platform/network/BlobRegistryImpl.cpp:
+ (WebCore::BlobRegistryImpl::appendStorageItems):
+ (WebCore::BlobRegistryImpl::registerFileBlobURL):
+ (WebCore::BlobRegistryImpl::registerBlobURL):
+ (WebCore::BlobRegistryImpl::registerBlobURLForSlice):
+ * platform/network/BlobResourceHandle.cpp:
+ (WebCore::BlobResourceHandle::getSizeForNext):
+ (WebCore::BlobResourceHandle::readSync):
+ (WebCore::BlobResourceHandle::readDataSync):
+ (WebCore::BlobResourceHandle::readFileSync):
+ (WebCore::BlobResourceHandle::readAsync):
+ (WebCore::BlobResourceHandle::readDataAsync):
+ (WebCore::BlobResourceHandle::readFileAsync):
+ * platform/network/BlobResourceHandle.h:
+ * platform/network/FormData.cpp:
+ (WebCore::appendBlobResolved):
+ * platform/network/soup/ResourceHandleSoup.cpp:
+ (WebCore::blobIsOutOfDate):
+ (WebCore::addEncodedBlobItemToSoupMessageBody):
+ * platform/text/LineEnding.cpp:
+ (WebCore::normalizeToCROrLF):
+ (WebCore::normalizeLineEndingsToNative):
+ (WebCore::normalizeLineEndingsToCR): Deleted.
+ (WebCore::normalizeLineEndingsToLF): Deleted.
+ * platform/text/LineEnding.h:
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::responseBlob):
+
2016-03-30 Enrica Casucci <[email protected]>
Add a style for Data Detectors links.
Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (198868 => 198869)
--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -201,7 +201,7 @@
ASSERT(type == Consumer::Type::ArrayBuffer || type == Consumer::Type::Blob);
if (type == Consumer::Type::ArrayBuffer) {
- Vector<char> data = ""
+ Vector<uint8_t> data = ""
fulfillPromiseWithArrayBuffer(promise, data.data(), data.size());
return;
}
@@ -232,12 +232,12 @@
owner.loadBlob(*m_blob, loadingType(type));
}
-Vector<char> FetchBody::extractFromText() const
+Vector<uint8_t> FetchBody::extractFromText() const
{
ASSERT(m_type == Type::Text);
// FIXME: This double allocation is not efficient. Might want to fix that at WTFString level.
CString data = ""
- Vector<char> value(data.length());
+ Vector<uint8_t> value(data.length());
memcpy(value.data(), data.data(), data.length());
return value;
}
@@ -245,10 +245,10 @@
static inline RefPtr<Blob> blobFromArrayBuffer(ArrayBuffer* buffer, const String& contentType)
{
if (!buffer)
- return Blob::create(Vector<char>(), contentType);
+ return Blob::create(Vector<uint8_t>(), contentType);
// FIXME: We should try to move buffer to Blob without doing this copy.
- Vector<char> value(buffer->byteLength());
+ Vector<uint8_t> value(buffer->byteLength());
memcpy(value.data(), buffer->data(), buffer->byteLength());
return Blob::create(WTFMove(value), contentType);
}
Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (198868 => 198869)
--- trunk/Source/WebCore/Modules/fetch/FetchBody.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -87,7 +87,7 @@
};
void consume(FetchBodyOwner&, Consumer::Type, DeferredWrapper&&);
- Vector<char> extractFromText() const;
+ Vector<uint8_t> extractFromText() const;
bool processIfEmptyOrDisturbed(Consumer::Type, DeferredWrapper&);
void consumeArrayBuffer(Consumer::Type, DeferredWrapper&);
void consumeText(Consumer::Type, DeferredWrapper&);
Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -180,10 +180,10 @@
processPendingTasks();
}
-void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData(Vector<char>&& binaryData)
+void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
{
ref();
- Vector<char>* capturedData = new Vector<char>(WTFMove(binaryData));
+ Vector<uint8_t>* capturedData = new Vector<uint8_t>(WTFMove(binaryData));
m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, capturedData] (ScriptExecutionContext&) {
if (m_client)
m_client->didReceiveBinaryData(WTFMove(*capturedData));
Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -79,7 +79,7 @@
void didConnect();
void didReceiveMessage(const String& message);
- void didReceiveBinaryData(Vector<char>&&);
+ void didReceiveBinaryData(Vector<uint8_t>&&);
void didUpdateBufferedAmount(unsigned long bufferedAmount);
void didStartClosingHandshake();
void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -561,7 +561,7 @@
dispatchEvent(MessageEvent::create(msg, SecurityOrigin::create(m_url)->toString()));
}
-void WebSocket::didReceiveBinaryData(Vector<char>&& binaryData)
+void WebSocket::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
{
LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message", this, static_cast<unsigned long>(binaryData.size()));
switch (m_binaryType) {
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -100,7 +100,7 @@
// WebSocketChannelClient functions.
void didConnect() override;
void didReceiveMessage(const String& message) override;
- void didReceiveBinaryData(Vector<char>&&) override;
+ void didReceiveBinaryData(Vector<uint8_t>&&) override;
void didReceiveMessageError() override;
void didUpdateBufferedAmount(unsigned long bufferedAmount) override;
void didStartClosingHandshake() override;
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -586,7 +586,7 @@
// so we should pretend that we have finished to read this frame and
// make sure that the member variables are in a consistent state before
// the handler is invoked.
- Vector<char> continuousFrameData = WTFMove(m_continuousFrameData);
+ Vector<uint8_t> continuousFrameData = WTFMove(m_continuousFrameData);
m_hasContinuousFrame = false;
if (m_continuousFrameOpCode == WebSocketFrame::OpCodeText) {
String message;
@@ -626,7 +626,7 @@
case WebSocketFrame::OpCodeBinary:
if (frame.final) {
- Vector<char> binaryData(frame.payloadLength);
+ Vector<uint8_t> binaryData(frame.payloadLength);
memcpy(binaryData.data(), frame.payload, frame.payloadLength);
skipBuffer(frameEnd - m_buffer.data());
m_client->didReceiveBinaryData(WTFMove(binaryData));
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -204,7 +204,7 @@
// Private members only for hybi-10 protocol.
bool m_hasContinuousFrame;
WebSocketFrame::OpCode m_continuousFrameOpCode;
- Vector<char> m_continuousFrameData;
+ Vector<uint8_t> m_continuousFrameData;
unsigned short m_closeEventCode;
String m_closeEventReason;
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -43,7 +43,7 @@
virtual ~WebSocketChannelClient() { }
virtual void didConnect() { }
virtual void didReceiveMessage(const String&) { }
- virtual void didReceiveBinaryData(Vector<char>&&) { }
+ virtual void didReceiveBinaryData(Vector<uint8_t>&&) { }
virtual void didReceiveMessageError() { }
virtual void didUpdateBufferedAmount(unsigned long /* bufferedAmount */) { }
virtual void didStartClosingHandshake() { }
Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -288,12 +288,12 @@
}, m_taskMode);
}
-void WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData(Vector<char>&& binaryData)
+void WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
{
ASSERT(isMainThread());
RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper;
- Vector<char>* capturedData = new Vector<char>(WTFMove(binaryData));
+ Vector<uint8_t>* capturedData = new Vector<uint8_t>(WTFMove(binaryData));
m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper, capturedData] (ScriptExecutionContext& context) {
ASSERT_UNUSED(context, context.isWorkerGlobalScope());
workerClientWrapper->didReceiveBinaryData(WTFMove(*capturedData));
Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h (198868 => 198869)
--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -100,7 +100,7 @@
// WebSocketChannelClient functions.
void didConnect() override;
void didReceiveMessage(const String& message) override;
- void didReceiveBinaryData(Vector<char>&&) override;
+ void didReceiveBinaryData(Vector<uint8_t>&&) override;
void didUpdateBufferedAmount(unsigned long bufferedAmount) override;
void didStartClosingHandshake() override;
void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override;
Modified: trunk/Source/WebCore/fileapi/Blob.cpp (198868 => 198869)
--- trunk/Source/WebCore/fileapi/Blob.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/fileapi/Blob.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -77,7 +77,7 @@
ThreadableBlobRegistry::registerBlobURL(m_internalURL, Vector<BlobPart>(), String());
}
-Blob::Blob(Vector<char> data, const String& contentType)
+Blob::Blob(Vector<uint8_t> data, const String& contentType)
: m_type(contentType)
, m_size(data.size())
{
Modified: trunk/Source/WebCore/fileapi/Blob.h (198868 => 198869)
--- trunk/Source/WebCore/fileapi/Blob.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/fileapi/Blob.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -48,7 +48,7 @@
return adoptRef(*new Blob);
}
- static Ref<Blob> create(Vector<char> data, const String& contentType)
+ static Ref<Blob> create(Vector<uint8_t> data, const String& contentType)
{
return adoptRef(*new Blob(WTFMove(data), contentType));
}
@@ -91,7 +91,7 @@
protected:
Blob();
- Blob(Vector<char>, const String& contentType);
+ Blob(Vector<uint8_t>, const String& contentType);
Blob(Vector<BlobPart>, const String& contentType);
enum UninitializedContructor { uninitializedContructor };
Modified: trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h (198868 => 198869)
--- trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -55,7 +55,7 @@
private:
Vector<BlobPart> m_items;
- Vector<char> m_appendableData;
+ Vector<uint8_t> m_appendableData;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/BlobData.cpp (198868 => 198869)
--- trunk/Source/WebCore/platform/network/BlobData.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/BlobData.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -39,6 +39,12 @@
namespace WebCore {
+BlobData::BlobData(const String& contentType)
+ : m_contentType(contentType)
+{
+ ASSERT(Blob::isNormalizedContentType(contentType));
+}
+
const long long BlobDataItem::toEndOfFile = -1;
long long BlobDataItem::length() const
@@ -46,31 +52,25 @@
if (m_length != toEndOfFile)
return m_length;
- switch (type) {
- case Data:
+ switch (m_type) {
+ case Type::Data:
ASSERT_NOT_REACHED();
return m_length;
- case File:
- return file->size();
+ case Type::File:
+ return m_file->size();
}
ASSERT_NOT_REACHED();
return m_length;
}
-void BlobData::setContentType(const String& contentType)
+void BlobData::appendData(const ThreadSafeDataBuffer& data)
{
- ASSERT(Blob::isNormalizedContentType(contentType));
- m_contentType = contentType;
-}
-
-void BlobData::appendData(PassRefPtr<RawData> data)
-{
- size_t dataSize = data->length();
+ size_t dataSize = data.data() ? data.data()->size() : 0;
appendData(data, 0, dataSize);
}
-void BlobData::appendData(PassRefPtr<RawData> data, long long offset, long long length)
+void BlobData::appendData(const ThreadSafeDataBuffer& data, long long offset, long long length)
{
m_items.append(BlobDataItem(data, offset, length));
}
Modified: trunk/Source/WebCore/platform/network/BlobData.h (198868 => 198869)
--- trunk/Source/WebCore/platform/network/BlobData.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/BlobData.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -32,52 +32,31 @@
#define BlobData_h
#include "BlobDataFileReference.h"
+#include "ThreadSafeDataBuffer.h"
#include "URL.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
+#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
-class RawData : public RefCounted<RawData> {
+class BlobDataItem {
public:
- static Ref<RawData> create(Vector<char>&& data)
- {
- return adoptRef(*new RawData(WTFMove(data)));
- }
-
- static Ref<RawData> create(const char* data, size_t size)
- {
- Vector<char> dataVector(size);
- memcpy(dataVector.data(), data, size);
- return adoptRef(*new RawData(WTFMove(dataVector)));
- }
-
- const char* data() const { return m_data.data(); }
- size_t length() const { return m_data.size(); }
-
-private:
- RawData(Vector<char>&& data)
- : m_data(WTFMove(data))
- {
- }
-
- Vector<char> m_data;
-};
-
-struct BlobDataItem {
WEBCORE_EXPORT static const long long toEndOfFile;
- enum {
+ enum class Type {
Data,
File
- } type;
+ };
+ Type type() const { return m_type; }
+
// For Data type.
- RefPtr<RawData> data;
+ const ThreadSafeDataBuffer& data() const { return m_data; }
// For File type.
- RefPtr<BlobDataFileReference> file;
+ BlobDataFileReference* file() const { return m_file.get(); }
long long offset() const { return m_offset; }
long long length() const; // Computes file length if it's not known yet.
@@ -86,55 +65,59 @@
friend class BlobData;
explicit BlobDataItem(PassRefPtr<BlobDataFileReference> file)
- : type(File)
- , file(file)
+ : m_type(Type::File)
+ , m_file(file)
, m_offset(0)
, m_length(toEndOfFile)
{
}
- BlobDataItem(PassRefPtr<RawData> data, long long offset, long long length)
- : type(Data)
- , data(data)
+ BlobDataItem(ThreadSafeDataBuffer data, long long offset, long long length)
+ : m_type(Type::Data)
+ , m_data(data)
, m_offset(offset)
, m_length(length)
{
}
BlobDataItem(BlobDataFileReference* file, long long offset, long long length)
- : type(File)
- , file(file)
+ : m_type(Type::File)
+ , m_file(file)
, m_offset(offset)
, m_length(length)
{
}
+ Type m_type;
+ ThreadSafeDataBuffer m_data;
+ RefPtr<BlobDataFileReference> m_file;
+
long long m_offset;
long long m_length;
};
typedef Vector<BlobDataItem> BlobDataItemList;
-class BlobData : public RefCounted<BlobData> {
+class BlobData : public ThreadSafeRefCounted<BlobData> {
public:
- static Ref<BlobData> create()
+ static Ref<BlobData> create(const String& contentType)
{
- return adoptRef(*new BlobData);
+ return adoptRef(*new BlobData(contentType));
}
const String& contentType() const { return m_contentType; }
- WEBCORE_EXPORT void setContentType(const String&);
const BlobDataItemList& items() const { return m_items; }
void swapItems(BlobDataItemList&);
- void appendData(PassRefPtr<RawData>);
+ void appendData(const ThreadSafeDataBuffer&);
void appendFile(PassRefPtr<BlobDataFileReference>);
private:
friend class BlobRegistryImpl;
+ BlobData(const String& contentType);
- void appendData(PassRefPtr<RawData>, long long offset, long long length);
+ void appendData(const ThreadSafeDataBuffer&, long long offset, long long length);
void appendFile(BlobDataFileReference*, long long offset, long long length);
String m_contentType;
Modified: trunk/Source/WebCore/platform/network/BlobPart.h (198868 => 198869)
--- trunk/Source/WebCore/platform/network/BlobPart.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/BlobPart.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -42,7 +42,7 @@
{
}
- BlobPart(Vector<char> data)
+ BlobPart(Vector<uint8_t> data)
: m_type(Data)
, m_data(WTFMove(data))
{
@@ -56,13 +56,13 @@
Type type() const { return m_type; }
- const Vector<char>& data() const
+ const Vector<uint8_t>& data() const
{
ASSERT(m_type == Data);
return m_data;
}
- Vector<char> moveData()
+ Vector<uint8_t> moveData()
{
ASSERT(m_type == Data);
return WTFMove(m_data);
@@ -81,7 +81,7 @@
private:
Type m_type;
- Vector<char> m_data;
+ Vector<uint8_t> m_data;
URL m_url;
};
Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (198868 => 198869)
--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -98,11 +98,11 @@
for (; iter != items.end() && length > 0; ++iter) {
long long currentLength = iter->length() - offset;
long long newLength = currentLength > length ? length : currentLength;
- if (iter->type == BlobDataItem::Data)
- blobData->appendData(iter->data, iter->offset() + offset, newLength);
+ if (iter->type() == BlobDataItem::Type::Data)
+ blobData->appendData(iter->data(), iter->offset() + offset, newLength);
else {
- ASSERT(iter->type == BlobDataItem::File);
- blobData->appendFile(iter->file.get(), iter->offset() + offset, newLength);
+ ASSERT(iter->type() == BlobDataItem::Type::File);
+ blobData->appendFile(iter->file(), iter->offset() + offset, newLength);
}
length -= newLength;
offset = 0;
@@ -115,8 +115,7 @@
ASSERT(isMainThread());
registerBlobResourceHandleConstructor();
- RefPtr<BlobData> blobData = BlobData::create();
- blobData->setContentType(contentType);
+ RefPtr<BlobData> blobData = BlobData::create(contentType);
blobData->appendFile(file);
m_blobs.set(url.string(), blobData.release());
@@ -127,8 +126,7 @@
ASSERT(isMainThread());
registerBlobResourceHandleConstructor();
- RefPtr<BlobData> blobData = BlobData::create();
- blobData->setContentType(contentType);
+ RefPtr<BlobData> blobData = BlobData::create(contentType);
// The blob data is stored in the "canonical" way. That is, it only contains a list of Data and File items.
// 1) The Data item is denoted by the raw data and the range.
@@ -139,8 +137,9 @@
for (BlobPart& part : blobParts) {
switch (part.type()) {
case BlobPart::Data: {
- RefPtr<RawData> rawData = RawData::create(part.moveData());
- blobData->appendData(rawData.release());
+ auto movedData = part.moveData();
+ auto data = ""
+ blobData->appendData(data);
break;
}
case BlobPart::Blob: {
@@ -196,8 +195,7 @@
end = originalSize;
unsigned long long newLength = end - start;
- RefPtr<BlobData> newData = BlobData::create();
- newData->setContentType(originalData->contentType());
+ RefPtr<BlobData> newData = BlobData::create(originalData->contentType());
appendStorageItems(newData.get(), originalData->items(), start, newLength);
Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (198868 => 198869)
--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -253,16 +253,16 @@
}
const BlobDataItem& item = m_blobData->items().at(m_sizeItemCount);
- switch (item.type) {
- case BlobDataItem::Data:
+ switch (item.type()) {
+ case BlobDataItem::Type::Data:
didGetSize(item.length());
break;
- case BlobDataItem::File:
+ case BlobDataItem::Type::File:
// Files know their sizes, but asking the stream to verify that the file wasn't modified.
if (m_async)
- m_asyncStream->getSize(item.file->path(), item.file->expectedModificationTime());
+ m_asyncStream->getSize(item.file()->path(), item.file()->expectedModificationTime());
else
- didGetSize(m_stream->getSize(item.file->path(), item.file->expectedModificationTime()));
+ didGetSize(m_stream->getSize(item.file()->path(), item.file()->expectedModificationTime()));
break;
default:
ASSERT_NOT_REACHED();
@@ -351,9 +351,9 @@
const BlobDataItem& item = m_blobData->items().at(m_readItemCount);
int bytesRead = 0;
- if (item.type == BlobDataItem::Data)
+ if (item.type() == BlobDataItem::Type::Data)
bytesRead = readDataSync(item, buf + offset, remaining);
- else if (item.type == BlobDataItem::File)
+ else if (item.type() == BlobDataItem::Type::File)
bytesRead = readFileSync(item, buf + offset, remaining);
else
ASSERT_NOT_REACHED();
@@ -389,7 +389,7 @@
int bytesToRead = (length > remaining) ? static_cast<int>(remaining) : length;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = static_cast<int>(m_totalRemainingSize);
- memcpy(buf, item.data->data() + item.offset() + m_currentItemReadSize, bytesToRead);
+ memcpy(buf, item.data().data() + item.offset() + m_currentItemReadSize, bytesToRead);
m_totalRemainingSize -= bytesToRead;
m_currentItemReadSize += bytesToRead;
@@ -411,7 +411,7 @@
long long bytesToRead = m_itemLengthList[m_readItemCount] - m_currentItemReadSize;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = m_totalRemainingSize;
- bool success = m_stream->openForRead(item.file->path(), item.offset() + m_currentItemReadSize, bytesToRead);
+ bool success = m_stream->openForRead(item.file()->path(), item.offset() + m_currentItemReadSize, bytesToRead);
m_currentItemReadSize = 0;
if (!success) {
m_errorCode = notReadableError;
@@ -452,9 +452,9 @@
}
const BlobDataItem& item = m_blobData->items().at(m_readItemCount);
- if (item.type == BlobDataItem::Data)
+ if (item.type() == BlobDataItem::Type::Data)
readDataAsync(item);
- else if (item.type == BlobDataItem::File)
+ else if (item.type() == BlobDataItem::Type::File)
readFileAsync(item);
else
ASSERT_NOT_REACHED();
@@ -464,12 +464,14 @@
{
ASSERT(isMainThread());
ASSERT(m_async);
+ ASSERT(item.data().data());
+
Ref<BlobResourceHandle> protect(*this);
long long bytesToRead = item.length() - m_currentItemReadSize;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = m_totalRemainingSize;
- consumeData(item.data->data() + item.offset() + m_currentItemReadSize, static_cast<int>(bytesToRead));
+ consumeData(reinterpret_cast<const char*>(item.data().data()->data()) + item.offset() + m_currentItemReadSize, static_cast<int>(bytesToRead));
m_currentItemReadSize = 0;
}
@@ -486,7 +488,7 @@
long long bytesToRead = m_itemLengthList[m_readItemCount] - m_currentItemReadSize;
if (bytesToRead > m_totalRemainingSize)
bytesToRead = static_cast<int>(m_totalRemainingSize);
- m_asyncStream->openForRead(item.file->path(), item.offset() + m_currentItemReadSize, bytesToRead);
+ m_asyncStream->openForRead(item.file()->path(), item.offset() + m_currentItemReadSize, bytesToRead);
m_fileOpened = true;
m_currentItemReadSize = 0;
}
Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.h (198868 => 198869)
--- trunk/Source/WebCore/platform/network/BlobResourceHandle.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -44,7 +44,7 @@
class FileStream;
class ResourceHandleClient;
class ResourceRequest;
-struct BlobDataItem;
+class BlobDataItem;
class BlobResourceHandle final : public FileStreamClient, public ResourceHandle {
public:
Modified: trunk/Source/WebCore/platform/network/FormData.cpp (198868 => 198869)
--- trunk/Source/WebCore/platform/network/FormData.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/FormData.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -293,10 +293,11 @@
const BlobDataItemList::const_iterator itend = blobData->items().end();
for (; it != itend; ++it) {
const BlobDataItem& blobItem = *it;
- if (blobItem.type == BlobDataItem::Data)
- formData->appendData(blobItem.data->data() + static_cast<int>(blobItem.offset()), static_cast<int>(blobItem.length()));
- else if (blobItem.type == BlobDataItem::File)
- formData->appendFileRange(blobItem.file->path(), blobItem.offset(), blobItem.length(), blobItem.file->expectedModificationTime());
+ if (blobItem.type() == BlobDataItem::Type::Data) {
+ ASSERT(blobItem.data().data());
+ formData->appendData(blobItem.data().data()->data() + static_cast<int>(blobItem.offset()), static_cast<int>(blobItem.length()));
+ } else if (blobItem.type() == BlobDataItem::Type::File)
+ formData->appendFileRange(blobItem.file()->path(), blobItem.offset(), blobItem.length(), blobItem.file()->expectedModificationTime());
else
ASSERT_NOT_REACHED();
}
Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (198868 => 198869)
--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -769,30 +769,30 @@
static bool blobIsOutOfDate(const BlobDataItem& blobItem)
{
- ASSERT(blobItem.type == BlobDataItem::File);
- if (!isValidFileTime(blobItem.file->expectedModificationTime()))
+ ASSERT(blobItem.type == BlobDataItem::Type::File);
+ if (!isValidFileTime(blobItem.file()->expectedModificationTime()))
return false;
time_t fileModificationTime;
- if (!getFileModificationTime(blobItem.file->path(), fileModificationTime))
+ if (!getFileModificationTime(blobItem.file()->path(), fileModificationTime))
return true;
- return fileModificationTime != static_cast<time_t>(blobItem.file->expectedModificationTime());
+ return fileModificationTime != static_cast<time_t>(blobItem.file()->expectedModificationTime());
}
static void addEncodedBlobItemToSoupMessageBody(SoupMessage* message, const BlobDataItem& blobItem, unsigned long& totalBodySize)
{
- if (blobItem.type == BlobDataItem::Data) {
+ if (blobItem.type() == BlobDataItem::Type::Data) {
totalBodySize += blobItem.length();
- soup_message_body_append(message->request_body, SOUP_MEMORY_TEMPORARY, blobItem.data->data() + blobItem.offset(), blobItem.length());
+ soup_message_body_append(message->request_body, SOUP_MEMORY_TEMPORARY, blobItem.data().data()->data() + blobItem.offset(), blobItem.length());
return;
}
- ASSERT(blobItem.type == BlobDataItem::File);
+ ASSERT(blobItem.type == BlobDataItem::Type::File);
if (blobIsOutOfDate(blobItem))
return;
- addFileToSoupMessageBody(message, blobItem.file->path(), blobItem.offset(), blobItem.length() == BlobDataItem::toEndOfFile ? 0 : blobItem.length(), totalBodySize);
+ addFileToSoupMessageBody(message, blobItem.file()->path(), blobItem.offset(), blobItem.length() == BlobDataItem::toEndOfFile ? 0 : blobItem.length(), totalBodySize);
}
static void addEncodedBlobToSoupMessageBody(SoupMessage* message, const FormDataElement& element, unsigned long& totalBodySize)
Modified: trunk/Source/WebCore/platform/text/LineEnding.cpp (198868 => 198869)
--- trunk/Source/WebCore/platform/text/LineEnding.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/text/LineEnding.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -153,10 +153,8 @@
namespace WebCore {
-void normalizeToCROrLF(const CString& from, Vector<char>& result, bool toCR);
-
// Normalize all line-endings to CR or LF.
-void normalizeToCROrLF(const CString& from, Vector<char>& result, bool toCR)
+static void normalizeToCROrLF(const CString& from, Vector<uint8_t>& result, bool toCR)
{
// Compute the new length.
size_t newLen = 0;
@@ -181,7 +179,7 @@
p = from.data();
size_t oldResultSize = result.size();
result.grow(oldResultSize + newLen);
- char* q = result.data() + oldResultSize;
+ uint8_t* q = result.data() + oldResultSize;
// If no need to fix the string, just copy the string over.
if (!needFix) {
@@ -214,23 +212,13 @@
return buffer.buffer();
}
-void normalizeLineEndingsToCR(const CString& from, Vector<char>& result)
+void normalizeLineEndingsToNative(const CString& from, Vector<uint8_t>& result)
{
- normalizeToCROrLF(from, result, true);
-}
-
-void normalizeLineEndingsToLF(const CString& from, Vector<char>& result)
-{
- normalizeToCROrLF(from, result, false);
-}
-
-void normalizeLineEndingsToNative(const CString& from, Vector<char>& result)
-{
#if OS(WINDOWS)
VectorCharAppendBuffer buffer(result);
internalNormalizeLineEndingsToCRLF(from, buffer);
#else
- normalizeLineEndingsToLF(from, result);
+ normalizeToCROrLF(from, result, false);
#endif
}
Modified: trunk/Source/WebCore/platform/text/LineEnding.h (198868 => 198869)
--- trunk/Source/WebCore/platform/text/LineEnding.h 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/platform/text/LineEnding.h 2016-03-31 01:21:04 UTC (rev 198869)
@@ -40,15 +40,9 @@
// Normalize all line-endings in the given string to CRLF.
CString normalizeLineEndingsToCRLF(const CString& from);
-// Normalize all line-endings in the given string to CR and append the result to the given buffer.
-void normalizeLineEndingsToCR(const CString& from, Vector<char>& result);
-
-// Normalize all line-endings in the given string to LF and append the result to the given buffer.
-void normalizeLineEndingsToLF(const CString& from, Vector<char>& result);
-
// Normalize all line-endings in the given string to the native line-endings and append the result to the given buffer.
// (Normalize to CRLF on Windows and normalize to LF on all other platforms.)
-void normalizeLineEndingsToNative(const CString& from, Vector<char>& result);
+void normalizeLineEndingsToNative(const CString& from, Vector<uint8_t>& result);
} // namespace WebCore
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (198868 => 198869)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -238,7 +238,7 @@
if (!m_responseBlob) {
if (m_binaryResponseBuilder) {
// FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient.
- Vector<char> data;
+ Vector<uint8_t> data;
data.append(m_binaryResponseBuilder->data(), m_binaryResponseBuilder->size());
String normalizedContentType = Blob::normalizedContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
m_responseBlob = Blob::create(WTFMove(data), normalizedContentType);
Modified: trunk/Source/WebKit2/ChangeLog (198868 => 198869)
--- trunk/Source/WebKit2/ChangeLog 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-31 01:21:04 UTC (rev 198869)
@@ -1,3 +1,15 @@
+2016-03-30 Brady Eidson <[email protected]>
+
+ Make BlobData use ThreadSafeSharedBuffer instead of RawData.
+ https://bugs.webkit.org/show_bug.cgi?id=156041
+
+ Reviewed by Alex Christensen.
+
+ * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
+ (WebKit::NetworkBlobRegistry::filesInBlob):
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<BlobPart>::decode):
+
2016-03-30 Daniel Bates <[email protected]>
Unreviewed, rolling out r198856.
Modified: trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp (198868 => 198869)
--- trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -141,8 +141,8 @@
Vector<RefPtr<BlobDataFileReference>> result;
for (const BlobDataItem& item : blobData->items()) {
- if (item.type == BlobDataItem::File)
- result.append(item.file);
+ if (item.type() == BlobDataItem::Type::File)
+ result.append(item.file());
}
return result;
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (198868 => 198869)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2016-03-31 00:47:15 UTC (rev 198868)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2016-03-31 01:21:04 UTC (rev 198869)
@@ -1861,7 +1861,7 @@
switch (type) {
case BlobPart::Data: {
- Vector<char> data;
+ Vector<uint8_t> data;
if (!decoder.decode(data))
return false;
blobPart = BlobPart(WTFMove(data));