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

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

Issue 2717583003: [BlobStorage] Enforcing renderer constraints to prevent broken blobs (Closed)
Patch Set: moving to dchecks Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/platform/blob/BlobData.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 long long length) { 104 long long length) {
105 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 105 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES)
106 << "Blobs with a unknown-size file cannot have other items."; 106 << "Blobs with a unknown-size file cannot have other items.";
107 m_items.push_back(BlobDataItem(std::move(data), offset, length)); 107 m_items.push_back(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 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES)
pwnall 2017/02/28 23:37:03 This CHECK should also be a DCHECK, but it's not i
115 << "Blobs with a unknown-size file cannot have other items."; 115 << "Blobs with a unknown-size file cannot have other items.";
116 DCHECK_NE(length, BlobDataItem::toEndOfFile)
117 << "It is illegal to append file items that have an unknown size. To "
118 "create a blob with a single file with unknown size, use "
119 "BlobData::createForFileWithUnknownSize. Otherwise please provide the "
120 "file size.";
116 m_items.push_back( 121 m_items.push_back(
117 BlobDataItem(path, offset, length, expectedModificationTime)); 122 BlobDataItem(path, offset, length, expectedModificationTime));
118 } 123 }
119 124
120 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> dataHandle, 125 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> dataHandle,
121 long long offset, 126 long long offset,
122 long long length) { 127 long long length) {
123 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 128 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES)
pwnall 2017/02/28 23:37:03 This CHECK should also be a DCHECK, same comment a
124 << "Blobs with a unknown-size file cannot have other items."; 129 << "Blobs with a unknown-size file cannot have other items.";
130 DCHECK(!dataHandle->isSingleUnknownSizeFile())
131 << "It is illegal to append an unknown size file blob.";
125 m_items.push_back(BlobDataItem(std::move(dataHandle), offset, length)); 132 m_items.push_back(BlobDataItem(std::move(dataHandle), offset, length));
126 } 133 }
127 134
128 void BlobData::appendFileSystemURL(const KURL& url, 135 void BlobData::appendFileSystemURL(const KURL& url,
129 long long offset, 136 long long offset,
130 long long length, 137 long long length,
131 double expectedModificationTime) { 138 double expectedModificationTime) {
132 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) 139 CHECK_EQ(m_fileComposition, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES)
133 << "Blobs with a unknown-size file cannot have other items."; 140 << "Blobs with a unknown-size file cannot have other items.";
134 m_items.push_back( 141 m_items.push_back(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return false; 210 return false;
204 BlobDataItem& lastItem = m_items.back(); 211 BlobDataItem& lastItem = m_items.back();
205 if (lastItem.type != BlobDataItem::Data) 212 if (lastItem.type != BlobDataItem::Data)
206 return false; 213 return false;
207 if (lastItem.data->length() + length > kMaxConsolidatedItemSizeInBytes) 214 if (lastItem.data->length() + length > kMaxConsolidatedItemSizeInBytes)
208 return false; 215 return false;
209 return true; 216 return true;
210 } 217 }
211 218
212 BlobDataHandle::BlobDataHandle() 219 BlobDataHandle::BlobDataHandle()
213 : m_uuid(createCanonicalUUIDString()), m_size(0) { 220 : m_uuid(createCanonicalUUIDString()),
221 m_size(0),
222 m_isSingleUnknownSizeFile(false) {
214 BlobRegistry::registerBlobData(m_uuid, BlobData::create()); 223 BlobRegistry::registerBlobData(m_uuid, BlobData::create());
215 } 224 }
216 225
217 BlobDataHandle::BlobDataHandle(std::unique_ptr<BlobData> data, long long size) 226 BlobDataHandle::BlobDataHandle(std::unique_ptr<BlobData> data, long long size)
218 : m_uuid(createCanonicalUUIDString()), 227 : m_uuid(createCanonicalUUIDString()),
219 m_type(data->contentType().isolatedCopy()), 228 m_type(data->contentType().isolatedCopy()),
220 m_size(size) { 229 m_size(size),
230 m_isSingleUnknownSizeFile(data->isSingleUnknownSizeFile()) {
221 BlobRegistry::registerBlobData(m_uuid, std::move(data)); 231 BlobRegistry::registerBlobData(m_uuid, std::move(data));
222 } 232 }
223 233
224 BlobDataHandle::BlobDataHandle(const String& uuid, 234 BlobDataHandle::BlobDataHandle(const String& uuid,
225 const String& type, 235 const String& type,
226 long long size) 236 long long size)
227 : m_uuid(uuid.isolatedCopy()), 237 : m_uuid(uuid.isolatedCopy()),
228 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""), 238 m_type(isValidBlobType(type) ? type.isolatedCopy() : ""),
229 m_size(size) { 239 m_size(size),
240 m_isSingleUnknownSizeFile(false) {
230 BlobRegistry::addBlobDataRef(m_uuid); 241 BlobRegistry::addBlobDataRef(m_uuid);
231 } 242 }
232 243
233 BlobDataHandle::~BlobDataHandle() { 244 BlobDataHandle::~BlobDataHandle() {
234 BlobRegistry::removeBlobDataRef(m_uuid); 245 BlobRegistry::removeBlobDataRef(m_uuid);
235 } 246 }
236 247
237 } // namespace blink 248 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/blob/BlobData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698