| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 void BlobData::appendFileSystemURL(const KURL& url, | 127 void BlobData::appendFileSystemURL(const KURL& url, |
| 128 long long offset, | 128 long long offset, |
| 129 long long length, | 129 long long length, |
| 130 double expectedModificationTime) { | 130 double expectedModificationTime) { |
| 131 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) | 131 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) |
| 132 << "Blobs with a unknown-size file cannot have other items."; | 132 << "Blobs with a unknown-size file cannot have other items."; |
| 133 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); | 133 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void BlobData::appendText(const String& text, | 136 void BlobData::appendText(const String& text) { |
| 137 bool doNormalizeLineEndingsToNative) { | |
| 138 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) | 137 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) |
| 139 << "Blobs with a unknown-size file cannot have other items."; | 138 << "Blobs with a unknown-size file cannot have other items."; |
| 140 CString utf8Text = UTF8Encoding().encode(text, WTF::EntitiesForUnencodables); | 139 CString utf8Text = UTF8Encoding().encode(text, WTF::EntitiesForUnencodables); |
| 141 RefPtr<RawData> data = nullptr; | 140 RefPtr<RawData> data = nullptr; |
| 142 Vector<char>* buffer; | 141 Vector<char>* buffer; |
| 143 if (canConsolidateData(text.length())) { | 142 if (canConsolidateData(text.length())) { |
| 144 buffer = m_items.back().data->mutableData(); | 143 buffer = m_items.back().data->mutableData(); |
| 145 } else { | 144 } else { |
| 146 data = RawData::create(); | 145 data = RawData::create(); |
| 147 buffer = data->mutableData(); | 146 buffer = data->mutableData(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 if (doNormalizeLineEndingsToNative) { | 149 buffer->append(utf8Text.data(), utf8Text.length()); |
| 151 normalizeLineEndingsToNative(utf8Text, *buffer); | |
| 152 } else { | |
| 153 buffer->append(utf8Text.data(), utf8Text.length()); | |
| 154 } | |
| 155 | 150 |
| 156 if (data) | 151 if (data) |
| 157 m_items.append(BlobDataItem(data.release())); | 152 m_items.append(BlobDataItem(data.release())); |
| 158 } | 153 } |
| 159 | 154 |
| 160 void BlobData::appendBytes(const void* bytes, size_t length) { | 155 void BlobData::appendBytes(const void* bytes, size_t length) { |
| 161 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) | 156 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) |
| 162 << "Blobs with a unknown-size file cannot have other items."; | 157 << "Blobs with a unknown-size file cannot have other items."; |
| 163 if (canConsolidateData(length)) { | 158 if (canConsolidateData(length)) { |
| 164 m_items.back().data->mutableData()->append(static_cast<const char*>(bytes), | 159 m_items.back().data->mutableData()->append(static_cast<const char*>(bytes), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""), | 221 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""), |
| 227 m_size(size) { | 222 m_size(size) { |
| 228 BlobRegistry::addBlobDataRef(m_uuid); | 223 BlobRegistry::addBlobDataRef(m_uuid); |
| 229 } | 224 } |
| 230 | 225 |
| 231 BlobDataHandle::~BlobDataHandle() { | 226 BlobDataHandle::~BlobDataHandle() { |
| 232 BlobRegistry::removeBlobDataRef(m_uuid); | 227 BlobRegistry::removeBlobDataRef(m_uuid); |
| 233 } | 228 } |
| 234 | 229 |
| 235 } // namespace blink | 230 } // namespace blink |
| OLD | NEW |