Changeset 198869 in webkit


Ignore:
Timestamp:
Mar 30, 2016 6:21:04 PM (8 years ago)
Author:
beidson@apple.com
Message:

Make BlobData use ThreadSafeSharedBuffer instead of RawData.
https://bugs.webkit.org/show_bug.cgi?id=156041

Reviewed by Alex Christensen.

Source/WebCore:

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):

Source/WebKit2:

  • NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:

(WebKit::NetworkBlobRegistry::filesInBlob):

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<BlobPart>::decode):

Location:
trunk/Source
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r198864 r198869  
     12016-03-30  Brady Eidson  <beidson@apple.com>
     2
     3        Make BlobData use ThreadSafeSharedBuffer instead of RawData.
     4        https://bugs.webkit.org/show_bug.cgi?id=156041
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests (No change in behavior).
     9
     10        * Modules/fetch/FetchBody.cpp:
     11        (WebCore::FetchBody::consumeText):
     12        (WebCore::FetchBody::extractFromText):
     13        (WebCore::blobFromArrayBuffer):
     14        * Modules/fetch/FetchBody.h:
     15        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
     16        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData):
     17        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:
     18        * Modules/websockets/WebSocket.cpp:
     19        (WebCore::WebSocket::didReceiveBinaryData):
     20        * Modules/websockets/WebSocket.h:
     21        * Modules/websockets/WebSocketChannel.cpp:
     22        (WebCore::WebSocketChannel::processFrame):
     23        * Modules/websockets/WebSocketChannel.h:
     24        * Modules/websockets/WebSocketChannelClient.h:
     25        (WebCore::WebSocketChannelClient::didReceiveBinaryData):
     26        * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
     27        (WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData):
     28        * Modules/websockets/WorkerThreadableWebSocketChannel.h:
     29        * fileapi/Blob.cpp:
     30        (WebCore::Blob::Blob):
     31        * fileapi/Blob.h:
     32        (WebCore::Blob::create):
     33        * fileapi/WebKitBlobBuilder.h:
     34        * platform/network/BlobData.cpp:
     35        (WebCore::BlobData::BlobData):
     36        (WebCore::BlobDataItem::length):
     37        (WebCore::BlobData::appendData):
     38        (WebCore::BlobData::setContentType): Deleted.
     39        * platform/network/BlobData.h:
     40        (WebCore::BlobDataItem::type):
     41        (WebCore::BlobDataItem::data):
     42        (WebCore::BlobDataItem::file):
     43        (WebCore::BlobDataItem::BlobDataItem):
     44        (WebCore::BlobData::create):
     45        (WebCore::RawData::create): Deleted.
     46        (WebCore::RawData::data): Deleted.
     47        (WebCore::RawData::length): Deleted.
     48        (WebCore::RawData::RawData): Deleted.
     49        * platform/network/BlobPart.h:
     50        (WebCore::BlobPart::BlobPart):
     51        (WebCore::BlobPart::data):
     52        (WebCore::BlobPart::moveData):
     53        * platform/network/BlobRegistryImpl.cpp:
     54        (WebCore::BlobRegistryImpl::appendStorageItems):
     55        (WebCore::BlobRegistryImpl::registerFileBlobURL):
     56        (WebCore::BlobRegistryImpl::registerBlobURL):
     57        (WebCore::BlobRegistryImpl::registerBlobURLForSlice):
     58        * platform/network/BlobResourceHandle.cpp:
     59        (WebCore::BlobResourceHandle::getSizeForNext):
     60        (WebCore::BlobResourceHandle::readSync):
     61        (WebCore::BlobResourceHandle::readDataSync):
     62        (WebCore::BlobResourceHandle::readFileSync):
     63        (WebCore::BlobResourceHandle::readAsync):
     64        (WebCore::BlobResourceHandle::readDataAsync):
     65        (WebCore::BlobResourceHandle::readFileAsync):
     66        * platform/network/BlobResourceHandle.h:
     67        * platform/network/FormData.cpp:
     68        (WebCore::appendBlobResolved):
     69        * platform/network/soup/ResourceHandleSoup.cpp:
     70        (WebCore::blobIsOutOfDate):
     71        (WebCore::addEncodedBlobItemToSoupMessageBody):
     72        * platform/text/LineEnding.cpp:
     73        (WebCore::normalizeToCROrLF):
     74        (WebCore::normalizeLineEndingsToNative):
     75        (WebCore::normalizeLineEndingsToCR): Deleted.
     76        (WebCore::normalizeLineEndingsToLF): Deleted.
     77        * platform/text/LineEnding.h:
     78        * xml/XMLHttpRequest.cpp:
     79        (WebCore::XMLHttpRequest::responseBlob):
     80
    1812016-03-30  Enrica Casucci  <enrica@apple.com>
    282
  • trunk/Source/WebCore/Modules/fetch/FetchBody.cpp

    r198665 r198869  
    202202
    203203    if (type == Consumer::Type::ArrayBuffer) {
    204         Vector<char> data = extractFromText();
     204        Vector<uint8_t> data = extractFromText();
    205205        fulfillPromiseWithArrayBuffer(promise, data.data(), data.size());
    206206        return;
     
    233233}
    234234
    235 Vector<char> FetchBody::extractFromText() const
     235Vector<uint8_t> FetchBody::extractFromText() const
    236236{
    237237    ASSERT(m_type == Type::Text);
    238238    // FIXME: This double allocation is not efficient. Might want to fix that at WTFString level.
    239239    CString data = m_text.utf8();
    240     Vector<char> value(data.length());
     240    Vector<uint8_t> value(data.length());
    241241    memcpy(value.data(), data.data(), data.length());
    242242    return value;
     
    246246{
    247247    if (!buffer)
    248         return Blob::create(Vector<char>(), contentType);
     248        return Blob::create(Vector<uint8_t>(), contentType);
    249249
    250250    // FIXME: We should try to move buffer to Blob without doing this copy.
    251     Vector<char> value(buffer->byteLength());
     251    Vector<uint8_t> value(buffer->byteLength());
    252252    memcpy(value.data(), buffer->data(), buffer->byteLength());
    253253    return Blob::create(WTFMove(value), contentType);
  • trunk/Source/WebCore/Modules/fetch/FetchBody.h

    r198665 r198869  
    8888    void consume(FetchBodyOwner&, Consumer::Type, DeferredWrapper&&);
    8989
    90     Vector<char> extractFromText() const;
     90    Vector<uint8_t> extractFromText() const;
    9191    bool processIfEmptyOrDisturbed(Consumer::Type, DeferredWrapper&);
    9292    void consumeArrayBuffer(Consumer::Type, DeferredWrapper&);
  • trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp

    r194496 r198869  
    181181}
    182182
    183 void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData(Vector<char>&& binaryData)
    184 {
    185     ref();
    186     Vector<char>* capturedData = new Vector<char>(WTFMove(binaryData));
     183void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
     184{
     185    ref();
     186    Vector<uint8_t>* capturedData = new Vector<uint8_t>(WTFMove(binaryData));
    187187    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, capturedData] (ScriptExecutionContext&) {
    188188        if (m_client)
  • trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h

    r184709 r198869  
    8080    void didConnect();
    8181    void didReceiveMessage(const String& message);
    82     void didReceiveBinaryData(Vector<char>&&);
     82    void didReceiveBinaryData(Vector<uint8_t>&&);
    8383    void didUpdateBufferedAmount(unsigned long bufferedAmount);
    8484    void didStartClosingHandshake();
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r198482 r198869  
    562562}
    563563
    564 void WebSocket::didReceiveBinaryData(Vector<char>&& binaryData)
     564void WebSocket::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
    565565{
    566566    LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message", this, static_cast<unsigned long>(binaryData.size()));
  • trunk/Source/WebCore/Modules/websockets/WebSocket.h

    r198482 r198869  
    101101    void didConnect() override;
    102102    void didReceiveMessage(const String& message) override;
    103     void didReceiveBinaryData(Vector<char>&&) override;
     103    void didReceiveBinaryData(Vector<uint8_t>&&) override;
    104104    void didReceiveMessageError() override;
    105105    void didUpdateBufferedAmount(unsigned long bufferedAmount) override;
  • trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp

    r194496 r198869  
    587587            // make sure that the member variables are in a consistent state before
    588588            // the handler is invoked.
    589             Vector<char> continuousFrameData = WTFMove(m_continuousFrameData);
     589            Vector<uint8_t> continuousFrameData = WTFMove(m_continuousFrameData);
    590590            m_hasContinuousFrame = false;
    591591            if (m_continuousFrameOpCode == WebSocketFrame::OpCodeText) {
     
    627627    case WebSocketFrame::OpCodeBinary:
    628628        if (frame.final) {
    629             Vector<char> binaryData(frame.payloadLength);
     629            Vector<uint8_t> binaryData(frame.payloadLength);
    630630            memcpy(binaryData.data(), frame.payload, frame.payloadLength);
    631631            skipBuffer(frameEnd - m_buffer.data());
  • trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h

    r197563 r198869  
    205205    bool m_hasContinuousFrame;
    206206    WebSocketFrame::OpCode m_continuousFrameOpCode;
    207     Vector<char> m_continuousFrameData;
     207    Vector<uint8_t> m_continuousFrameData;
    208208    unsigned short m_closeEventCode;
    209209    String m_closeEventReason;
  • trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h

    r183234 r198869  
    4444        virtual void didConnect() { }
    4545        virtual void didReceiveMessage(const String&) { }
    46         virtual void didReceiveBinaryData(Vector<char>&&) { }
     46        virtual void didReceiveBinaryData(Vector<uint8_t>&&) { }
    4747        virtual void didReceiveMessageError() { }
    4848        virtual void didUpdateBufferedAmount(unsigned long /* bufferedAmount */) { }
  • trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp

    r194496 r198869  
    289289}
    290290
    291 void WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData(Vector<char>&& binaryData)
    292 {
    293     ASSERT(isMainThread());
    294 
    295     RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper;
    296     Vector<char>* capturedData = new Vector<char>(WTFMove(binaryData));
     291void WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
     292{
     293    ASSERT(isMainThread());
     294
     295    RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper;
     296    Vector<uint8_t>* capturedData = new Vector<uint8_t>(WTFMove(binaryData));
    297297    m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper, capturedData] (ScriptExecutionContext& context) {
    298298        ASSERT_UNUSED(context, context.isWorkerGlobalScope());
  • trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h

    r197563 r198869  
    101101        void didConnect() override;
    102102        void didReceiveMessage(const String& message) override;
    103         void didReceiveBinaryData(Vector<char>&&) override;
     103        void didReceiveBinaryData(Vector<uint8_t>&&) override;
    104104        void didUpdateBufferedAmount(unsigned long bufferedAmount) override;
    105105        void didStartClosingHandshake() override;
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r197563 r198869  
    7878}
    7979
    80 Blob::Blob(Vector<char> data, const String& contentType)
     80Blob::Blob(Vector<uint8_t> data, const String& contentType)
    8181    : m_type(contentType)
    8282    , m_size(data.size())
  • trunk/Source/WebCore/fileapi/Blob.h

    r197563 r198869  
    4949    }
    5050
    51     static Ref<Blob> create(Vector<char> data, const String& contentType)
     51    static Ref<Blob> create(Vector<uint8_t> data, const String& contentType)
    5252    {
    5353        return adoptRef(*new Blob(WTFMove(data), contentType));
     
    9292protected:
    9393    Blob();
    94     Blob(Vector<char>, const String& contentType);
     94    Blob(Vector<uint8_t>, const String& contentType);
    9595    Blob(Vector<BlobPart>, const String& contentType);
    9696
  • trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h

    r189650 r198869  
    5656private:
    5757    Vector<BlobPart> m_items;
    58     Vector<char> m_appendableData;
     58    Vector<uint8_t> m_appendableData;
    5959};
    6060
  • trunk/Source/WebCore/platform/network/BlobData.cpp

    r183234 r198869  
    4040namespace WebCore {
    4141
     42BlobData::BlobData(const String& contentType)
     43    : m_contentType(contentType)
     44{
     45    ASSERT(Blob::isNormalizedContentType(contentType));
     46}
     47
    4248const long long BlobDataItem::toEndOfFile = -1;
    4349
     
    4753        return m_length;
    4854
    49     switch (type) {
    50     case Data:
     55    switch (m_type) {
     56    case Type::Data:
    5157        ASSERT_NOT_REACHED();
    5258        return m_length;
    53     case File:
    54         return file->size();
     59    case Type::File:
     60        return m_file->size();
    5561    }
    5662
     
    5965}
    6066
    61 void BlobData::setContentType(const String& contentType)
     67void BlobData::appendData(const ThreadSafeDataBuffer& data)
    6268{
    63     ASSERT(Blob::isNormalizedContentType(contentType));
    64     m_contentType = contentType;
    65 }
    66 
    67 void BlobData::appendData(PassRefPtr<RawData> data)
    68 {
    69     size_t dataSize = data->length();
     69    size_t dataSize = data.data() ? data.data()->size() : 0;
    7070    appendData(data, 0, dataSize);
    7171}
    7272
    73 void BlobData::appendData(PassRefPtr<RawData> data, long long offset, long long length)
     73void BlobData::appendData(const ThreadSafeDataBuffer& data, long long offset, long long length)
    7474{
    7575    m_items.append(BlobDataItem(data, offset, length));
  • trunk/Source/WebCore/platform/network/BlobData.h

    r194496 r198869  
    3333
    3434#include "BlobDataFileReference.h"
     35#include "ThreadSafeDataBuffer.h"
    3536#include "URL.h"
    3637#include <wtf/Forward.h>
    3738#include <wtf/RefCounted.h>
     39#include <wtf/ThreadSafeRefCounted.h>
    3840#include <wtf/text/WTFString.h>
    3941
    4042namespace WebCore {
    4143
    42 class RawData : public RefCounted<RawData> {
     44class BlobDataItem {
    4345public:
    44     static Ref<RawData> create(Vector<char>&& data)
    45     {
    46         return adoptRef(*new RawData(WTFMove(data)));
    47     }
    48 
    49     static Ref<RawData> create(const char* data, size_t size)
    50     {
    51         Vector<char> dataVector(size);
    52         memcpy(dataVector.data(), data, size);
    53         return adoptRef(*new RawData(WTFMove(dataVector)));
    54     }
    55 
    56     const char* data() const { return m_data.data(); }
    57     size_t length() const { return m_data.size(); }
    58 
    59 private:
    60     RawData(Vector<char>&& data)
    61         : m_data(WTFMove(data))
    62     {
    63     }
    64 
    65     Vector<char> m_data;
    66 };
    67 
    68 struct BlobDataItem {
    6946    WEBCORE_EXPORT static const long long toEndOfFile;
    7047
    71     enum {
     48    enum class Type {
    7249        Data,
    7350        File
    74     } type;
     51    };
     52
     53    Type type() const { return m_type; }
    7554
    7655    // For Data type.
    77     RefPtr<RawData> data;
     56    const ThreadSafeDataBuffer& data() const { return m_data; }
    7857
    7958    // For File type.
    80     RefPtr<BlobDataFileReference> file;
     59    BlobDataFileReference* file() const { return m_file.get(); }
    8160
    8261    long long offset() const { return m_offset; }
     
    8766
    8867    explicit BlobDataItem(PassRefPtr<BlobDataFileReference> file)
    89         : type(File)
    90         , file(file)
     68        : m_type(Type::File)
     69        , m_file(file)
    9170        , m_offset(0)
    9271        , m_length(toEndOfFile)
     
    9473    }
    9574
    96     BlobDataItem(PassRefPtr<RawData> data, long long offset, long long length)
    97         : type(Data)
    98         , data(data)
     75    BlobDataItem(ThreadSafeDataBuffer data, long long offset, long long length)
     76        : m_type(Type::Data)
     77        , m_data(data)
    9978        , m_offset(offset)
    10079        , m_length(length)
     
    10382
    10483    BlobDataItem(BlobDataFileReference* file, long long offset, long long length)
    105         : type(File)
    106         , file(file)
     84        : m_type(Type::File)
     85        , m_file(file)
    10786        , m_offset(offset)
    10887        , m_length(length)
    10988    {
    11089    }
     90
     91    Type m_type;
     92    ThreadSafeDataBuffer m_data;
     93    RefPtr<BlobDataFileReference> m_file;
    11194
    11295    long long m_offset;
     
    11699typedef Vector<BlobDataItem> BlobDataItemList;
    117100
    118 class BlobData : public RefCounted<BlobData> {
     101class BlobData : public ThreadSafeRefCounted<BlobData> {
    119102public:
    120     static Ref<BlobData> create()
     103    static Ref<BlobData> create(const String& contentType)
    121104    {
    122         return adoptRef(*new BlobData);
     105        return adoptRef(*new BlobData(contentType));
    123106    }
    124107
    125108    const String& contentType() const { return m_contentType; }
    126     WEBCORE_EXPORT void setContentType(const String&);
    127109
    128110    const BlobDataItemList& items() const { return m_items; }
    129111    void swapItems(BlobDataItemList&);
    130112
    131     void appendData(PassRefPtr<RawData>);
     113    void appendData(const ThreadSafeDataBuffer&);
    132114    void appendFile(PassRefPtr<BlobDataFileReference>);
    133115
    134116private:
    135117    friend class BlobRegistryImpl;
     118    BlobData(const String& contentType);
    136119
    137     void appendData(PassRefPtr<RawData>, long long offset, long long length);
     120    void appendData(const ThreadSafeDataBuffer&, long long offset, long long length);
    138121    void appendFile(BlobDataFileReference*, long long offset, long long length);
    139122
  • trunk/Source/WebCore/platform/network/BlobPart.h

    r194496 r198869  
    4343    }
    4444
    45     BlobPart(Vector<char> data)
     45    BlobPart(Vector<uint8_t> data)
    4646        : m_type(Data)
    4747        , m_data(WTFMove(data))
     
    5757    Type type() const { return m_type; }
    5858
    59     const Vector<char>& data() const
     59    const Vector<uint8_t>& data() const
    6060    {
    6161        ASSERT(m_type == Data);
     
    6363    }
    6464
    65     Vector<char> moveData()
     65    Vector<uint8_t> moveData()
    6666    {
    6767        ASSERT(m_type == Data);
     
    8282private:
    8383    Type m_type;
    84     Vector<char> m_data;
     84    Vector<uint8_t> m_data;
    8585    URL m_url;
    8686};
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp

    r196174 r198869  
    9999        long long currentLength = iter->length() - offset;
    100100        long long newLength = currentLength > length ? length : currentLength;
    101         if (iter->type == BlobDataItem::Data)
    102             blobData->appendData(iter->data, iter->offset() + offset, newLength);
     101        if (iter->type() == BlobDataItem::Type::Data)
     102            blobData->appendData(iter->data(), iter->offset() + offset, newLength);
    103103        else {
    104             ASSERT(iter->type == BlobDataItem::File);
    105             blobData->appendFile(iter->file.get(), iter->offset() + offset, newLength);
     104            ASSERT(iter->type() == BlobDataItem::Type::File);
     105            blobData->appendFile(iter->file(), iter->offset() + offset, newLength);
    106106        }
    107107        length -= newLength;
     
    116116    registerBlobResourceHandleConstructor();
    117117
    118     RefPtr<BlobData> blobData = BlobData::create();
    119     blobData->setContentType(contentType);
     118    RefPtr<BlobData> blobData = BlobData::create(contentType);
    120119
    121120    blobData->appendFile(file);
     
    128127    registerBlobResourceHandleConstructor();
    129128
    130     RefPtr<BlobData> blobData = BlobData::create();
    131     blobData->setContentType(contentType);
     129    RefPtr<BlobData> blobData = BlobData::create(contentType);
    132130
    133131    // The blob data is stored in the "canonical" way. That is, it only contains a list of Data and File items.
     
    140138        switch (part.type()) {
    141139        case BlobPart::Data: {
    142             RefPtr<RawData> rawData = RawData::create(part.moveData());
    143             blobData->appendData(rawData.release());
     140            auto movedData = part.moveData();
     141            auto data = ThreadSafeDataBuffer::adoptVector(movedData);
     142            blobData->appendData(data);
    144143            break;
    145144        }
     
    197196
    198197    unsigned long long newLength = end - start;
    199     RefPtr<BlobData> newData = BlobData::create();
    200     newData->setContentType(originalData->contentType());
     198    RefPtr<BlobData> newData = BlobData::create(originalData->contentType());
    201199
    202200    appendStorageItems(newData.get(), originalData->items(), start, newLength);
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r198665 r198869  
    254254
    255255    const BlobDataItem& item = m_blobData->items().at(m_sizeItemCount);
    256     switch (item.type) {
    257     case BlobDataItem::Data:
     256    switch (item.type()) {
     257    case BlobDataItem::Type::Data:
    258258        didGetSize(item.length());
    259259        break;
    260     case BlobDataItem::File:
     260    case BlobDataItem::Type::File:
    261261        // Files know their sizes, but asking the stream to verify that the file wasn't modified.
    262262        if (m_async)
    263             m_asyncStream->getSize(item.file->path(), item.file->expectedModificationTime());
     263            m_asyncStream->getSize(item.file()->path(), item.file()->expectedModificationTime());
    264264        else
    265             didGetSize(m_stream->getSize(item.file->path(), item.file->expectedModificationTime()));
     265            didGetSize(m_stream->getSize(item.file()->path(), item.file()->expectedModificationTime()));
    266266        break;
    267267    default:
     
    352352        const BlobDataItem& item = m_blobData->items().at(m_readItemCount);
    353353        int bytesRead = 0;
    354         if (item.type == BlobDataItem::Data)
     354        if (item.type() == BlobDataItem::Type::Data)
    355355            bytesRead = readDataSync(item, buf + offset, remaining);
    356         else if (item.type == BlobDataItem::File)
     356        else if (item.type() == BlobDataItem::Type::File)
    357357            bytesRead = readFileSync(item, buf + offset, remaining);
    358358        else
     
    390390    if (bytesToRead > m_totalRemainingSize)
    391391        bytesToRead = static_cast<int>(m_totalRemainingSize);
    392     memcpy(buf, item.data->data() + item.offset() + m_currentItemReadSize, bytesToRead);
     392    memcpy(buf, item.data().data() + item.offset() + m_currentItemReadSize, bytesToRead);
    393393    m_totalRemainingSize -= bytesToRead;
    394394
     
    412412        if (bytesToRead > m_totalRemainingSize)
    413413            bytesToRead = m_totalRemainingSize;
    414         bool success = m_stream->openForRead(item.file->path(), item.offset() + m_currentItemReadSize, bytesToRead);
     414        bool success = m_stream->openForRead(item.file()->path(), item.offset() + m_currentItemReadSize, bytesToRead);
    415415        m_currentItemReadSize = 0;
    416416        if (!success) {
     
    453453
    454454    const BlobDataItem& item = m_blobData->items().at(m_readItemCount);
    455     if (item.type == BlobDataItem::Data)
     455    if (item.type() == BlobDataItem::Type::Data)
    456456        readDataAsync(item);
    457     else if (item.type == BlobDataItem::File)
     457    else if (item.type() == BlobDataItem::Type::File)
    458458        readFileAsync(item);
    459459    else
     
    465465    ASSERT(isMainThread());
    466466    ASSERT(m_async);
     467    ASSERT(item.data().data());
     468
    467469    Ref<BlobResourceHandle> protect(*this);
    468470
     
    470472    if (bytesToRead > m_totalRemainingSize)
    471473        bytesToRead = m_totalRemainingSize;
    472     consumeData(item.data->data() + item.offset() + m_currentItemReadSize, static_cast<int>(bytesToRead));
     474    consumeData(reinterpret_cast<const char*>(item.data().data()->data()) + item.offset() + m_currentItemReadSize, static_cast<int>(bytesToRead));
    473475    m_currentItemReadSize = 0;
    474476}
     
    487489    if (bytesToRead > m_totalRemainingSize)
    488490        bytesToRead = static_cast<int>(m_totalRemainingSize);
    489     m_asyncStream->openForRead(item.file->path(), item.offset() + m_currentItemReadSize, bytesToRead);
     491    m_asyncStream->openForRead(item.file()->path(), item.offset() + m_currentItemReadSize, bytesToRead);
    490492    m_fileOpened = true;
    491493    m_currentItemReadSize = 0;
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.h

    r197563 r198869  
    4545class ResourceHandleClient;
    4646class ResourceRequest;
    47 struct BlobDataItem;
     47class BlobDataItem;
    4848
    4949class BlobResourceHandle final : public FileStreamClient, public ResourceHandle  {
  • trunk/Source/WebCore/platform/network/FormData.cpp

    r195450 r198869  
    294294    for (; it != itend; ++it) {
    295295        const BlobDataItem& blobItem = *it;
    296         if (blobItem.type == BlobDataItem::Data)
    297             formData->appendData(blobItem.data->data() + static_cast<int>(blobItem.offset()), static_cast<int>(blobItem.length()));
    298         else if (blobItem.type == BlobDataItem::File)
    299             formData->appendFileRange(blobItem.file->path(), blobItem.offset(), blobItem.length(), blobItem.file->expectedModificationTime());
     296        if (blobItem.type() == BlobDataItem::Type::Data) {
     297            ASSERT(blobItem.data().data());
     298            formData->appendData(blobItem.data().data()->data() + static_cast<int>(blobItem.offset()), static_cast<int>(blobItem.length()));
     299        } else if (blobItem.type() == BlobDataItem::Type::File)
     300            formData->appendFileRange(blobItem.file()->path(), blobItem.offset(), blobItem.length(), blobItem.file()->expectedModificationTime());
    300301        else
    301302            ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r197563 r198869  
    770770static bool blobIsOutOfDate(const BlobDataItem& blobItem)
    771771{
    772     ASSERT(blobItem.type == BlobDataItem::File);
    773     if (!isValidFileTime(blobItem.file->expectedModificationTime()))
     772    ASSERT(blobItem.type == BlobDataItem::Type::File);
     773    if (!isValidFileTime(blobItem.file()->expectedModificationTime()))
    774774        return false;
    775775
    776776    time_t fileModificationTime;
    777     if (!getFileModificationTime(blobItem.file->path(), fileModificationTime))
     777    if (!getFileModificationTime(blobItem.file()->path(), fileModificationTime))
    778778        return true;
    779779
    780     return fileModificationTime != static_cast<time_t>(blobItem.file->expectedModificationTime());
     780    return fileModificationTime != static_cast<time_t>(blobItem.file()->expectedModificationTime());
    781781}
    782782
    783783static void addEncodedBlobItemToSoupMessageBody(SoupMessage* message, const BlobDataItem& blobItem, unsigned long& totalBodySize)
    784784{
    785     if (blobItem.type == BlobDataItem::Data) {
     785    if (blobItem.type() == BlobDataItem::Type::Data) {
    786786        totalBodySize += blobItem.length();
    787         soup_message_body_append(message->request_body, SOUP_MEMORY_TEMPORARY, blobItem.data->data() + blobItem.offset(), blobItem.length());
    788         return;
    789     }
    790 
    791     ASSERT(blobItem.type == BlobDataItem::File);
     787        soup_message_body_append(message->request_body, SOUP_MEMORY_TEMPORARY, blobItem.data().data()->data() + blobItem.offset(), blobItem.length());
     788        return;
     789    }
     790
     791    ASSERT(blobItem.type == BlobDataItem::Type::File);
    792792    if (blobIsOutOfDate(blobItem))
    793793        return;
    794794
    795     addFileToSoupMessageBody(message, blobItem.file->path(), blobItem.offset(), blobItem.length() == BlobDataItem::toEndOfFile ? 0 : blobItem.length(),  totalBodySize);
     795    addFileToSoupMessageBody(message, blobItem.file()->path(), blobItem.offset(), blobItem.length() == BlobDataItem::toEndOfFile ? 0 : blobItem.length(),  totalBodySize);
    796796}
    797797
  • trunk/Source/WebCore/platform/text/LineEnding.cpp

    r197591 r198869  
    154154namespace WebCore {
    155155
    156 void normalizeToCROrLF(const CString& from, Vector<char>& result, bool toCR);
    157 
    158156// Normalize all line-endings to CR or LF.
    159 void normalizeToCROrLF(const CString& from, Vector<char>& result, bool toCR)
     157static void normalizeToCROrLF(const CString& from, Vector<uint8_t>& result, bool toCR)
    160158{
    161159    // Compute the new length.
     
    182180    size_t oldResultSize = result.size();
    183181    result.grow(oldResultSize + newLen);
    184     char* q = result.data() + oldResultSize;
     182    uint8_t* q = result.data() + oldResultSize;
    185183
    186184    // If no need to fix the string, just copy the string over.
     
    215213}
    216214
    217 void normalizeLineEndingsToCR(const CString& from, Vector<char>& result)
    218 {
    219     normalizeToCROrLF(from, result, true);
    220 }
    221 
    222 void normalizeLineEndingsToLF(const CString& from, Vector<char>& result)
    223 {
    224     normalizeToCROrLF(from, result, false);
    225 }
    226 
    227 void normalizeLineEndingsToNative(const CString& from, Vector<char>& result)
     215void normalizeLineEndingsToNative(const CString& from, Vector<uint8_t>& result)
    228216{
    229217#if OS(WINDOWS)
     
    231219    internalNormalizeLineEndingsToCRLF(from, buffer);
    232220#else
    233     normalizeLineEndingsToLF(from, result);
     221    normalizeToCROrLF(from, result, false);
    234222#endif
    235223}
  • trunk/Source/WebCore/platform/text/LineEnding.h

    r95901 r198869  
    4141CString normalizeLineEndingsToCRLF(const CString& from);
    4242
    43 // Normalize all line-endings in the given string to CR and append the result to the given buffer.
    44 void normalizeLineEndingsToCR(const CString& from, Vector<char>& result);
    45 
    46 // Normalize all line-endings in the given string to LF and append the result to the given buffer.
    47 void normalizeLineEndingsToLF(const CString& from, Vector<char>& result);
    48 
    4943// Normalize all line-endings in the given string to the native line-endings and append the result to the given buffer.
    5044// (Normalize to CRLF on Windows and normalize to LF on all other platforms.)
    51 void normalizeLineEndingsToNative(const CString& from, Vector<char>& result);
     45void normalizeLineEndingsToNative(const CString& from, Vector<uint8_t>& result);
    5246
    5347} // namespace WebCore
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r197706 r198869  
    239239        if (m_binaryResponseBuilder) {
    240240            // FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient.
    241             Vector<char> data;
     241            Vector<uint8_t> data;
    242242            data.append(m_binaryResponseBuilder->data(), m_binaryResponseBuilder->size());
    243243            String normalizedContentType = Blob::normalizedContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
  • trunk/Source/WebKit2/ChangeLog

    r198865 r198869  
     12016-03-30  Brady Eidson  <beidson@apple.com>
     2
     3        Make BlobData use ThreadSafeSharedBuffer instead of RawData.
     4        https://bugs.webkit.org/show_bug.cgi?id=156041
     5
     6        Reviewed by Alex Christensen.
     7
     8        * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
     9        (WebKit::NetworkBlobRegistry::filesInBlob):
     10        * Shared/WebCoreArgumentCoders.cpp:
     11        (IPC::ArgumentCoder<BlobPart>::decode):
     12
    1132016-03-30  Daniel Bates  <dabates@apple.com>
    214
  • trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp

    r196174 r198869  
    142142    Vector<RefPtr<BlobDataFileReference>> result;
    143143    for (const BlobDataItem& item : blobData->items()) {
    144         if (item.type == BlobDataItem::File)
    145             result.append(item.file);
     144        if (item.type() == BlobDataItem::Type::File)
     145            result.append(item.file());
    146146    }
    147147
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r197592 r198869  
    18621862    switch (type) {
    18631863    case BlobPart::Data: {
    1864         Vector<char> data;
     1864        Vector<uint8_t> data;
    18651865        if (!decoder.decode(data))
    18661866            return false;
Note: See TracChangeset for help on using the changeset viewer.