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

Side by Side Diff: third_party/WebKit/Source/core/fileapi/File.cpp

Issue 2717583003: [BlobStorage] Enforcing renderer constraints to prevent broken blobs (Closed)
Patch Set: added test Created 3 years, 8 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 | « no previous file | third_party/WebKit/Source/core/fileapi/FileTest.cpp » ('j') | 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const String& path, 78 const String& path,
79 const String& fileSystemName, 79 const String& fileSystemName,
80 File::ContentTypeLookupPolicy policy) { 80 File::ContentTypeLookupPolicy policy) {
81 return createBlobDataForFileWithType( 81 return createBlobDataForFileWithType(
82 path, getContentTypeFromFileName(fileSystemName, policy)); 82 path, getContentTypeFromFileName(fileSystemName, policy));
83 } 83 }
84 84
85 static std::unique_ptr<BlobData> createBlobDataForFileWithMetadata( 85 static std::unique_ptr<BlobData> createBlobDataForFileWithMetadata(
86 const String& fileSystemName, 86 const String& fileSystemName,
87 const FileMetadata& metadata) { 87 const FileMetadata& metadata) {
88 std::unique_ptr<BlobData> blobData = BlobData::create(); 88 std::unique_ptr<BlobData> blobData;
89 if (metadata.length == BlobDataItem::toEndOfFile) {
90 blobData = BlobData::createForFileWithUnknownSize(
91 metadata.platformPath, metadata.modificationTime / msPerSecond);
92 } else {
93 blobData = BlobData::create();
94 blobData->appendFile(metadata.platformPath, 0, metadata.length,
95 metadata.modificationTime / msPerSecond);
96 }
89 blobData->setContentType( 97 blobData->setContentType(
90 getContentTypeFromFileName(fileSystemName, File::WellKnownContentTypes)); 98 getContentTypeFromFileName(fileSystemName, File::WellKnownContentTypes));
91 blobData->appendFile(metadata.platformPath, 0, metadata.length,
92 metadata.modificationTime / msPerSecond);
93 return blobData; 99 return blobData;
94 } 100 }
95 101
96 static std::unique_ptr<BlobData> createBlobDataForFileSystemURL( 102 static std::unique_ptr<BlobData> createBlobDataForFileSystemURL(
97 const KURL& fileSystemURL, 103 const KURL& fileSystemURL,
98 const FileMetadata& metadata) { 104 const FileMetadata& metadata) {
99 std::unique_ptr<BlobData> blobData = BlobData::create(); 105 std::unique_ptr<BlobData> blobData;
106 if (metadata.length == BlobDataItem::toEndOfFile) {
107 blobData = BlobData::createForFileSystemURLWithUnknownSize(
108 fileSystemURL, metadata.modificationTime / msPerSecond);
109 } else {
110 blobData = BlobData::create();
111 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length,
112 metadata.modificationTime / msPerSecond);
113 }
100 blobData->setContentType(getContentTypeFromFileName( 114 blobData->setContentType(getContentTypeFromFileName(
101 fileSystemURL.path(), File::WellKnownContentTypes)); 115 fileSystemURL.path(), File::WellKnownContentTypes));
102 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length,
103 metadata.modificationTime / msPerSecond);
104 return blobData; 116 return blobData;
105 } 117 }
106 118
107 // static 119 // static
108 File* File::create( 120 File* File::create(
109 ExecutionContext* context, 121 ExecutionContext* context,
110 const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& fileBits, 122 const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& fileBits,
111 const String& fileName, 123 const String& fileName,
112 const FilePropertyBag& options, 124 const FilePropertyBag& options,
113 ExceptionState& exceptionState) { 125 ExceptionState& exceptionState) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) 405 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty())
394 return false; 406 return false;
395 407
396 if (!m_fileSystemURL.isEmpty()) 408 if (!m_fileSystemURL.isEmpty())
397 return m_fileSystemURL == other.m_fileSystemURL; 409 return m_fileSystemURL == other.m_fileSystemURL;
398 410
399 return uuid() == other.uuid(); 411 return uuid() == other.uuid();
400 } 412 }
401 413
402 } // namespace blink 414 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fileapi/FileTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698