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