Changeset 168333 in webkit


Ignore:
Timestamp:
May 5, 2014 5:42:52 PM (10 years ago)
Author:
ap@apple.com
Message:

Stop using BlobData on client side
https://bugs.webkit.org/show_bug.cgi?id=132582

Reviewed by Sam Weinig.

Source/WebCore:
Blob registration now uses either a single file path, or a vector of much simpler
BlobPart objects, not an array with arbitrarily sliced blobs or files, which can't happen.

  • Modules/websockets/WebSocket.cpp:(WebCore::WebSocket::didReceiveBinaryData):

Use a new simpler Blob constructor.

  • WebCore.xcodeproj/project.pbxproj: Added BlobPart, removed BlobRegistrationData.
  • bindings/js/JSBlobCustom.cpp: (WebCore::JSBlobConstructor::constructJSBlob):

Use Vector<BlobPart> instead of BlobData (1 line of code instead of 5).

  • dom/DataTransfer.cpp: (WebCore::DataTransfer::hasFileOfType): Updated for

File::contentTypeFromFilePathOrName rename.

  • fileapi/Blob.cpp: (WebCore::Blob::Blob):
  • fileapi/Blob.h:

(WebCore::Blob::create):
(WebCore::Blob::deserialize):

  • fileapi/File.cpp:

(WebCore::File::File):
(WebCore::File::contentTypeFromFilePathOrName):
(WebCore::createBlobDataForFileWithType): Deleted.
(WebCore::createBlobDataForFile): Deleted.
(WebCore::createBlobDataForFileWithName): Deleted.
(WebCore::File::contentTypeFromFilePath): Deleted.

  • fileapi/File.h: (WebCore::File::deserialize): Deleted.

Added and updated constructors to not use BlobData. Changed special case constructors
to use name tags instead of non-enforced comments.

  • fileapi/ThreadableBlobRegistry.h:
  • fileapi/ThreadableBlobRegistry.cpp:

(WebCore::BlobRegistryContext::BlobRegistryContext): Updated with new data members
that were split out of BlobData.
(WebCore::ThreadableBlobRegistry::registerFileBlobURL): Added.
(WebCore::ThreadableBlobRegistry::registerBlobURL): Updated to pass Content-Type
explicitly, as it's no longer hidden in BlobData.

  • fileapi/WebKitBlobBuilder.h:
  • fileapi/WebKitBlobBuilder.cpp:

(WebCore::BlobBuilder::append):
(WebCore::BlobBuilder::finalize):
(WebCore::BlobBuilder::appendBytesData): Deleted.
Updated to use BlobPart. There is no longer any need to special case Files,
the registry takes care of that.

  • platform/network/BlobData.h:
  • platform/network/BlobData.cpp:

(WebCore::BlobDataItem::detachFromCurrentThread): Deleted.
(WebCore::BlobData::detachFromCurrentThread): Deleted.
BlobData will only be used on main thread by the registry.

  • platform/network/BlobPart.h: Added. A new class to encapsulate a list of blobs

that are combined into a new blob, as exposed to JS via Blob constructor.

  • platform/network/BlobRegistry.h:
  • platform/network/BlobRegistryImpl.cpp:

(WebCore::BlobRegistryImpl::registerFileBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURL):

  • platform/network/BlobRegistryImpl.h:

Updated for the new registration methods. We no longer have arbitrary BlobDatas
coming in.

  • platform/network/FormData.cpp: Don't include BlobData for now (but really,

BlobStorageData is the same thing, and they will be merged soon).
Unfortunately, FormData is used by both client and registry side, and there is
no clear delimitation at the time.

  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::responseBlob): Use the new simpler

way to create a Blob.

Source/WebKit2:
Update for WebCore changes.

  • CMakeLists.txt:
  • NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:

(WebKit::NetworkBlobRegistry::registerFileBlobURL):
(WebKit::NetworkBlobRegistry::registerBlobURL):

  • NetworkProcess/FileAPI/NetworkBlobRegistry.h:
  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::registerFileBlobURL):
(WebKit::NetworkConnectionToWebProcess::registerBlobURL):

  • NetworkProcess/NetworkConnectionToWebProcess.h:
  • NetworkProcess/NetworkConnectionToWebProcess.messages.in:
  • Shared/FileAPI/BlobRegistrationData.cpp: Removed.
  • Shared/FileAPI/BlobRegistrationData.h: Removed.
  • Shared/WebCoreArgumentCoders.cpp:

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

  • Shared/WebCoreArgumentCoders.h:
  • WebKit2.xcodeproj/project.pbxproj:
  • WebProcess/FileAPI/BlobRegistryProxy.cpp:

(WebKit::BlobRegistryProxy::registerFileBlobURL):
(WebKit::BlobRegistryProxy::registerBlobURL):

  • WebProcess/FileAPI/BlobRegistryProxy.h:
