⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 130705 in webkit


Ignore:
Timestamp:
Oct 8, 2012, 5:08:57 PM (14 years ago)
Author:
abarth@webkit.org
Message:

Remove unused features of BlobBuilder
​https://bugs.webkit.org/show_bug.cgi?id=98331

Reviewed by Eric Seidel.

Now that we don't expose BlobBuilder as a web platform API, we can
strip down the class to handle only those cases that are needed by the
Blob constructor.

I've also renamed the class from WebKitBlobBuilder to BlobBuilder and
made it stack allocated rather than RefCounted. A future patch will
actually move the files around. (I didn't want to mix moving code
around with modifying the code.)

  • bindings/js/JSBlobCustom.cpp:

(WebCore::JSBlobConstructor::constructJSBlob):

  • bindings/v8/custom/V8BlobCustom.cpp:

(WebCore::V8Blob::constructorCallback):

  • fileapi/WebKitBlobBuilder.cpp:

(WebCore):
(WebCore::BlobBuilder::BlobBuilder):
(WebCore::BlobBuilder::getBuffer):
(WebCore::BlobBuilder::append):
(WebCore::BlobBuilder::appendBytesData):
(WebCore::BlobBuilder::getBlob):

  • fileapi/WebKitBlobBuilder.h:

(WebCore):
(BlobBuilder):

  • page/FeatureObserver.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130704 r130705  
     12012-10-08  Adam Barth  <abarth@webkit.org>
     2
     3        Remove unused features of BlobBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=98331
     5
     6        Reviewed by Eric Seidel.
     7
     8        Now that we don't expose BlobBuilder as a web platform API, we can
     9        strip down the class to handle only those cases that are needed by the
     10        Blob constructor.
     11
     12        I've also renamed the class from WebKitBlobBuilder to BlobBuilder and
     13        made it stack allocated rather than RefCounted. A future patch will
     14        actually move the files around. (I didn't want to mix moving code
     15        around with modifying the code.)
     16
     17        * bindings/js/JSBlobCustom.cpp:
     18        (WebCore::JSBlobConstructor::constructJSBlob):
     19        * bindings/v8/custom/V8BlobCustom.cpp:
     20        (WebCore::V8Blob::constructorCallback):
     21        * fileapi/WebKitBlobBuilder.cpp:
     22        (WebCore):
     23        (WebCore::BlobBuilder::BlobBuilder):
     24        (WebCore::BlobBuilder::getBuffer):
     25        (WebCore::BlobBuilder::append):
     26        (WebCore::BlobBuilder::appendBytesData):
     27        (WebCore::BlobBuilder::getBlob):
     28        * fileapi/WebKitBlobBuilder.h:
     29        (WebCore):
     30        (BlobBuilder):
     31        * page/FeatureObserver.h:
     32
    1332012-10-08  Martin Robinson  <mrobinson@igalia.com>
    234
  • trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp

    r129574 r130705  
    112112    ASSERT(endings == "transparent" || endings == "native");
    113113
    114     // FIXME: this would be better if the WebKitBlobBuilder were a stack object to avoid the allocation.
    115     RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create();
     114    BlobBuilder blobBuilder;
    116115
    117116    JSArray* array = asArray(firstArg);
    … …  
    122121#if ENABLE(BLOB)
    123122        if (item.inherits(&JSArrayBuffer::s_info))
    124             blobBuilder->append(context, toArrayBuffer(item));
     123            blobBuilder.append(context, toArrayBuffer(item));
    125124        else if (item.inherits(&JSArrayBufferView::s_info))
    126             blobBuilder->append(toArrayBufferView(item));
     125            blobBuilder.append(toArrayBufferView(item));
    127126        else
    128127#endif
    129128        if (item.inherits(&JSBlob::s_info))
    130             blobBuilder->append(toBlob(item));
     129            blobBuilder.append(toBlob(item));
    131130        else {
    132131            String string = item.toString(exec)->value(exec);
    133132            if (exec->hadException())
    134133                return JSValue::encode(jsUndefined());
    135             blobBuilder->append(string, endings, ASSERT_NO_EXCEPTION);
     134            blobBuilder.append(string, endings);
    136135        }
    137136    }
    138137
    139     RefPtr<Blob> blob = blobBuilder->getBlob(type, BlobConstructedByConstructor);
     138    RefPtr<Blob> blob = blobBuilder.getBlob(type);
    140139    return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get()));
    141140}
  • trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp

    r128139 r130705  
    106106    ASSERT(endings == "transparent" || endings == "native");
    107107
    108     RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create();
     108    BlobBuilder blobBuilder;
    109109
    110110    EXCEPTION_BLOCK(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(firstArg));
    … …  
    118118            ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item));
    119119            ASSERT(arrayBuffer);
    120             blobBuilder->append(context, arrayBuffer);
     120            blobBuilder.append(context, arrayBuffer);
    121121        } else if (V8ArrayBufferView::HasInstance(item)) {
    122122            ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item));
    123123            ASSERT(arrayBufferView);
    124             blobBuilder->append(arrayBufferView);
     124            blobBuilder.append(arrayBufferView);
    125125        } else
    126126#endif
    … …  
    128128            Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item));
    129129            ASSERT(blob);
    130             blobBuilder->append(blob);
     130            blobBuilder.append(blob);
    131131        } else {
    132132            EXCEPTION_BLOCK(String, stringValue, toWebCoreString(item));
    133             blobBuilder->append(stringValue, endings, ASSERT_NO_EXCEPTION);
     133            blobBuilder.append(stringValue, endings);
    134134        }
    135135    }
    136136
    137     RefPtr<Blob> blob = blobBuilder->getBlob(type, BlobConstructedByConstructor);
     137    RefPtr<Blob> blob = blobBuilder.getBlob(type);
    138138    return toV8(blob.get(), args.Holder(), args.GetIsolate());
    139139}
  • trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp

    r128797 r130705  
    3636#include "Document.h"
    3737#include "ExceptionCode.h"
    38 #include "FeatureObserver.h"
    3938#include "File.h"
    4039#include "HistogramSupport.h"
    … …  
    5251namespace WebCore {
    5352
     53// FIXME: Move this file to BlobBuilder.cpp
     54
    5455enum BlobConstructorArrayBufferOrView {
    5556    BlobConstructorArrayBuffer,
    … …  
    5859};
    5960
    60 // static
    61 PassRefPtr<WebKitBlobBuilder> WebKitBlobBuilder::create(ScriptExecutionContext* context)
    62 {
    63     String message("BlobBuilder is deprecated. Use \"Blob\" constructor instead.");
    64     context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, message);
    65 
    66     if (context->isDocument()) {
    67         Document* document = static_cast<Document*>(context);
    68         FeatureObserver::observe(document->domWindow(), FeatureObserver::LegacyBlobBuilder);
    69     }
    70 
    71     return adoptRef(new WebKitBlobBuilder());
    72 }
    73 
    74 WebKitBlobBuilder::WebKitBlobBuilder()
     61BlobBuilder::BlobBuilder()
    7562    : m_size(0)
    7663{
    7764}
    7865
    79 Vector<char>& WebKitBlobBuilder::getBuffer()
     66Vector<char>& BlobBuilder::getBuffer()
    8067{
    8168    // If the last item is not a data item, create one. Otherwise, we simply append the new string to the last data item.
    … …  
    8673}
    8774
    88 void WebKitBlobBuilder::append(const String& text, const String& endingType, ExceptionCode& ec)
     75void BlobBuilder::append(const String& text, const String& endingType)
    8976{
    90     bool isEndingTypeTransparent = endingType == "transparent";
    91     bool isEndingTypeNative = endingType == "native";
    92     if (!endingType.isEmpty() && !isEndingTypeTransparent && !isEndingTypeNative) {
    93         ec = SYNTAX_ERR;
    94         return;
    95     }
    96 
    9777    CString utf8Text = UTF8Encoding().encode(text.characters(), text.length(), EntitiesForUnencodables);
    9878
    … …  
    10080    size_t oldSize = buffer.size();
    10181
    102     if (isEndingTypeNative)
     82    if (endingType == "native")
    10383        normalizeLineEndingsToNative(utf8Text, buffer);
    104     else
     84    else {
     85        ASSERT(endingType == "transparent");
    10586        buffer.append(utf8Text.data(), utf8Text.length());
     87    }
    10688    m_size += buffer.size() - oldSize;
    10789}
    10890
    109 void WebKitBlobBuilder::append(const String& text, ExceptionCode& ec)
    110 {
    111     append(text, String(), ec);
    112 }
    113 
    11491#if ENABLE(BLOB)
    115 void WebKitBlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer)
     92void BlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer)
    11693{
    11794    String consoleMessage("ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead.");
    … …  
    126103}
    127104
    128 void WebKitBlobBuilder::append(ArrayBufferView* arrayBufferView)
     105void BlobBuilder::append(ArrayBufferView* arrayBufferView)
    129106{
    130107    HistogramSupport::histogramEnumeration("WebCore.Blob.constructor.ArrayBufferOrView", BlobConstructorArrayBufferView, BlobConstructorArrayBufferOrViewMax);
    … …  
    137114#endif
    138115
    139 void WebKitBlobBuilder::append(Blob* blob)
     116void BlobBuilder::append(Blob* blob)
    140117{
    141118    if (!blob)
    … …  
    163140}
    164141
    165 void WebKitBlobBuilder::appendBytesData(const void* data, size_t length)
     142void BlobBuilder::appendBytesData(const void* data, size_t length)
    166143{
    167144    Vector<char>& buffer = getBuffer();
    … …  
    171148}
    172149
    173 PassRefPtr<Blob> WebKitBlobBuilder::getBlob(const String& contentType, BlobConstructionReason constructionReason)
     150PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType)
    174151{
    175     HistogramSupport::histogramEnumeration("WebCore.BlobBuilder.getBlob", constructionReason, BlobConstructionReasonMax);
    176 
    177152    OwnPtr<BlobData> blobData = BlobData::create();
    178153    blobData->setContentType(contentType);
  • trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h

    r125386 r130705  
    3838namespace WebCore {
    3939
     40// FIXME: Move this file to BlobBuilder.h
     41
    4042class Blob;
    4143class ScriptExecutionContext;
    … …  
    4446typedef int ExceptionCode;
    4547
    46 enum BlobConstructionReason {
    47     BlobConstructedByBlobBuilder,
    48     BlobConstructedByConstructor,
    49     BlobConstructionReasonMax,
    50 };
    51 
    52 class WebKitBlobBuilder : public RefCounted<WebKitBlobBuilder> {
     48class BlobBuilder {
    5349public:
    54     // Called when BlobBuilder is instantiated in JS API. We show deprecate warning message.
    55     static PassRefPtr<WebKitBlobBuilder> create(ScriptExecutionContext*);
    56 
    57     // Called by Blob constructor.
    58     static PassRefPtr<WebKitBlobBuilder> create() { return adoptRef(new WebKitBlobBuilder()); }
     50    BlobBuilder();
    5951
    6052    void append(Blob*);
    61     void append(const String& text, ExceptionCode&);
    62     void append(const String& text, const String& ending, ExceptionCode&);
     53    void append(const String& text, const String& ending);
    6354#if ENABLE(BLOB)
    6455    void append(ScriptExecutionContext*, ArrayBuffer*);
    … …  
    6657#endif
    6758
    68     PassRefPtr<Blob> getBlob(const String& contentType = String(), BlobConstructionReason = BlobConstructedByBlobBuilder);
     59    PassRefPtr<Blob> getBlob(const String& contentType);
    6960
    7061private:
    71     WebKitBlobBuilder();
    72 
    7362    void appendBytesData(const void*, size_t);
    7463
  • trunk/Source/WebCore/page/FeatureObserver.h

    r130463 r130705  
    4242        PageDestruction,
    4343        LegacyNotifications,
    44         LegacyBlobBuilder,
     44        UnusedSlot01, // Prior to 10/2012, we used this slot for LegacyBlobBuilder.
    4545        PrefixedIndexedDB,
    4646        WorkerStart,
Note: See TracChangeset for help on using the changeset viewer.