| 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 23 matching lines...) Expand all Loading... |
| 34 #include "bindings/core/v8/ScriptWrappable.h" | 34 #include "bindings/core/v8/ScriptWrappable.h" |
| 35 #include "bindings/core/v8/UnionTypesCore.h" | 35 #include "bindings/core/v8/UnionTypesCore.h" |
| 36 #include "core/CoreExport.h" | 36 #include "core/CoreExport.h" |
| 37 #include "core/dom/DOMArrayBuffer.h" | 37 #include "core/dom/DOMArrayBuffer.h" |
| 38 #include "core/dom/DOMArrayBufferView.h" | 38 #include "core/dom/DOMArrayBufferView.h" |
| 39 #include "core/html/URLRegistry.h" | 39 #include "core/html/URLRegistry.h" |
| 40 #include "core/imagebitmap/ImageBitmapSource.h" | 40 #include "core/imagebitmap/ImageBitmapSource.h" |
| 41 #include "platform/blob/BlobData.h" | 41 #include "platform/blob/BlobData.h" |
| 42 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
| 43 #include "wtf/PassRefPtr.h" | 43 #include "wtf/PassRefPtr.h" |
| 44 #include "wtf/RefCounted.h" |
| 44 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
| 45 | 46 |
| 46 namespace blink { | 47 namespace blink { |
| 47 | 48 |
| 48 class BlobPropertyBag; | 49 class BlobPropertyBag; |
| 49 class ExceptionState; | 50 class ExceptionState; |
| 50 class ExecutionContext; | 51 class ExecutionContext; |
| 51 | 52 |
| 52 class CORE_EXPORT Blob : public GarbageCollectedFinalized<Blob>, public ScriptWr
appable, public URLRegistrable, public ImageBitmapSource { | 53 class CORE_EXPORT Blob : public GarbageCollectedFinalized<Blob>, public ScriptWr
appable, public URLRegistrable, public ImageBitmapSource { |
| 53 DEFINE_WRAPPERTYPEINFO(); | 54 DEFINE_WRAPPERTYPEINFO(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 110 |
| 110 protected: | 111 protected: |
| 111 explicit Blob(PassRefPtr<BlobDataHandle>); | 112 explicit Blob(PassRefPtr<BlobDataHandle>); |
| 112 | 113 |
| 113 template<typename ItemType> | 114 template<typename ItemType> |
| 114 static void populateBlobData(BlobData* blobData, const HeapVector<ItemType>&
parts, bool normalizeLineEndingsToNative) | 115 static void populateBlobData(BlobData* blobData, const HeapVector<ItemType>&
parts, bool normalizeLineEndingsToNative) |
| 115 { | 116 { |
| 116 for (size_t i = 0; i < parts.size(); ++i) { | 117 for (size_t i = 0; i < parts.size(); ++i) { |
| 117 const ItemType& item = parts[i]; | 118 const ItemType& item = parts[i]; |
| 118 if (item.isArrayBuffer()) { | 119 if (item.isArrayBuffer()) { |
| 119 DOMArrayBuffer* arrayBuffer = item.getAsArrayBuffer(); | 120 RefPtr<DOMArrayBuffer> arrayBuffer = item.getAsArrayBuffer(); |
| 120 blobData->appendBytes(arrayBuffer->data(), arrayBuffer->byteLeng
th()); | 121 blobData->appendBytes(arrayBuffer->data(), arrayBuffer->byteLeng
th()); |
| 121 } else if (item.isArrayBufferView()) { | 122 } else if (item.isArrayBufferView()) { |
| 122 DOMArrayBufferView* arrayBufferView = item.getAsArrayBufferView(
); | 123 RefPtr<DOMArrayBufferView> arrayBufferView = item.getAsArrayBuff
erView(); |
| 123 blobData->appendBytes(arrayBufferView->baseAddress(), arrayBuffe
rView->byteLength()); | 124 blobData->appendBytes(arrayBufferView->baseAddress(), arrayBuffe
rView->byteLength()); |
| 124 } else if (item.isBlob()) { | 125 } else if (item.isBlob()) { |
| 125 item.getAsBlob()->appendTo(*blobData); | 126 item.getAsBlob()->appendTo(*blobData); |
| 126 } else if (item.isString()) { | 127 } else if (item.isString()) { |
| 127 blobData->appendText(item.getAsString(), normalizeLineEndingsToN
ative); | 128 blobData->appendText(item.getAsString(), normalizeLineEndingsToN
ative); |
| 128 } else { | 129 } else { |
| 129 ASSERT_NOT_REACHED(); | 130 ASSERT_NOT_REACHED(); |
| 130 } | 131 } |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 | 134 |
| 134 static void clampSliceOffsets(long long size, long long& start, long long& e
nd); | 135 static void clampSliceOffsets(long long size, long long& start, long long& e
nd); |
| 135 private: | 136 private: |
| 136 Blob(); | 137 Blob(); |
| 137 | 138 |
| 138 RefPtr<BlobDataHandle> m_blobDataHandle; | 139 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 139 bool m_hasBeenClosed; | 140 bool m_hasBeenClosed; |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 } // namespace blink | 143 } // namespace blink |
| 143 | 144 |
| 144 #endif // Blob_h | 145 #endif // Blob_h |
| OLD | NEW |