| 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 "BlobData.h" | 32 #include "BlobData.h" |
| 33 | 33 |
| 34 #include "BlobRegistry.h" |
| 35 #include "UUID.h" |
| 34 #include <wtf/OwnPtr.h> | 36 #include <wtf/OwnPtr.h> |
| 35 #include <wtf/PassOwnPtr.h> | 37 #include <wtf/PassOwnPtr.h> |
| 36 #include <wtf/PassRefPtr.h> | 38 #include <wtf/PassRefPtr.h> |
| 37 #include <wtf/RefPtr.h> | 39 #include <wtf/RefPtr.h> |
| 38 #include <wtf/Vector.h> | 40 #include <wtf/Vector.h> |
| 39 | 41 |
| 40 namespace WebCore { | 42 namespace WebCore { |
| 41 | 43 |
| 42 const long long BlobDataItem::toEndOfFile = -1; | 44 const long long BlobDataItem::toEndOfFile = -1; |
| 43 | 45 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 void BlobData::appendFile(const String& path) | 79 void BlobData::appendFile(const String& path) |
| 78 { | 80 { |
| 79 m_items.append(BlobDataItem(path)); | 81 m_items.append(BlobDataItem(path)); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void BlobData::appendFile(const String& path, long long offset, long long length
, double expectedModificationTime) | 84 void BlobData::appendFile(const String& path, long long offset, long long length
, double expectedModificationTime) |
| 83 { | 85 { |
| 84 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime))
; | 86 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime))
; |
| 85 } | 87 } |
| 86 | 88 |
| 87 void BlobData::appendBlob(const KURL& url, long long offset, long long length) | 89 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> blobDataHandle, long long o
ffset, long long length) |
| 88 { | 90 { |
| 89 m_items.append(BlobDataItem(url, offset, length)); | 91 m_items.append(BlobDataItem(blobDataHandle, offset, length)); |
| 90 } | 92 } |
| 91 | 93 |
| 92 #if ENABLE(FILE_SYSTEM) | 94 #if ENABLE(FILE_SYSTEM) |
| 93 void BlobData::appendURL(const KURL& url, long long offset, long long length, do
uble expectedModificationTime) | 95 void BlobData::appendURL(const KURL& url, long long offset, long long length, do
uble expectedModificationTime) |
| 94 { | 96 { |
| 95 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); | 97 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); |
| 96 } | 98 } |
| 97 #endif | 99 #endif |
| 98 | 100 |
| 99 void BlobData::swapItems(BlobDataItemList& items) | 101 void BlobData::swapItems(BlobDataItemList& items) |
| 100 { | 102 { |
| 101 m_items.swap(items); | 103 m_items.swap(items); |
| 102 } | 104 } |
| 103 | 105 |
| 106 // ------------- seperate file -------------------------------------- |
| 107 |
| 108 BlobDataHandle::BlobDataHandle() |
| 109 : m_uuid(createCanonicalUUIDString()) |
| 110 , m_size(0) |
| 111 { |
| 112 blobRegistry().registerBlobData(m_uuid, BlobData::create()); |
| 113 } |
| 114 |
| 115 BlobDataHandle::BlobDataHandle(PassOwnPtr<BlobData> data, long long size) |
| 116 : m_uuid(createCanonicalUUIDString()) |
| 117 , m_type(data->contentType().isolatedCopy()) |
| 118 , m_size(size) |
| 119 { |
| 120 blobRegistry().registerBlobData(m_uuid, data); |
| 121 } |
| 122 |
| 123 BlobDataHandle::BlobDataHandle(const String& uuid, const String& type, long long
size) |
| 124 : m_uuid(uuid.isolatedCopy()) |
| 125 , m_type(type.isolatedCopy()) |
| 126 , m_size(size) |
| 127 { |
| 128 blobRegistry().addBlobDataRef(m_uuid); |
| 129 } |
| 130 |
| 131 BlobDataHandle::~BlobDataHandle() |
| 132 { |
| 133 blobRegistry().removeBlobDataRef(m_uuid); |
| 134 } |
| 135 |
| 104 } // namespace WebCore | 136 } // namespace WebCore |
| OLD | NEW |