Location:
trunk/Source
Files:
1 added
2 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r168327 r168333  
     12014-05-05  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Stop using BlobData on client side
     4        https://bugs.webkit.org/show_bug.cgi?id=132582
     5
     6        Reviewed by Sam Weinig.
     7
     8        Blob registration now uses either a single file path, or a vector of much simpler
     9        BlobPart objects, not an array with arbitrarily sliced blobs or files, which can't happen.
     10
     11        * Modules/websockets/WebSocket.cpp:(WebCore::WebSocket::didReceiveBinaryData):
     12        Use a new simpler Blob constructor.
     13
     14        * WebCore.xcodeproj/project.pbxproj: Added BlobPart, removed BlobRegistrationData.
     15
     16        * bindings/js/JSBlobCustom.cpp: (WebCore::JSBlobConstructor::constructJSBlob):
     17        Use Vector<BlobPart> instead of BlobData (1 line of code instead of 5).
     18
     19        * dom/DataTransfer.cpp: (WebCore::DataTransfer::hasFileOfType): Updated for
     20        File::contentTypeFromFilePathOrName rename.
     21
     22        * fileapi/Blob.cpp: (WebCore::Blob::Blob):
     23        * fileapi/Blob.h:
     24        (WebCore::Blob::create):
     25        (WebCore::Blob::deserialize):
     26        * fileapi/File.cpp:
     27        (WebCore::File::File):
     28        (WebCore::File::contentTypeFromFilePathOrName):
     29        (WebCore::createBlobDataForFileWithType): Deleted.
     30        (WebCore::createBlobDataForFile): Deleted.
     31        (WebCore::createBlobDataForFileWithName): Deleted.
     32        (WebCore::File::contentTypeFromFilePath): Deleted.
     33        * fileapi/File.h: (WebCore::File::deserialize): Deleted.
     34        Added and updated constructors to not use BlobData. Changed special case constructors
     35        to use name tags instead of non-enforced comments.
     36
     37        * fileapi/ThreadableBlobRegistry.h:
     38        * fileapi/ThreadableBlobRegistry.cpp:
     39        (WebCore::BlobRegistryContext::BlobRegistryContext): Updated with new data members
     40        that were split out of BlobData.
     41        (WebCore::ThreadableBlobRegistry::registerFileBlobURL): Added.
     42        (WebCore::ThreadableBlobRegistry::registerBlobURL): Updated to pass Content-Type
     43        explicitly, as it's no longer hidden in BlobData.
     44
     45        * fileapi/WebKitBlobBuilder.h:
     46        * fileapi/WebKitBlobBuilder.cpp:
     47        (WebCore::BlobBuilder::append):
     48        (WebCore::BlobBuilder::finalize):
     49        (WebCore::BlobBuilder::appendBytesData): Deleted.
     50        Updated to use BlobPart. There is no longer any need to special case Files,
     51        the registry takes care of that.
     52
     53        * platform/network/BlobData.h:
     54        * platform/network/BlobData.cpp:
     55        (WebCore::BlobDataItem::detachFromCurrentThread): Deleted.
     56        (WebCore::BlobData::detachFromCurrentThread): Deleted.
     57        BlobData will only be used on main thread by the registry.
     58
     59        * platform/network/BlobPart.h: Added. A new class to encapsulate a list of blobs
     60        that are combined into a new blob, as exposed to JS via Blob constructor.
     61
     62        * platform/network/BlobRegistry.h:
     63        * platform/network/BlobRegistryImpl.cpp:
     64        (WebCore::BlobRegistryImpl::registerFileBlobURL):
     65        (WebCore::BlobRegistryImpl::registerBlobURL):
     66        * platform/network/BlobRegistryImpl.h:
     67        Updated for the new registration methods. We no longer have arbitrary BlobDatas
     68        coming in.
     69
     70        * platform/network/FormData.cpp: Don't include BlobData for now (but really,
     71        BlobStorageData is the same thing, and they will be merged soon).
     72        Unfortunately, FormData is used by both client and registry side, and there is
     73        no clear delimitation at the time.
     74 
     75        * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::responseBlob): Use the new simpler
     76        way to create a Blob.
     77
    1782014-05-05  Benjamin Poulain  <benjamin@webkit.org>
    279
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r168183 r168333  
    3636
    3737#include "Blob.h"
    38 #include "BlobData.h"
    3938#include "CloseEvent.h"
    4039#include "ContentSecurityPolicy.h"
     
    521520    case BinaryTypeBlob: {
    522521        // FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient.
    523         auto blobData = std::make_unique<BlobData>();
    524         blobData->appendData(RawData::create(std::move(*binaryData)), 0, BlobDataItem::toEndOfFile);
    525         RefPtr<Blob> blob = Blob::create(std::move(blobData));
     522        RefPtr<Blob> blob = Blob::create(std::move(*binaryData), emptyString());
    526523        dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::create(m_url)->toString()));
    527524        break;
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r168316 r168333  
    59655965                E1C657271816F9FE00256CDD /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C657261816F9FE00256CDD /* CryptoAlgorithmParameters.h */; };
    59665966                E1C8BE5D0E8BD15A0064CB7D /* JSWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */; };
     5967                E1C94AF9191303F000D5A893 /* BlobPart.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C94AF7191303F000D5A893 /* BlobPart.h */; settings = {ATTRIBUTES = (Private, ); }; };
    59675968                E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */; };
    59685969                E1CAA5C60E8BD23600A73ECA /* JSWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CAA5C50E8BD23600A73ECA /* JSWorker.h */; };
     
    1337113372                E1C6CFC21746D293007B87A1 /* DOMWindowConstructors.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowConstructors.idl; sourceTree = "<group>"; };
    1337213373                E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorker.cpp; sourceTree = "<group>"; };
     13374                E1C94AF7191303F000D5A893 /* BlobPart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobPart.h; sourceTree = "<group>"; };
    1337313375                E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerCustom.cpp; sourceTree = "<group>"; };
    1337413376                E1CAA5C50E8BD23600A73ECA /* JSWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorker.h; sourceTree = "<group>"; };
     
    1605616058                                2EDEF1ED121B0EFC00726DB2 /* BlobData.cpp */,
    1605716059                                2EDEF1EE121B0EFC00726DB2 /* BlobData.h */,
     16060                                E1C94AF7191303F000D5A893 /* BlobPart.h */,
    1605816061                                E14A94D616DFDF950068DE82 /* BlobRegistry.cpp */,
    1605916062                                2EDEF1EF121B0EFC00726DB2 /* BlobRegistry.h */,
     
    2542325426                                D0CE58F9125E4CC200F3F199 /* ResourceLoadScheduler.h in Headers */,
    2542425427                                8A81BF8511DCFD9000DA2B98 /* ResourceLoadTiming.h in Headers */,
     25428                                E1C94AF9191303F000D5A893 /* BlobPart.h in Headers */,
    2542525429                                7EE6846D12D26E3800E79415 /* ResourceRequest.h in Headers */,
    2542625430                                514C767D0CE923A1007EF3CD /* ResourceRequestBase.h in Headers */,
  • trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp

    r168126 r168333  
    135135    }
    136136
    137     BlobDataItemList items = blobBuilder.finalize();
    138     auto blobData = std::make_unique<BlobData>();
    139     blobData->setContentType(Blob::normalizedContentType(type));
    140     blobData->swapItems(items);
    141 
    142     RefPtr<Blob> blob = Blob::create(std::move(blobData));
     137    RefPtr<Blob> blob = Blob::create(blobBuilder.finalize(), Blob::normalizedContentType(type));
    143138
    144139    return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), Blob, blob.get()));
  • trunk/Source/WebCore/dom/DataTransfer.cpp

    r167784 r168333  
    190190
    191191    for (const String& filename : m_pasteboard->readFilenames()) {
    192         if (equalIgnoringCase(File::contentTypeFromFilePath(filename, File::AllContentTypes), type))
     192        if (equalIgnoringCase(File::contentTypeFromFilePathOrName(filename, File::AllContentTypes), type))
    193193            return true;
    194194    }
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r168209 r168333  
    6767
    6868
     69Blob::Blob(UninitializedContructor)
     70{
     71}
     72
    6973Blob::Blob()
    7074    : m_size(0)
    7175{
    72     auto blobData = std::make_unique<BlobData>();
    73 
    74     // Create a new internal URL and register it with the provided blob data.
    7576    m_internalURL = BlobURL::createInternalURL();
    76     ThreadableBlobRegistry::registerBlobURL(m_internalURL, std::move(blobData));
     77    ThreadableBlobRegistry::registerBlobURL(m_internalURL, Vector<BlobPart>(), String());
    7778}
    7879
    79 Blob::Blob(std::unique_ptr<BlobData> blobData)
    80     : m_type(blobData->contentType())
     80Blob::Blob(Vector<char> data, const String& contentType)
     81    : m_type(contentType)
    8182{
    82     ASSERT(blobData);
    83 
    84     // Create a new internal URL and register it with the provided blob data.
     83    Vector<BlobPart> blobParts;
     84    blobParts.append(BlobPart(std::move(data)));
    8585    m_internalURL = BlobURL::createInternalURL();
    86     m_size = ThreadableBlobRegistry::registerBlobURL(m_internalURL, std::move(blobData));
     86    m_size = ThreadableBlobRegistry::registerBlobURL(m_internalURL, std::move(blobParts), contentType);
    8787}
    8888
    89 Blob::Blob(const URL& srcURL, const String& type, long long size)
     89Blob::Blob(Vector<BlobPart> blobParts, const String& contentType)
     90    : m_type(contentType)
     91{
     92    m_internalURL = BlobURL::createInternalURL();
     93    m_size = ThreadableBlobRegistry::registerBlobURL(m_internalURL, std::move(blobParts), contentType);
     94}
     95
     96Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size)
    9097    : m_type(Blob::normalizedContentType(type))
    9198    , m_size(size)
    9299{
    93     // Create a new internal URL and register it with the same blob data as the source URL.
    94100    m_internalURL = BlobURL::createInternalURL();
    95101    ThreadableBlobRegistry::registerBlobURL(0, m_internalURL, srcURL);
     
    100106    : m_type(Blob::normalizedContentType(type))
    101107{
    102     // Create a new internal URL and register it with the same blob data as the source URL.
    103108    m_internalURL = BlobURL::createInternalURL();
    104109    m_size = ThreadableBlobRegistry::registerBlobURLForSlice(m_internalURL, srcURL, start, end);
  • trunk/Source/WebCore/fileapi/Blob.h

    r168183 r168333  
    3232#define Blob_h
    3333
    34 #include "BlobData.h"
    35 #include "URL.h"
     34#include "BlobPart.h"
    3635#include "ScriptWrappable.h"
    3736#include "URLRegistry.h"
     
    5150    }
    5251
    53     static PassRefPtr<Blob> create(std::unique_ptr<BlobData> blobData)
     52    static PassRefPtr<Blob> create(Vector<char> data, const String& contentType)
    5453    {
    55         return adoptRef(new Blob(std::move(blobData)));
     54        return adoptRef(new Blob(std::move(data), contentType));
     55    }
     56
     57    static PassRefPtr<Blob> create(Vector<BlobPart> blobParts, const String& contentType)
     58    {
     59        return adoptRef(new Blob(std::move(blobParts), contentType));
    5660    }
    5761
     
    5963    {
    6064        ASSERT(Blob::isNormalizedContentType(type));
    61         return adoptRef(new Blob(srcURL, type, size));
     65        return adoptRef(new Blob(deserializationContructor, srcURL, type, size));
    6266    }
    6367
     
    9094protected:
    9195    Blob();
    92     Blob(std::unique_ptr<BlobData>);
     96    Blob(Vector<char>, const String& contentType);
     97    Blob(Vector<BlobPart>, const String& contentType);
    9398
    94     // For deserialization.
    95     Blob(const URL& srcURL, const String& type, long long size);
     99    enum UninitializedContructor { uninitializedContructor };
     100    Blob(UninitializedContructor);
     101
     102    enum DeserializationContructor { deserializationContructor };
     103    Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size);
    96104
    97105#if ENABLE(BLOB)
  • trunk/Source/WebCore/fileapi/File.cpp

    r168126 r168333  
    2727#include "File.h"
    2828
     29#include "BlobURL.h"
    2930#include "FileMetadata.h"
    3031#include "FileSystem.h"
    3132#include "MIMETypeRegistry.h"
     33#include "ThreadableBlobRegistry.h"
    3234#include <wtf/CurrentTime.h>
    3335#include <wtf/DateMath.h>
     
    3638namespace WebCore {
    3739
    38 static std::unique_ptr<BlobData> createBlobDataForFileWithType(const String& path, const String& contentType)
    39 {
    40     auto blobData = std::make_unique<BlobData>();
    41     ASSERT(Blob::isNormalizedContentType(contentType));
    42     blobData->setContentType(contentType);
    43     blobData->appendFile(path);
    44     return blobData;
    45 }
    46 
    47 static std::unique_ptr<BlobData> createBlobDataForFile(const String& path, File::ContentTypeLookupPolicy policy)
    48 {
    49     return createBlobDataForFileWithType(path, File::contentTypeFromFilePath(path, policy));
    50 }
    51 
    52 static std::unique_ptr<BlobData> createBlobDataForFileWithName(const String& path, const String& fileSystemName, File::ContentTypeLookupPolicy policy)
    53 {
    54     return createBlobDataForFileWithType(path, File::contentTypeFromFilePath(fileSystemName, policy));
    55 }
    56 
    5740File::File(const String& path, ContentTypeLookupPolicy policy)
    58     : Blob(createBlobDataForFile(path, policy))
     41    : Blob(uninitializedContructor)
    5942    , m_path(path)
    6043    , m_name(pathGetFileName(path))
    6144{
     45    m_internalURL = BlobURL::createInternalURL();
     46    m_type = contentTypeFromFilePathOrName(path, policy);
     47    m_size = -1;
     48    ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
    6249}
    6350
    64 File::File(const String& path, const URL& url, const String& type)
    65     : Blob(url, type, -1)
     51File::File(const String& path, const String& name, ContentTypeLookupPolicy policy)
     52    : Blob(uninitializedContructor)
     53    , m_path(path)
     54    , m_name(name)
     55{
     56    m_internalURL = BlobURL::createInternalURL();
     57    m_type = contentTypeFromFilePathOrName(name, policy);
     58    m_size = -1;
     59    ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
     60}
     61
     62File::File(DeserializationContructor, const String& path, const URL& url, const String& type)
     63    : Blob(deserializationContructor, url, type, -1)
    6664    , m_path(path)
    6765{
    6866    m_name = pathGetFileName(path);
    69     // FIXME: File object serialization/deserialization does not include
    70     // newer file object data members: m_name and m_relativePath.
     67    // FIXME: File object serialization/deserialization does not include m_name.
    7168    // See SerializedScriptValue.cpp
    72 }
    73 
    74 File::File(const String& path, const String& name, ContentTypeLookupPolicy policy)
    75     : Blob(createBlobDataForFileWithName(path, name, policy))
    76     , m_path(path)
    77     , m_name(name)
    78 {
    7969}
    8070
     
    9888}
    9989
    100 String File::contentTypeFromFilePath(const String& name, File::ContentTypeLookupPolicy policy)
     90String File::contentTypeFromFilePathOrName(const String& name, File::ContentTypeLookupPolicy policy)
    10191{
    10292    String type;
  • trunk/Source/WebCore/fileapi/File.h

    r168183 r168333  
    3333namespace WebCore {
    3434
    35 struct FileMetadata;
    3635class URL;
    3736
    38 class File : public Blob {
     37class File final : public Blob {
    3938public:
    4039    // AllContentTypes should only be used when the full path/name are trusted; otherwise, it could
     
    5251    static PassRefPtr<File> deserialize(const String& path, const URL& srcURL, const String& type)
    5352    {
    54         return adoptRef(new File(path, srcURL, type));
     53        return adoptRef(new File(deserializationContructor, path, srcURL, type));
    5554    }
    5655
     
    7271    double lastModifiedDate() const;
    7372
    74     static String contentTypeFromFilePath(const String&, ContentTypeLookupPolicy);
     73    static String contentTypeFromFilePathOrName(const String&, ContentTypeLookupPolicy);
    7574
    7675private:
     
    7877    File(const String& path, const String& name, ContentTypeLookupPolicy);
    7978
    80     // For deserialization.
    81     File(const String& path, const URL& srcURL, const String& type);
     79    File(DeserializationContructor, const String& path, const URL& srcURL, const String& type);
    8280
    8381    String m_path;
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp

    r168127 r168333  
    3232#include "ThreadableBlobRegistry.h"
    3333
    34 #include "BlobData.h"
     34#include "BlobPart.h"
    3535#include "BlobRegistry.h"
    3636#include "BlobURL.h"
     
    5151    WTF_MAKE_FAST_ALLOCATED;
    5252public:
    53     BlobRegistryContext(const URL& url, std::unique_ptr<BlobData> blobData)
    54         : url(url.copy())
    55         , blobData(std::move(blobData))
    56     {
    57         this->blobData->detachFromCurrentThread();
     53    BlobRegistryContext(const URL& url, Vector<BlobPart> blobParts, const String& contentType)
     54        : url(url.copy())
     55        , contentType(contentType.isolatedCopy())
     56        , blobParts(std::move(blobParts))
     57    {
     58        for (BlobPart& part : blobParts)
     59            part.detachFromCurrentThread();
    5860    }
    5961
     
    6668    BlobRegistryContext(const URL& url)
    6769        : url(url.copy())
     70    {
     71    }
     72
     73    BlobRegistryContext(const URL& url, const String& path, const String& contentType)
     74        : url(url.copy())
     75        , path(path.isolatedCopy())
     76        , contentType(contentType.isolatedCopy())
    6877    {
    6978    }
     
    7180    URL url;
    7281    URL srcURL;
    73     std::unique_ptr<BlobData> blobData;
     82    String path;
     83    String contentType;
     84    Vector<BlobPart> blobParts;
    7485};
    7586
     
    89100}
    90101
    91 unsigned long long ThreadableBlobRegistry::registerBlobURL(const URL& url, std::unique_ptr<BlobData> blobData)
     102void ThreadableBlobRegistry::registerFileBlobURL(const URL& url, const String& path, const String& contentType)
     103{
     104    if (isMainThread())
     105        blobRegistry().registerFileBlobURL(url, path, contentType);
     106    else {
     107        // BlobRegistryContext performs an isolated copy of data.
     108        BlobRegistryContext* context = new BlobRegistryContext(url, path, contentType);
     109        BinarySemaphore semaphore;
     110        callOnMainThread([context] {
     111            std::unique_ptr<BlobRegistryContext> blobRegistryContext(context);
     112            blobRegistry().registerFileBlobURL(blobRegistryContext->url, blobRegistryContext->path, blobRegistryContext->contentType);
     113        });
     114    }
     115}
     116
     117unsigned long long ThreadableBlobRegistry::registerBlobURL(const URL& url, Vector<BlobPart> blobParts, const String& contentType)
    92118{
    93119    unsigned long long resultSize;
    94120    if (isMainThread())
    95         resultSize = blobRegistry().registerBlobURL(url, std::move(blobData));
    96     else {
    97         // BlobRegistryContext performs an isolated copy of data.
    98         BlobRegistryContext* context = new BlobRegistryContext(url, std::move(blobData));
     121        resultSize = blobRegistry().registerBlobURL(url, std::move(blobParts), contentType);
     122    else {
     123        // BlobRegistryContext performs an isolated copy of data.
     124        BlobRegistryContext* context = new BlobRegistryContext(url, std::move(blobParts), contentType);
    99125        BinarySemaphore semaphore;
    100126        callOnMainThread([context, &semaphore, &resultSize] {
    101127            std::unique_ptr<BlobRegistryContext> blobRegistryContext(context);
    102             resultSize = blobRegistry().registerBlobURL(blobRegistryContext->url, std::move(blobRegistryContext->blobData));
     128            resultSize = blobRegistry().registerBlobURL(blobRegistryContext->url, std::move(blobRegistryContext->blobParts), blobRegistryContext->contentType);
    103129            semaphore.signal();
    104130        });
     
    169195#else
    170196
    171 unsigned long long ThreadableBlobRegistry::registerBlobURL(const URL&, std::unique_ptr<BlobData>)
     197void ThreadableBlobRegistry::registerFileBlobURL(const URL&, const String&, const String&)
     198{
     199}
     200
     201unsigned long long ThreadableBlobRegistry::registerBlobURL(const URL&, Vector<BlobPart>, const String&)
    172202{
    173203    return 0;
  • trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.h

    r168126 r168333  
    3232#define ThreadableBlobRegistry_h
    3333
    34 #include <wtf/PassRefPtr.h>
     34#include <wtf/Forward.h>
     35#include <wtf/Vector.h>
    3536
    3637namespace WebCore {
    3738
    38 class BlobData;
     39class BlobPart;
    3940class URL;
    4041class SecurityOrigin;
     
    4243class ThreadableBlobRegistry {
    4344public:
    44     static unsigned long long registerBlobURL(const URL&, std::unique_ptr<BlobData>);
     45    static void registerFileBlobURL(const URL&, const String& path, const String& contentType);
     46    static unsigned long long registerBlobURL(const URL&, Vector<BlobPart> blobParts, const String& contentType);
    4547    static void registerBlobURL(SecurityOrigin*, const URL&, const URL& srcURL);
    4648    static void unregisterBlobURL(const URL&);
  • trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp

    r168209 r168333  
    7676        return;
    7777
    78     appendBytesData(arrayBuffer->data(), arrayBuffer->byteLength());
     78    m_appendableData.append(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->byteLength());
    7979}
    8080
     
    8484        return;
    8585
    86     appendBytesData(arrayBufferView->baseAddress(), arrayBufferView->byteLength());
     86    m_appendableData.append(static_cast<const char*>(arrayBufferView->baseAddress()), arrayBufferView->byteLength());
    8787}
    8888#endif
     
    9393        return;
    9494    if (!m_appendableData.isEmpty())
    95         m_items.append(BlobDataItem(RawData::create(std::move(m_appendableData))));
    96     if (blob->isFile()) {
    97         File* file = toFile(blob);
    98         m_items.append(BlobDataItem(file->path(), 0, BlobDataItem::toEndOfFile, invalidFileTime()));
    99     } else {
    100         long long blobSize = static_cast<long long>(blob->size());
    101         m_items.append(BlobDataItem(blob->url(), 0, blobSize));
    102     }
     95        m_items.append(BlobPart(std::move(m_appendableData)));
     96    m_items.append(BlobPart(blob->url()));
    10397}
    10498
    105 void BlobBuilder::appendBytesData(const void* data, size_t length)
    106 {
    107     m_appendableData.append(static_cast<const char*>(data), length);
    108 }
    109 
    110 BlobDataItemList BlobBuilder::finalize()
     99Vector<BlobPart> BlobBuilder::finalize()
    111100{
    112101    if (!m_appendableData.isEmpty())
    113         m_items.append(BlobDataItem(RawData::create(std::move(m_appendableData))));
     102        m_items.append(BlobPart(std::move(m_appendableData)));
    114103    return std::move(m_items);
    115104}
  • trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h

    r168126 r168333  
    3232#define WebKitBlobBuilder_h
    3333
    34 #include "BlobData.h"
    35 #include <wtf/Forward.h>
     34#include "BlobPart.h"
    3635
    3736namespace JSC {
     
    5554#endif
    5655
    57     BlobDataItemList finalize();
     56    Vector<BlobPart> finalize();
    5857
    5958private:
    60     void appendBytesData(const void*, size_t);
    61 
    62     BlobDataItemList m_items;
     59    Vector<BlobPart> m_items;
    6360    Vector<char> m_appendableData;
    6461};
  • trunk/Source/WebCore/platform/network/BlobData.cpp

    r168032 r168333  
    4646const long long BlobDataItem::toEndOfFile = -1;
    4747
    48 void BlobDataItem::detachFromCurrentThread()
    49 {
    50     path = path.isolatedCopy();
    51     url = url.copy();
    52 }
    53 
    54 void BlobData::detachFromCurrentThread()
    55 {
    56     m_contentType = m_contentType.isolatedCopy();
    57     m_contentDisposition = m_contentDisposition.isolatedCopy();
    58     for (size_t i = 0; i < m_items.size(); ++i)
    59         m_items.at(i).detachFromCurrentThread();
    60 }
    61 
    6248void BlobData::setContentType(const String& contentType)
    6349{
  • trunk/Source/WebCore/platform/network/BlobData.h

    r168201 r168333  
    4141namespace WebCore {
    4242
     43// FIXME: RawData doesn't need to be ThreadSafeRefCounted any more. We can probably switch to another data buffer type now.
    4344class RawData : public ThreadSafeRefCounted<RawData> {
    4445public:
     
    119120    }
    120121
    121     // Detaches from current thread so that it can be passed to another thread.
    122     void detachFromCurrentThread();
    123 
    124122    enum {
    125123        Data,
     
    162160    BlobData() { }
    163161
    164     // Detaches from current thread so that it can be passed to another thread.
    165     void detachFromCurrentThread();
    166 
    167162    const String& contentType() const { return m_contentType; }
    168163    void setContentType(const String&);
  • trunk/Source/WebCore/platform/network/BlobRegistry.h

    r168126 r168333  
    3232#define BlobRegistry_h
    3333
    34 #include <wtf/PassOwnPtr.h>
     34#include <wtf/Forward.h>
     35#include <wtf/Vector.h>
    3536
    3637namespace WebCore {
    3738
    38 class BlobData;
    39 class BlobStorageData;
     39class BlobPart;
    4040class BlobRegistry;
    4141class URL;
     
    4646class BlobRegistry {
    4747public:
     48
     49    // Registers a blob URL referring to the specified file.
     50    virtual void registerFileBlobURL(const URL&, const String& path, const String& contentType) = 0;
     51
    4852    // Registers a blob URL referring to the specified blob data.
    49     virtual unsigned long long registerBlobURL(const URL&, std::unique_ptr<BlobData>) = 0;
     53    virtual unsigned long long registerBlobURL(const URL&, Vector<BlobPart>, const String& contentType) = 0;
    5054   
    5155    // Registers a new blob URL referring to the blob data identified by the specified srcURL.
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp

    r168201 r168333  
    3535#if ENABLE(BLOB)
    3636
     37#include "BlobPart.h"
    3738#include "BlobResourceHandle.h"
    3839#include "BlobStorageData.h"
     
    117118}
    118119
    119 unsigned long long BlobRegistryImpl::registerBlobURL(const URL& url, std::unique_ptr<BlobData> blobData)
     120void BlobRegistryImpl::registerFileBlobURL(const URL& url, const String& path, const String& contentType)
    120121{
    121122    ASSERT(isMainThread());
    122123    registerBlobResourceHandleConstructor();
    123124
    124     RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(blobData->contentType());
     125    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(contentType);
     126
     127    // FIXME: Factor out size and modification tracking for a cleaner implementation.
     128    FileMetadata metadata;
     129    if (!getFileMetadata(path, metadata))
     130        return;
     131
     132    blobStorageData->m_data.appendFile(path, 0, metadata.length, metadata.modificationTime);
     133    m_blobs.set(url.string(), blobStorageData);
     134}
     135
     136unsigned long long BlobRegistryImpl::registerBlobURL(const URL& url, Vector<BlobPart> blobParts, const String& contentType)
     137{
     138    ASSERT(isMainThread());
     139    registerBlobResourceHandleConstructor();
     140
     141    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(contentType);
    125142
    126143    // The blob data is stored in the "canonical" way. That is, it only contains a list of Data and File items.
     
    130147    // All the Blob items in the passing blob data are resolved and expanded into a set of Data and File items.
    131148
    132     // FIXME: BlobDataItems contain a lot of information that we do not expect to be present when registering a new blob,
    133     // these data members are only used inside the registry. Use a more appropriate type than BlobData.
    134 
    135149    unsigned long long size = 0;
    136     for (const BlobDataItem& item : blobData->items()) {
    137         switch (item.type) {
    138         case BlobDataItem::Data:
    139             blobStorageData->m_data.appendData(item.data, 0, item.data->length());
    140             size += item.data->length();
     150    for (BlobPart& part : blobParts) {
     151        switch (part.type()) {
     152        case BlobPart::Data: {
     153            unsigned long long partSize = part.data().size();
     154            RefPtr<RawData> rawData = RawData::create(part.moveData());
     155            size += partSize;
     156            blobStorageData->m_data.appendData(rawData.release(), 0, partSize);
    141157            break;
    142         case BlobDataItem::File: {
    143             ASSERT(!item.offset);
    144             ASSERT(item.length == BlobDataItem::toEndOfFile);
    145             ASSERT(!isValidFileTime(item.expectedModificationTime));
    146 
    147             // FIXME: Factor out size and modification tracking for a cleaner implementation.
    148             FileMetadata metadata;
    149             if (!getFileMetadata(item.path, metadata))
     158        }
     159        case BlobPart::Blob: {
     160            if (!m_blobs.contains(part.url().string()))
    150161                return 0;
    151 
    152             blobStorageData->m_data.appendFile(item.path, 0, metadata.length, metadata.modificationTime);
    153             size += metadata.length;
     162            unsigned long long partSize = blobSize(part.url()); // As a side effect, this calculates sizes of all files in the blob.
     163            size += partSize;
     164            appendStorageItems(blobStorageData.get(), m_blobs.get(part.url().string())->items(), 0, partSize);
    154165            break;
    155166        }
    156         case BlobDataItem::Blob:
    157             if (!m_blobs.contains(item.url.string()))
    158                 return 0;
    159             size += blobSize(item.url); // As a side effect, this calculates sizes of all files in the blob.
    160             ASSERT(blobSize(item.url) == static_cast<unsigned long long>(item.length));
    161             appendStorageItems(blobStorageData.get(), m_blobs.get(item.url.string())->items(), item.offset, item.length);
    162             break;
    163167        }
    164168    }
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.h

    r168126 r168333  
    4646
    4747// BlobRegistryImpl is not thread-safe. It should only be called from main thread.
    48 class BlobRegistryImpl : public BlobRegistry {
     48class BlobRegistryImpl final : public BlobRegistry {
    4949    WTF_MAKE_FAST_ALLOCATED;
    5050public:
     
    5858    void appendStorageItems(BlobStorageData*, const BlobDataItemList&, long long offset, long long length);
    5959
    60     virtual unsigned long long registerBlobURL(const URL&, std::unique_ptr<BlobData>) override;
     60    virtual void registerFileBlobURL(const WebCore::URL&, const String& path, const String& contentType) override;
     61    virtual unsigned long long registerBlobURL(const URL&, Vector<BlobPart>, const String& contentType) override;
    6162    virtual void registerBlobURL(const URL&, const URL& srcURL) override;
    6263    virtual unsigned long long registerBlobURLForSlice(const URL&, const URL& srcURL, long long start, long long end) override;
  • trunk/Source/WebCore/platform/network/FormData.cpp

    r168199 r168333  
    2424#include "FormData.h"
    2525
    26 #include "BlobData.h"
    2726#include "BlobRegistryImpl.h"
     27#include "BlobStorageData.h"
    2828#include "BlobURL.h"
    2929#include "Chrome.h"
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r168209 r168333  
    2525
    2626#include "Blob.h"
    27 #include "BlobData.h"
    2827#include "ContentSecurityPolicy.h"
    2928#include "CrossOriginAccessControl.h"
     
    290289        if (m_binaryResponseBuilder) {
    291290            // FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient.
    292             unsigned size = m_binaryResponseBuilder->size();
    293             auto blobData = std::make_unique<BlobData>();
    294             blobData->appendData(RawData::create(m_binaryResponseBuilder->data(), size), 0, BlobDataItem::toEndOfFile);
    295             String normalizedContentType = Blob::normalizedContentType(responseMIMEType());
    296             blobData->setContentType(normalizedContentType); // responseMIMEType defaults to text/xml which may be incorrect.
     291            Vector<char> data;
     292            data.append(m_binaryResponseBuilder->data(), m_binaryResponseBuilder->size());
     293            String normalizedContentType = Blob::normalizedContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
     294            m_responseBlob = Blob::create(std::move(data), normalizedContentType);
    297295            m_binaryResponseBuilder.clear();
    298             m_responseBlob = Blob::create(std::move(blobData));
    299296        } else {
    300297            // If we errored out or got no data, we still return a blob, just an empty one.
  • trunk/Source/WebKit2/CMakeLists.txt

    r167488 r168333  
    270270    Shared/Downloads/DownloadManager.cpp
    271271
    272     Shared/FileAPI/BlobRegistrationData.cpp
    273 
    274272    Shared/Network/NetworkProcessCreationParameters.cpp
    275273    Shared/Network/NetworkResourceLoadParameters.cpp
  • trunk/Source/WebKit2/ChangeLog

    r168325 r168333  
     12014-05-05  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Stop using BlobData on client side
     4        https://bugs.webkit.org/show_bug.cgi?id=132582
     5
     6        Reviewed by Sam Weinig.
     7
     8        Update for WebCore changes.
     9
     10        * CMakeLists.txt:
     11        * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
     12        (WebKit::NetworkBlobRegistry::registerFileBlobURL):
     13        (WebKit::NetworkBlobRegistry::registerBlobURL):
     14        * NetworkProcess/FileAPI/NetworkBlobRegistry.h:
     15        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     16        (WebKit::NetworkConnectionToWebProcess::registerFileBlobURL):
     17        (WebKit::NetworkConnectionToWebProcess::registerBlobURL):
     18        * NetworkProcess/NetworkConnectionToWebProcess.h:
     19        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     20        * Shared/FileAPI/BlobRegistrationData.cpp: Removed.
     21        * Shared/FileAPI/BlobRegistrationData.h: Removed.
     22        * Shared/WebCoreArgumentCoders.cpp:
     23        (IPC::ArgumentCoder<BlobPart>::encode):
     24        (IPC::ArgumentCoder<BlobPart>::decode):
     25        * Shared/WebCoreArgumentCoders.h:
     26        * WebKit2.xcodeproj/project.pbxproj:
     27        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
     28        (WebKit::BlobRegistryProxy::registerFileBlobURL):
     29        (WebKit::BlobRegistryProxy::registerBlobURL):
     30        * WebProcess/FileAPI/BlobRegistryProxy.h:
     31
    1322014-05-05  Beth Dakin  <bdakin@apple.com>
    233
  • trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp

    r168126 r168333  
    3030
    3131#include "SandboxExtension.h"
     32#include <WebCore/BlobPart.h>
    3233#include <WebCore/BlobRegistryImpl.h>
    3334#include <wtf/NeverDestroyed.h>
     
    4950}
    5051
    51 uint64_t NetworkBlobRegistry::registerBlobURL(NetworkConnectionToWebProcess* connection, const URL& url, std::unique_ptr<BlobData> data, const Vector<RefPtr<SandboxExtension>>& newSandboxExtensions)
     52void NetworkBlobRegistry::registerFileBlobURL(NetworkConnectionToWebProcess* connection, const URL& url, const String& path, PassRefPtr<SandboxExtension> sandboxExtension, const String& contentType)
    5253{
    5354    ASSERT(!m_sandboxExtensions.contains(url.string()));
    5455
    55     // Combine new extensions for File items and existing extensions for inner Blob items.
    56     Vector<RefPtr<SandboxExtension>> sandboxExtensions = newSandboxExtensions;
    57     const BlobDataItemList& items = data->items();
    58     for (size_t i = 0, count = items.size(); i < count; ++i) {
    59         if (items[i].type == BlobDataItem::Blob)
    60             sandboxExtensions.appendVector(m_sandboxExtensions.get(items[i].url.string()));
     56    blobRegistry().registerFileBlobURL(url, path, contentType);
     57
     58    if (sandboxExtension) {
     59        Vector<RefPtr<SandboxExtension>> extensionsVector;
     60        extensionsVector.append(sandboxExtension);
     61        m_sandboxExtensions.add(url.string(), std::move(extensionsVector));
    6162    }
    6263
    63     uint64_t resultSize = blobRegistry().registerBlobURL(url, std::move(data));
     64    ASSERT(!m_blobsForConnection.get(connection).contains(url));
     65    BlobForConnectionMap::iterator mapIterator = m_blobsForConnection.find(connection);
     66    if (mapIterator == m_blobsForConnection.end())
     67        mapIterator = m_blobsForConnection.add(connection, HashSet<URL>()).iterator;
     68    mapIterator->value.add(url);
     69}
     70
     71uint64_t NetworkBlobRegistry::registerBlobURL(NetworkConnectionToWebProcess* connection, const URL& url, Vector<WebCore::BlobPart> blobParts, const String& contentType)
     72{
     73    ASSERT(!m_sandboxExtensions.contains(url.string()));
     74
     75    // Combine existing extensions for inner Blob items.
     76    Vector<RefPtr<SandboxExtension>> sandboxExtensions;
     77    for (const BlobPart& part : blobParts) {
     78        if (part.type() == BlobPart::Blob)
     79            sandboxExtensions.appendVector(m_sandboxExtensions.get(part.url().string()));
     80    }
     81
     82    uint64_t resultSize = blobRegistry().registerBlobURL(url, std::move(blobParts), contentType);
    6483
    6584    if (!sandboxExtensions.isEmpty())
    66         m_sandboxExtensions.add(url.string(), sandboxExtensions);
     85        m_sandboxExtensions.add(url.string(), std::move(sandboxExtensions));
    6786
    6887    ASSERT(!m_blobsForConnection.get(connection).contains(url));
  • trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h

    r168126 r168333  
    3434
    3535namespace WebCore {
    36 class BlobData;
     36class BlobPart;
    3737}
    3838
     
    4848    static NetworkBlobRegistry& shared();
    4949
    50     uint64_t registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, std::unique_ptr<WebCore::BlobData>, const Vector<RefPtr<SandboxExtension>>&);
     50    void registerFileBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const String& path, PassRefPtr<SandboxExtension>, const String& contentType);
     51    uint64_t registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType);
    5152    void registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL);
    5253    uint64_t registerBlobURLForSlice(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL, int64_t start, int64_t end);
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r168126 r168333  
    2929#if ENABLE(NETWORK_PROCESS)
    3030
    31 #include "BlobRegistrationData.h"
    3231#include "ConnectionStack.h"
    3332#include "NetworkBlobRegistry.h"
     
    3938#include "RemoteNetworkingContext.h"
    4039#include "SessionTracker.h"
    41 #include <WebCore/BlobData.h>
    4240#include <WebCore/PlatformCookieJar.h>
    4341#include <WebCore/ResourceLoaderOptions.h>
     
    226224
    227225#if ENABLE(BLOB)
    228 void NetworkConnectionToWebProcess::registerBlobURL(const URL& url, const BlobRegistrationData& data, uint64_t& resultSize)
    229 {
    230     Vector<RefPtr<SandboxExtension>> extensions;
    231     for (size_t i = 0, count = data.sandboxExtensions().size(); i < count; ++i) {
    232         if (RefPtr<SandboxExtension> extension = SandboxExtension::create(data.sandboxExtensions()[i]))
    233             extensions.append(extension);
    234     }
    235 
    236     resultSize = NetworkBlobRegistry::shared().registerBlobURL(this, url, data.releaseData(), extensions);
     226void NetworkConnectionToWebProcess::registerFileBlobURL(const URL& url, const String& path, const SandboxExtension::Handle& extensionHandle, const String& contentType)
     227{
     228    RefPtr<SandboxExtension> extension = SandboxExtension::create(extensionHandle);
     229
     230    NetworkBlobRegistry::shared().registerFileBlobURL(this, url, path, extension.release(), contentType);
     231}
     232
     233void NetworkConnectionToWebProcess::registerBlobURL(const URL& url, Vector<BlobPart> blobParts, const String& contentType, uint64_t& resultSize)
     234{
     235    resultSize = NetworkBlobRegistry::shared().registerBlobURL(this, url, std::move(blobParts), contentType);
    237236}
    238237
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h

    r168126 r168333  
    4242namespace WebKit {
    4343
    44 class BlobRegistrationData;
    4544class NetworkConnectionToWebProcess;
    4645class NetworkResourceLoader;
     
    8988
    9089#if ENABLE(BLOB)
    91     void registerBlobURL(const WebCore::URL&, const BlobRegistrationData&, uint64_t& resultSize);
     90    void registerFileBlobURL(const WebCore::URL&, const String& path, const SandboxExtension::Handle&, const String& contentType);
     91    void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType, uint64_t& resultSize);
    9292    void registerBlobURLFromURL(const WebCore::URL&, const WebCore::URL& srcURL);
    9393    void registerBlobURLForSlice(const WebCore::URL&, const WebCore::URL& srcURL, int64_t start, int64_t end, uint64_t& resultSize);
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r168126 r168333  
    4545
    4646#if ENABLE(BLOB)
    47     RegisterBlobURL(WebCore::URL url, WebKit::BlobRegistrationData data) -> (uint64_t resultSize)
     47    RegisterFileBlobURL(WebCore::URL url, String path, WebKit::SandboxExtension::Handle extensionHandle, String contentType)
     48    RegisterBlobURL(WebCore::URL url, Vector<WebCore::BlobPart> blobParts, String contentType) -> (uint64_t resultSize)
    4849    RegisterBlobURLFromURL(WebCore::URL url, WebCore::URL srcURL)
    4950    RegisterBlobURLForSlice(WebCore::URL url, WebCore::URL srcURL, int64_t start, int64_t end) -> (uint64_t resultSize)
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r168228 r168333  
    3030#include "ShareableBitmap.h"
    3131#include <WebCore/AuthenticationChallenge.h>
     32#include <WebCore/BlobPart.h>
    3233#include <WebCore/CertificateInfo.h>
    3334#include <WebCore/Cookie.h>
     
    19731974}
    19741975
     1976void ArgumentCoder<BlobPart>::encode(ArgumentEncoder& encoder, const BlobPart& blobPart)
     1977{
     1978    encoder << static_cast<uint32_t>(blobPart.type());
     1979    switch (blobPart.type()) {
     1980    case BlobPart::Data:
     1981        encoder << blobPart.data();
     1982        break;
     1983    case BlobPart::Blob:
     1984        encoder << blobPart.url();
     1985        break;
     1986    }
     1987}
     1988
     1989bool ArgumentCoder<BlobPart>::decode(ArgumentDecoder& decoder, BlobPart& blobPart)
     1990{
     1991    uint32_t type;
     1992    if (!decoder.decode(type))
     1993        return false;
     1994
     1995    switch (type) {
     1996    case BlobPart::Data: {
     1997        Vector<char> data;
     1998        if (!decoder.decode(data))
     1999            return false;
     2000        blobPart = BlobPart(std::move(data));
     2001        break;
     2002    }
     2003    case BlobPart::Blob: {
     2004        String url;
     2005        if (!decoder.decode(url))
     2006            return false;
     2007        blobPart = BlobPart(URL(URL(), url));
     2008        break;
     2009    }
     2010    default:
     2011        return false;
     2012    }
     2013
     2014    return true;
     2015}
     2016
    19752017} // namespace IPC
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h

    r167266 r168333  
    3232class AffineTransform;
    3333class AuthenticationChallenge;
     34class BlobPart;
    3435class CertificateInfo;
    3536class Color;
     
    425426};
    426427
     428template<> struct ArgumentCoder<WebCore::BlobPart> {
     429    static void encode(ArgumentEncoder&, const WebCore::BlobPart&);
     430    static bool decode(ArgumentDecoder&, WebCore::BlobPart&);
     431};
     432
    427433} // namespace IPC
    428434
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r168260 r168333  
    15291529                E170876B16D6CA6900F99226 /* BlobRegistryProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E170876916D6CA6900F99226 /* BlobRegistryProxy.cpp */; };
    15301530                E170876C16D6CA6900F99226 /* BlobRegistryProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = E170876A16D6CA6900F99226 /* BlobRegistryProxy.h */; };
    1531                 E170877016D6CFE500F99226 /* BlobRegistrationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E170876E16D6CFE400F99226 /* BlobRegistrationData.cpp */; };
    1532                 E170877116D6CFE500F99226 /* BlobRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = E170876F16D6CFE500F99226 /* BlobRegistrationData.h */; };
    15331531                E179088D169BAA62006904C7 /* SecItemShim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18E6947169B77C8009B6670 /* SecItemShim.cpp */; };
    15341532                E179088F169BAA6A006904C7 /* SecItemShim.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E6948169B77C8009B6670 /* SecItemShim.h */; };
     
    34413439                DF58C6351371ACA000F9A37C /* NativeWebWheelEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebWheelEventMac.mm; sourceTree = "<group>"; };
    34423440                E105FE5318D7B9DE008F57A8 /* EditingRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingRange.h; sourceTree = "<group>"; };
    3443                 E115C715190F8A2500ECC516 /* com.apple.WebKit.Databases.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; path = com.apple.WebKit.Databases.sb; sourceTree = "<group>"; };
     3441                E115C715190F8A2500ECC516 /* com.apple.WebKit.Databases.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.WebKit.Databases.sb; sourceTree = "<group>"; };
    34443442                E133FD891423DD7F00FC7BFB /* WebKit.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = WebKit.icns; path = Resources/WebKit.icns; sourceTree = "<group>"; };
    34453443                E13833EB189C33C8001E2350 /* LocalStorageDetails.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalStorageDetails.h; sourceTree = "<group>"; };
     
    34533451                E170876916D6CA6900F99226 /* BlobRegistryProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobRegistryProxy.cpp; path = WebProcess/FileAPI/BlobRegistryProxy.cpp; sourceTree = "<group>"; };
    34543452                E170876A16D6CA6900F99226 /* BlobRegistryProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobRegistryProxy.h; path = WebProcess/FileAPI/BlobRegistryProxy.h; sourceTree = "<group>"; };
    3455                 E170876E16D6CFE400F99226 /* BlobRegistrationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobRegistrationData.cpp; path = FileAPI/BlobRegistrationData.cpp; sourceTree = "<group>"; };
    3456                 E170876F16D6CFE500F99226 /* BlobRegistrationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobRegistrationData.h; path = FileAPI/BlobRegistrationData.h; sourceTree = "<group>"; };
    34573453                E1798C7716E6818800240139 /* NetworkBlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkBlobRegistry.cpp; path = NetworkProcess/FileAPI/NetworkBlobRegistry.cpp; sourceTree = "<group>"; };
    34583454                E1798C7816E6818800240139 /* NetworkBlobRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkBlobRegistry.h; path = NetworkProcess/FileAPI/NetworkBlobRegistry.h; sourceTree = "<group>"; };
     
    65786574                        isa = PBXGroup;
    65796575                        children = (
    6580                                 E170876E16D6CFE400F99226 /* BlobRegistrationData.cpp */,
    6581                                 E170876F16D6CFE500F99226 /* BlobRegistrationData.h */,
    65826576                        );
    65836577                        name = FileAPI;
     
    66716665                                518E8EF916B2091C00E91429 /* AuthenticationManager.h in Headers */,
    66726666                                512F58A312A883AD00629530 /* AuthenticationManagerMessages.h in Headers */,
    6673                                 E170877116D6CFE500F99226 /* BlobRegistrationData.h in Headers */,
    66746667                                E170876C16D6CA6900F99226 /* BlobRegistryProxy.h in Headers */,
    66756668                                4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */,
     
    81558148                                518E8EFB16B2091C00E91429 /* AuthenticationManager.mac.mm in Sources */,
    81568149                                512F58A212A883AD00629530 /* AuthenticationManagerMessageReceiver.cpp in Sources */,
    8157                                 E170877016D6CFE500F99226 /* BlobRegistrationData.cpp in Sources */,
    81588150                                E170876B16D6CA6900F99226 /* BlobRegistryProxy.cpp in Sources */,
    81598151                                BCF18638167D071E00A1A85A /* CacheModel.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp

    r168126 r168333  
    2929#if ENABLE(BLOB) && ENABLE(NETWORK_PROCESS)
    3030
    31 #include "BlobRegistrationData.h"
    3231#include "NetworkConnectionToWebProcessMessages.h"
    3332#include "NetworkProcessConnection.h"
    3433#include "WebCoreArgumentCoders.h"
    3534#include "WebProcess.h"
    36 #include <WebCore/BlobData.h>
    3735
    3836using namespace WebCore;
     
    4038namespace WebKit {
    4139
    42 unsigned long long BlobRegistryProxy::registerBlobURL(const URL& url, std::unique_ptr<BlobData> blobData)
     40void BlobRegistryProxy::registerFileBlobURL(const WebCore::URL& url, const String& path, const String& contentType)
     41{
     42    ASSERT(WebProcess::shared().usesNetworkProcess());
     43
     44    SandboxExtension::Handle extensionHandle;
     45
     46    // File path can be empty when submitting a form file input without a file, see bug 111778.
     47    if (!path.isEmpty())
     48        SandboxExtension::createHandle(path, SandboxExtension::ReadOnly, extensionHandle);
     49
     50    WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::RegisterFileBlobURL(url, path, extensionHandle, contentType), 0);
     51}
     52
     53unsigned long long BlobRegistryProxy::registerBlobURL(const URL& url, Vector<BlobPart> blobParts, const String& contentType)
    4354{
    4455    ASSERT(WebProcess::shared().usesNetworkProcess());
    4556
    4657    uint64_t resultSize;
    47     if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::RegisterBlobURL(url, BlobRegistrationData(std::move(blobData))), Messages::NetworkConnectionToWebProcess::RegisterBlobURL::Reply(resultSize), 0))
     58    if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::RegisterBlobURL(url, blobParts, contentType), Messages::NetworkConnectionToWebProcess::RegisterBlobURL::Reply(resultSize), 0))
    4859        return 0;
    4960    return resultSize;
  • trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h

    r168126 r168333  
    3333namespace WebKit {
    3434
    35 class BlobRegistryProxy : public WebCore::BlobRegistry {
     35class BlobRegistryProxy final : public WebCore::BlobRegistry {
    3636public:
    37     virtual unsigned long long registerBlobURL(const WebCore::URL&, std::unique_ptr<WebCore::BlobData>) override;
     37    virtual void registerFileBlobURL(const WebCore::URL&, const String& path, const String& contentType) override;
     38    virtual unsigned long long registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType) override;
    3839    virtual void registerBlobURL(const WebCore::URL&, const WebCore::URL& srcURL) override;
    3940    virtual void unregisterBlobURL(const WebCore::URL&) override;
Note: See TracChangeset for help on using the changeset viewer.