| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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 "config.h" | 31 #include "config.h" |
| 32 #include "core/fileapi/Blob.h" | 32 #include "core/fileapi/Blob.h" |
| 33 | 33 |
| 34 #include "core/fileapi/File.h" |
| 34 #include "platform/blob/BlobRegistry.h" | 35 #include "platform/blob/BlobRegistry.h" |
| 35 #include "platform/blob/BlobURL.h" | 36 #include "platform/blob/BlobURL.h" |
| 36 | 37 |
| 37 namespace WebCore { | 38 namespace WebCore { |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 class BlobURLRegistry FINAL : public URLRegistry { | 42 class BlobURLRegistry FINAL : public URLRegistry { |
| 42 public: | 43 public: |
| 43 virtual void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) OVER
RIDE; | 44 virtual void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) OVER
RIDE; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 end = 0; | 93 end = 0; |
| 93 if (start >= size) { | 94 if (start >= size) { |
| 94 start = 0; | 95 start = 0; |
| 95 end = 0; | 96 end = 0; |
| 96 } else if (end < start) | 97 } else if (end < start) |
| 97 end = start; | 98 end = start; |
| 98 else if (end > size) | 99 else if (end > size) |
| 99 end = size; | 100 end = size; |
| 100 } | 101 } |
| 101 | 102 |
| 102 PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& conte
ntType) const | 103 PassRefPtrWillBeRawPtr<Blob> Blob::slice(long long start, long long end, const S
tring& contentType) const |
| 103 { | 104 { |
| 104 long long size = this->size(); | 105 long long size = this->size(); |
| 105 clampSliceOffsets(size, start, end); | 106 clampSliceOffsets(size, start, end); |
| 106 | 107 |
| 107 long long length = end - start; | 108 long long length = end - start; |
| 108 OwnPtr<BlobData> blobData = BlobData::create(); | 109 OwnPtr<BlobData> blobData = BlobData::create(); |
| 109 blobData->setContentType(contentType); | 110 blobData->setContentType(contentType); |
| 110 blobData->appendBlob(m_blobDataHandle, start, length); | 111 blobData->appendBlob(m_blobDataHandle, start, length); |
| 111 return Blob::create(BlobDataHandle::create(blobData.release(), length)); | 112 return Blob::create(BlobDataHandle::create(blobData.release(), length)); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void Blob::appendTo(BlobData& blobData) const | 115 void Blob::appendTo(BlobData& blobData) const |
| 115 { | 116 { |
| 116 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); | 117 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); |
| 117 } | 118 } |
| 118 | 119 |
| 119 URLRegistry& Blob::registry() const | 120 URLRegistry& Blob::registry() const |
| 120 { | 121 { |
| 121 return BlobURLRegistry::registry(); | 122 return BlobURLRegistry::registry(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 | |
| 125 } // namespace WebCore | 125 } // namespace WebCore |
| OLD | NEW |