| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 buffer = data->mutableData(); | 149 buffer = data->mutableData(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 if (doNormalizeLineEndingsToNative) { | 152 if (doNormalizeLineEndingsToNative) { |
| 153 normalizeLineEndingsToNative(utf8Text, *buffer); | 153 normalizeLineEndingsToNative(utf8Text, *buffer); |
| 154 } else { | 154 } else { |
| 155 buffer->append(utf8Text.data(), utf8Text.length()); | 155 buffer->append(utf8Text.data(), utf8Text.length()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 if (data) | 158 if (data) |
| 159 m_items.push_back(BlobDataItem(data.release())); | 159 m_items.push_back(BlobDataItem(std::move(data))); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void BlobData::appendBytes(const void* bytes, size_t length) { | 162 void BlobData::appendBytes(const void* bytes, size_t length) { |
| 163 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) | 163 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) |
| 164 << "Blobs with a unknown-size file cannot have other items."; | 164 << "Blobs with a unknown-size file cannot have other items."; |
| 165 if (canConsolidateData(length)) { | 165 if (canConsolidateData(length)) { |
| 166 m_items.back().data->mutableData()->append(static_cast<const char*>(bytes), | 166 m_items.back().data->mutableData()->append(static_cast<const char*>(bytes), |
| 167 length); | 167 length); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 RefPtr<RawData> data = RawData::create(); | 170 RefPtr<RawData> data = RawData::create(); |
| 171 Vector<char>* buffer = data->mutableData(); | 171 Vector<char>* buffer = data->mutableData(); |
| 172 buffer->append(static_cast<const char*>(bytes), length); | 172 buffer->append(static_cast<const char*>(bytes), length); |
| 173 m_items.push_back(BlobDataItem(data.release())); | 173 m_items.push_back(BlobDataItem(std::move(data))); |
| 174 } | 174 } |
| 175 | 175 |
| 176 long long BlobData::length() const { | 176 long long BlobData::length() const { |
| 177 long long length = 0; | 177 long long length = 0; |
| 178 | 178 |
| 179 for (Vector<BlobDataItem>::const_iterator it = m_items.begin(); | 179 for (Vector<BlobDataItem>::const_iterator it = m_items.begin(); |
| 180 it != m_items.end(); ++it) { | 180 it != m_items.end(); ++it) { |
| 181 const BlobDataItem& item = *it; | 181 const BlobDataItem& item = *it; |
| 182 if (item.length != BlobDataItem::toEndOfFile) { | 182 if (item.length != BlobDataItem::toEndOfFile) { |
| 183 ASSERT(item.length >= 0); | 183 ASSERT(item.length >= 0); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""), | 228 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""), |
| 229 m_size(size) { | 229 m_size(size) { |
| 230 BlobRegistry::addBlobDataRef(m_uuid); | 230 BlobRegistry::addBlobDataRef(m_uuid); |
| 231 } | 231 } |
| 232 | 232 |
| 233 BlobDataHandle::~BlobDataHandle() { | 233 BlobDataHandle::~BlobDataHandle() { |
| 234 BlobRegistry::removeBlobDataRef(m_uuid); | 234 BlobRegistry::removeBlobDataRef(m_uuid); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |