| 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 14 matching lines...) Expand all Loading... |
| 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/platform/network/BlobData.h" | 32 #include "core/platform/network/BlobData.h" |
| 33 | 33 |
| 34 #include "core/fileapi/BlobRegistry.h" | 34 #include "core/fileapi/BlobRegistry.h" |
| 35 #include "core/fileapi/BlobURL.h" | 35 #include "platform/UUID.h" |
| 36 #include "wtf/OwnPtr.h" | 36 #include "wtf/OwnPtr.h" |
| 37 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 const long long BlobDataItem::toEndOfFile = -1; | 44 const long long BlobDataItem::toEndOfFile = -1; |
| 45 | 45 |
| 46 RawData::RawData() | 46 RawData::RawData() |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void RawData::detachFromCurrentThread() | 50 void RawData::detachFromCurrentThread() |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void BlobDataItem::detachFromCurrentThread() | 54 void BlobDataItem::detachFromCurrentThread() |
| 55 { | 55 { |
| 56 data->detachFromCurrentThread(); | 56 data->detachFromCurrentThread(); |
| 57 path = path.isolatedCopy(); | 57 path = path.isolatedCopy(); |
| 58 url = url.copy(); | 58 fileSystemURL = fileSystemURL.copy(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 PassOwnPtr<BlobData> BlobData::create() | 61 PassOwnPtr<BlobData> BlobData::create() |
| 62 { | 62 { |
| 63 return adoptPtr(new BlobData()); | 63 return adoptPtr(new BlobData()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void BlobData::detachFromCurrentThread() | 66 void BlobData::detachFromCurrentThread() |
| 67 { | 67 { |
| 68 m_contentType = m_contentType.isolatedCopy(); | 68 m_contentType = m_contentType.isolatedCopy(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 void BlobData::appendFile(const String& path) | 79 void BlobData::appendFile(const String& path) |
| 80 { | 80 { |
| 81 m_items.append(BlobDataItem(path)); | 81 m_items.append(BlobDataItem(path)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 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) |
| 85 { | 85 { |
| 86 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime))
; | 86 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime))
; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void BlobData::appendBlob(const KURL& url, long long offset, long long length) | 89 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> dataHandle, long long offse
t, long long length) |
| 90 { | 90 { |
| 91 m_items.append(BlobDataItem(url, offset, length)); | 91 m_items.append(BlobDataItem(dataHandle, offset, length)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void BlobData::appendURL(const KURL& url, long long offset, long long length, do
uble expectedModificationTime) | 94 void BlobData::appendFileSystemURL(const KURL& url, long long offset, long long
length, double expectedModificationTime) |
| 95 { | 95 { |
| 96 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); | 96 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void BlobData::swapItems(BlobDataItemList& items) | 99 void BlobData::swapItems(BlobDataItemList& items) |
| 100 { | 100 { |
| 101 m_items.swap(items); | 101 m_items.swap(items); |
| 102 } | 102 } |
| 103 | 103 |
| 104 BlobDataHandle::BlobDataHandle() |
| 105 : m_uuid(createCanonicalUUIDString()) |
| 106 , m_size(0) |
| 107 { |
| 108 BlobRegistry::registerBlobData(m_uuid, BlobData::create()); |
| 109 } |
| 104 | 110 |
| 105 BlobDataHandle::BlobDataHandle(PassOwnPtr<BlobData> data, long long size) | 111 BlobDataHandle::BlobDataHandle(PassOwnPtr<BlobData> data, long long size) |
| 112 : m_uuid(createCanonicalUUIDString()) |
| 113 , m_type(data->contentType().isolatedCopy()) |
| 114 , m_size(size) |
| 106 { | 115 { |
| 107 UNUSED_PARAM(size); | 116 BlobRegistry::registerBlobData(m_uuid, data); |
| 108 m_internalURL = BlobURL::createInternalURL(); | 117 } |
| 109 BlobRegistry::registerBlobURL(m_internalURL, data); | 118 |
| 119 BlobDataHandle::BlobDataHandle(const String& uuid, const String& type, long long
size) |
| 120 : m_uuid(uuid.isolatedCopy()) |
| 121 , m_type(type.isolatedCopy()) |
| 122 , m_size(size) |
| 123 { |
| 124 BlobRegistry::addBlobDataRef(m_uuid); |
| 110 } | 125 } |
| 111 | 126 |
| 112 BlobDataHandle::~BlobDataHandle() | 127 BlobDataHandle::~BlobDataHandle() |
| 113 { | 128 { |
| 114 BlobRegistry::unregisterBlobURL(m_internalURL); | 129 BlobRegistry::removeBlobDataRef(m_uuid); |
| 115 } | 130 } |
| 116 | 131 |
| 117 } // namespace WebCore | 132 } // namespace WebCore |
| OLD | NEW |