Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: third_party/WebKit/Source/platform/blob/BlobData.cpp

Issue 2147633002: Remove nonstandard 'endings' option for Blob/File constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/blob/BlobData.h ('k') | third_party/WebKit/Source/platform/blob/BlobDataTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698