| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/fileapi/Blob.h" | 31 #include "core/fileapi/Blob.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
| 34 #include "core/dom/DOMURL.h" | 34 #include "core/dom/DOMURL.h" |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "core/fileapi/BlobPropertyBag.h" | 37 #include "core/fileapi/BlobPropertyBag.h" |
| 38 #include "core/frame/UseCounter.h" |
| 38 #include "platform/blob/BlobRegistry.h" | 39 #include "platform/blob/BlobRegistry.h" |
| 39 #include "platform/blob/BlobURL.h" | 40 #include "platform/blob/BlobURL.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 class BlobURLRegistry final : public URLRegistry { | 46 class BlobURLRegistry final : public URLRegistry { |
| 46 public: | 47 public: |
| 47 void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) override; | 48 void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) override; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 78 : m_blobDataHandle(dataHandle) | 79 : m_blobDataHandle(dataHandle) |
| 79 , m_hasBeenClosed(false) | 80 , m_hasBeenClosed(false) |
| 80 { | 81 { |
| 81 } | 82 } |
| 82 | 83 |
| 83 Blob::~Blob() | 84 Blob::~Blob() |
| 84 { | 85 { |
| 85 } | 86 } |
| 86 | 87 |
| 87 // static | 88 // static |
| 88 Blob* Blob::create(const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrString>&
blobParts, const BlobPropertyBag& options, ExceptionState& exceptionState) | 89 Blob* Blob::create(ExecutionContext* context, const HeapVector<ArrayBufferOrArra
yBufferViewOrBlobOrString>& blobParts, const BlobPropertyBag& options, Exception
State& exceptionState) |
| 89 { | 90 { |
| 90 ASSERT(options.hasType()); | 91 ASSERT(options.hasType()); |
| 91 if (!options.type().containsOnlyASCII()) { | 92 if (!options.type().containsOnlyASCII()) { |
| 92 exceptionState.throwDOMException(SyntaxError, "The 'type' property must
consist of ASCII characters."); | 93 exceptionState.throwDOMException(SyntaxError, "The 'type' property must
consist of ASCII characters."); |
| 93 return nullptr; | 94 return nullptr; |
| 94 } | 95 } |
| 95 | 96 |
| 96 ASSERT(options.hasEndings()); | 97 ASSERT(options.hasEndings()); |
| 97 bool normalizeLineEndingsToNative = options.endings() == "native"; | 98 bool normalizeLineEndingsToNative = options.endings() == "native"; |
| 99 if (normalizeLineEndingsToNative) |
| 100 UseCounter::count(context, UseCounter::FileAPINativeLineEndings); |
| 98 | 101 |
| 99 OwnPtr<BlobData> blobData = BlobData::create(); | 102 OwnPtr<BlobData> blobData = BlobData::create(); |
| 100 blobData->setContentType(options.type().lower()); | 103 blobData->setContentType(options.type().lower()); |
| 101 | 104 |
| 102 populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); | 105 populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); |
| 103 | 106 |
| 104 long long blobSize = blobData->length(); | 107 long long blobSize = blobData->length(); |
| 105 return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); | 108 return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); |
| 106 } | 109 } |
| 107 | 110 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 { | 188 { |
| 186 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); | 189 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); |
| 187 } | 190 } |
| 188 | 191 |
| 189 URLRegistry& Blob::registry() const | 192 URLRegistry& Blob::registry() const |
| 190 { | 193 { |
| 191 return BlobURLRegistry::registry(); | 194 return BlobURLRegistry::registry(); |
| 192 } | 195 } |
| 193 | 196 |
| 194 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |