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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 Blob::~Blob() | 84 Blob::~Blob() |
85 { | 85 { |
86 } | 86 } |
87 | 87 |
88 // static | 88 // static |
89 Blob* Blob::create(const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrString>&
blobParts, const BlobPropertyBag& options, ExceptionState& exceptionState) | 89 Blob* Blob::create(const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrString>&
blobParts, const BlobPropertyBag& options, ExceptionState& exceptionState) |
90 { | 90 { |
91 ASSERT(options.hasType()); | 91 ASSERT(options.hasType()); |
92 if (!options.type().containsOnlyASCII()) { | |
93 exceptionState.throwDOMException(SyntaxError, "The 'type' property must
consist of ASCII characters."); | |
94 return nullptr; | |
95 } | |
96 | 92 |
97 ASSERT(options.hasEndings()); | 93 ASSERT(options.hasEndings()); |
98 bool normalizeLineEndingsToNative = options.endings() == "native"; | 94 bool normalizeLineEndingsToNative = options.endings() == "native"; |
99 | 95 |
100 OwnPtr<BlobData> blobData = BlobData::create(); | 96 OwnPtr<BlobData> blobData = BlobData::create(); |
101 blobData->setContentType(options.type().lower()); | 97 blobData->setContentType(options.type().lower()); |
102 | 98 |
103 populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); | 99 populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); |
104 | 100 |
105 long long blobSize = blobData->length(); | 101 long long blobSize = blobData->length(); |
(...skipping 29 matching lines...) Expand all Loading... |
135 if (hasBeenClosed()) { | 131 if (hasBeenClosed()) { |
136 exceptionState.throwDOMException(InvalidStateError, "Blob has been close
d."); | 132 exceptionState.throwDOMException(InvalidStateError, "Blob has been close
d."); |
137 return nullptr; | 133 return nullptr; |
138 } | 134 } |
139 | 135 |
140 long long size = this->size(); | 136 long long size = this->size(); |
141 clampSliceOffsets(size, start, end); | 137 clampSliceOffsets(size, start, end); |
142 | 138 |
143 long long length = end - start; | 139 long long length = end - start; |
144 OwnPtr<BlobData> blobData = BlobData::create(); | 140 OwnPtr<BlobData> blobData = BlobData::create(); |
145 blobData->setContentType(contentType); | 141 blobData->setContentType(contentType.lower()); |
146 blobData->appendBlob(m_blobDataHandle, start, length); | 142 blobData->appendBlob(m_blobDataHandle, start, length); |
147 return Blob::create(BlobDataHandle::create(blobData.release(), length)); | 143 return Blob::create(BlobDataHandle::create(blobData.release(), length)); |
148 } | 144 } |
149 | 145 |
150 void Blob::close(ExecutionContext* executionContext, ExceptionState& exceptionSt
ate) | 146 void Blob::close(ExecutionContext* executionContext, ExceptionState& exceptionSt
ate) |
151 { | 147 { |
152 if (hasBeenClosed()) { | 148 if (hasBeenClosed()) { |
153 exceptionState.throwDOMException(InvalidStateError, "Blob has been close
d."); | 149 exceptionState.throwDOMException(InvalidStateError, "Blob has been close
d."); |
154 return; | 150 return; |
155 } | 151 } |
(...skipping 17 matching lines...) Expand all Loading... |
173 { | 169 { |
174 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); | 170 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); |
175 } | 171 } |
176 | 172 |
177 URLRegistry& Blob::registry() const | 173 URLRegistry& Blob::registry() const |
178 { | 174 { |
179 return BlobURLRegistry::registry(); | 175 return BlobURLRegistry::registry(); |
180 } | 176 } |
181 | 177 |
182 } // namespace blink | 178 } // namespace blink |
OLD | NEW |