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

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

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void BlobData::setContentType(const String& contentType) { 95 void BlobData::setContentType(const String& contentType) {
96 if (isValidBlobType(contentType)) 96 if (isValidBlobType(contentType))
97 m_contentType = contentType; 97 m_contentType = contentType;
98 else 98 else
99 m_contentType = ""; 99 m_contentType = "";
100 } 100 }
101 101
102 void BlobData::appendData(PassRefPtr<RawData> data, 102 void BlobData::appendData(PassRefPtr<RawData> data,
103 long long offset, 103 long long offset,
104 long long length) { 104 long long length) {
105 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 105 // Blobs with a unknown-size file cannot have other items.
106 << "Blobs with a unknown-size file cannot have other items."; 106 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES);
107 m_items.append(BlobDataItem(std::move(data), offset, length)); 107 m_items.append(BlobDataItem(std::move(data), offset, length));
108 } 108 }
109 109
110 void BlobData::appendFile(const String& path, 110 void BlobData::appendFile(const String& path,
111 long long offset, 111 long long offset,
112 long long length, 112 long long length,
113 double expectedModificationTime) { 113 double expectedModificationTime) {
114 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 114 // Blobs with a unknown-size file cannot have other items.
115 << "Blobs with a unknown-size file cannot have other items."; 115 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES);
116 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime)); 116 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime));
117 } 117 }
118 118
119 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> dataHandle, 119 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> dataHandle,
120 long long offset, 120 long long offset,
121 long long length) { 121 long long length) {
122 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 122 // Blobs with a unknown-size file cannot have other items.
123 << "Blobs with a unknown-size file cannot have other items."; 123 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES);
124 m_items.append(BlobDataItem(std::move(dataHandle), offset, length)); 124 m_items.append(BlobDataItem(std::move(dataHandle), offset, length));
125 } 125 }
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 // Blobs with a unknown-size file cannot have other items.
132 << "Blobs with a unknown-size file cannot have other items."; 132 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES);
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) { 137 bool doNormalizeLineEndingsToNative) {
138 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 138 // Blobs with a unknown-size file cannot have other items.
139 << "Blobs with a unknown-size file cannot have other items."; 139 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES);
140 CString utf8Text = UTF8Encoding().encode(text, WTF::EntitiesForUnencodables); 140 CString utf8Text = UTF8Encoding().encode(text, WTF::EntitiesForUnencodables);
141 RefPtr<RawData> data = nullptr; 141 RefPtr<RawData> data = nullptr;
142 Vector<char>* buffer; 142 Vector<char>* buffer;
143 if (canConsolidateData(text.length())) { 143 if (canConsolidateData(text.length())) {
144 buffer = m_items.back().data->mutableData(); 144 buffer = m_items.back().data->mutableData();
145 } else { 145 } else {
146 data = RawData::create(); 146 data = RawData::create();
147 buffer = data->mutableData(); 147 buffer = data->mutableData();
148 } 148 }
149 149
150 if (doNormalizeLineEndingsToNative) { 150 if (doNormalizeLineEndingsToNative) {
151 normalizeLineEndingsToNative(utf8Text, *buffer); 151 normalizeLineEndingsToNative(utf8Text, *buffer);
152 } else { 152 } else {
153 buffer->append(utf8Text.data(), utf8Text.length()); 153 buffer->append(utf8Text.data(), utf8Text.length());
154 } 154 }
155 155
156 if (data) 156 if (data)
157 m_items.append(BlobDataItem(data.release())); 157 m_items.append(BlobDataItem(data.release()));
158 } 158 }
159 159
160 void BlobData::appendBytes(const void* bytes, size_t length) { 160 void BlobData::appendBytes(const void* bytes, size_t length) {
161 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 161 // Blobs with a unknown-size file cannot have other items.
162 << "Blobs with a unknown-size file cannot have other items."; 162 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES);
163 if (canConsolidateData(length)) { 163 if (canConsolidateData(length)) {
164 m_items.back().data->mutableData()->append(static_cast<const char*>(bytes), 164 m_items.back().data->mutableData()->append(static_cast<const char*>(bytes),
165 length); 165 length);
166 return; 166 return;
167 } 167 }
168 RefPtr<RawData> data = RawData::create(); 168 RefPtr<RawData> data = RawData::create();
169 Vector<char>* buffer = data->mutableData(); 169 Vector<char>* buffer = data->mutableData();
170 buffer->append(static_cast<const char*>(bytes), length); 170 buffer->append(static_cast<const char*>(bytes), length);
171 m_items.append(BlobDataItem(data.release())); 171 m_items.append(BlobDataItem(data.release()));
172 } 172 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""), 226 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""),
227 m_size(size) { 227 m_size(size) {
228 BlobRegistry::addBlobDataRef(m_uuid); 228 BlobRegistry::addBlobDataRef(m_uuid);
229 } 229 }
230 230
231 BlobDataHandle::~BlobDataHandle() { 231 BlobDataHandle::~BlobDataHandle() {
232 BlobRegistry::removeBlobDataRef(m_uuid); 232 BlobRegistry::removeBlobDataRef(m_uuid);
233 } 233 }
234 234
235 } // namespace blink 235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698