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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 file->captureSnapshot(snapshotSize, snapshotModificationTime); | 103 file->captureSnapshot(snapshotSize, snapshotModificationTime); |
104 | 104 |
105 m_size += snapshotSize; | 105 m_size += snapshotSize; |
106 if (!file->fileSystemURL().isEmpty()) | 106 if (!file->fileSystemURL().isEmpty()) |
107 m_items.append(BlobDataItem(file->fileSystemURL(), 0, snapshotSize,
snapshotModificationTime)); | 107 m_items.append(BlobDataItem(file->fileSystemURL(), 0, snapshotSize,
snapshotModificationTime)); |
108 else | 108 else |
109 m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotM
odificationTime)); | 109 m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotM
odificationTime)); |
110 } else { | 110 } else { |
111 long long blobSize = static_cast<long long>(blob->size()); | 111 long long blobSize = static_cast<long long>(blob->size()); |
112 m_size += blobSize; | 112 m_size += blobSize; |
113 m_items.append(BlobDataItem(blob->url(), 0, blobSize)); | 113 m_items.append(BlobDataItem(blob->blobDataHandle(), 0, blobSize)); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 void BlobBuilder::appendBytesData(const void* data, size_t length) | 117 void BlobBuilder::appendBytesData(const void* data, size_t length) |
118 { | 118 { |
119 Vector<char>& buffer = getBuffer(); | 119 Vector<char>& buffer = getBuffer(); |
120 size_t oldSize = buffer.size(); | 120 size_t oldSize = buffer.size(); |
121 buffer.append(static_cast<const char*>(data), length); | 121 buffer.append(static_cast<const char*>(data), length); |
122 m_size += buffer.size() - oldSize; | 122 m_size += buffer.size() - oldSize; |
123 } | 123 } |
124 | 124 |
125 PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType) | 125 PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType) |
126 { | 126 { |
127 OwnPtr<BlobData> blobData = BlobData::create(); | 127 OwnPtr<BlobData> blobData = BlobData::create(); |
128 blobData->setContentType(contentType); | 128 blobData->setContentType(contentType); |
129 blobData->swapItems(m_items); | 129 blobData->swapItems(m_items); |
130 | 130 |
131 RefPtr<Blob> blob = Blob::create(blobData.release(), m_size); | 131 RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(),
m_size)); |
132 | 132 |
133 // After creating a blob from the current blob data, we do not need to keep
the data around any more. Instead, we only | 133 // After creating a blob from the current blob data, we do not need to keep
the data around any more. |
134 // need to keep a reference to the URL of the blob just created. | 134 // Instead, we only need to keep a reference to the blob data just created. |
135 m_items.append(BlobDataItem(blob->url(), 0, m_size)); | 135 m_items.append(BlobDataItem(blob->blobDataHandle(), 0, m_size)); |
136 | 136 |
137 return blob; | 137 return blob; |
138 } | 138 } |
139 | 139 |
140 } // namespace WebCore | 140 } // namespace WebCore |
OLD | NEW |