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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 m_size += snapshotSize; | 128 m_size += snapshotSize; |
129 #if ENABLE(FILE_SYSTEM) | 129 #if ENABLE(FILE_SYSTEM) |
130 if (!file->fileSystemURL().isEmpty()) | 130 if (!file->fileSystemURL().isEmpty()) |
131 m_items.append(BlobDataItem(file->fileSystemURL(), 0, snapshotSize,
snapshotModificationTime)); | 131 m_items.append(BlobDataItem(file->fileSystemURL(), 0, snapshotSize,
snapshotModificationTime)); |
132 else | 132 else |
133 #endif | 133 #endif |
134 m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotModif
icationTime)); | 134 m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotModif
icationTime)); |
135 } else { | 135 } else { |
136 long long blobSize = static_cast<long long>(blob->size()); | 136 long long blobSize = static_cast<long long>(blob->size()); |
137 m_size += blobSize; | 137 m_size += blobSize; |
138 m_items.append(BlobDataItem(blob->url(), 0, blobSize)); | 138 m_items.append(BlobDataItem(blob->blobDataHandle(), 0, blobSize)); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 void BlobBuilder::appendBytesData(const void* data, size_t length) | 142 void BlobBuilder::appendBytesData(const void* data, size_t length) |
143 { | 143 { |
144 Vector<char>& buffer = getBuffer(); | 144 Vector<char>& buffer = getBuffer(); |
145 size_t oldSize = buffer.size(); | 145 size_t oldSize = buffer.size(); |
146 buffer.append(static_cast<const char*>(data), length); | 146 buffer.append(static_cast<const char*>(data), length); |
147 m_size += buffer.size() - oldSize; | 147 m_size += buffer.size() - oldSize; |
148 } | 148 } |
149 | 149 |
150 PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType) | 150 PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType) |
151 { | 151 { |
152 OwnPtr<BlobData> blobData = BlobData::create(); | 152 OwnPtr<BlobData> blobData = BlobData::create(); |
153 blobData->setContentType(contentType); | 153 blobData->setContentType(contentType); |
154 blobData->swapItems(m_items); | 154 blobData->swapItems(m_items); |
155 | 155 |
156 RefPtr<Blob> blob = Blob::create(blobData.release(), m_size); | 156 RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(),
m_size)); |
157 | 157 |
158 // After creating a blob from the current blob data, we do not need to keep
the data around any more. Instead, we only | 158 // After creating a blob from the current blob data, we do not need to keep
the data around any more. Instead, we only |
159 // need to keep a reference to the URL of the blob just created. | 159 // need to keep a reference to the blob data just created. |
160 m_items.append(BlobDataItem(blob->url(), 0, m_size)); | 160 m_items.append(BlobDataItem(blob->blobDataHandle(), 0, m_size)); |
161 | 161 |
162 return blob; | 162 return blob; |
163 } | 163 } |
164 | 164 |
165 } // namespace WebCore | 165 } // namespace WebCore |
OLD | NEW |