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

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: fixed File.cpp usage 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 | « no previous file | third_party/WebKit/Source/platform/blob/BlobData.h » ('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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const String& path, 77 const String& path,
78 const String& fileSystemName, 78 const String& fileSystemName,
79 File::ContentTypeLookupPolicy policy) { 79 File::ContentTypeLookupPolicy policy) {
80 return createBlobDataForFileWithType( 80 return createBlobDataForFileWithType(
81 path, getContentTypeFromFileName(fileSystemName, policy)); 81 path, getContentTypeFromFileName(fileSystemName, policy));
82 } 82 }
83 83
84 static std::unique_ptr<BlobData> createBlobDataForFileWithMetadata( 84 static std::unique_ptr<BlobData> createBlobDataForFileWithMetadata(
85 const String& fileSystemName, 85 const String& fileSystemName,
86 const FileMetadata& metadata) { 86 const FileMetadata& metadata) {
87 std::unique_ptr<BlobData> blobData = BlobData::create(); 87 std::unique_ptr<BlobData> blobData;
88 if (metadata.length == BlobDataItem::toEndOfFile) {
pwnall 2017/03/06 21:13:45 Tests?
dmurph 2017/03/06 23:43:29 Tested by one or more of: FileTest.fileSystemFileW
pwnall 2017/03/06 23:45:12 Do we know for sure that we have coverage of both
dmurph 2017/03/29 23:19:24 Checked. Added one test for case where we have the
89 blobData = BlobData::createForFileWithUnknownSize(
90 metadata.platformPath, metadata.modificationTime / msPerSecond);
91 } else {
92 blobData = BlobData::create();
93 blobData->appendFile(metadata.platformPath, 0, metadata.length,
94 metadata.modificationTime / msPerSecond);
95 }
88 blobData->setContentType( 96 blobData->setContentType(
89 getContentTypeFromFileName(fileSystemName, File::WellKnownContentTypes)); 97 getContentTypeFromFileName(fileSystemName, File::WellKnownContentTypes));
90 blobData->appendFile(metadata.platformPath, 0, metadata.length,
91 metadata.modificationTime / msPerSecond);
92 return blobData; 98 return blobData;
93 } 99 }
94 100
95 static std::unique_ptr<BlobData> createBlobDataForFileSystemURL( 101 static std::unique_ptr<BlobData> createBlobDataForFileSystemURL(
96 const KURL& fileSystemURL, 102 const KURL& fileSystemURL,
97 const FileMetadata& metadata) { 103 const FileMetadata& metadata) {
98 std::unique_ptr<BlobData> blobData = BlobData::create(); 104 std::unique_ptr<BlobData> blobData;
105 if (metadata.length == BlobDataItem::toEndOfFile) {
106 blobData = BlobData::createForFileSystemURLWithUnknownSize(
107 fileSystemURL, metadata.modificationTime / msPerSecond);
108 } else {
109 blobData = BlobData::create();
110 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length,
111 metadata.modificationTime / msPerSecond);
112 }
99 blobData->setContentType(getContentTypeFromFileName( 113 blobData->setContentType(getContentTypeFromFileName(
100 fileSystemURL.path(), File::WellKnownContentTypes)); 114 fileSystemURL.path(), File::WellKnownContentTypes));
101 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length,
102 metadata.modificationTime / msPerSecond);
103 return blobData; 115 return blobData;
104 } 116 }
105 117
106 // static 118 // static
107 File* File::create( 119 File* File::create(
108 ExecutionContext* context, 120 ExecutionContext* context,
109 const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& fileBits, 121 const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& fileBits,
110 const String& fileName, 122 const String& fileName,
111 const FilePropertyBag& options, 123 const FilePropertyBag& options,
112 ExceptionState& exceptionState) { 124 ExceptionState& exceptionState) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) 410 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty())
399 return false; 411 return false;
400 412
401 if (!m_fileSystemURL.isEmpty()) 413 if (!m_fileSystemURL.isEmpty())
402 return m_fileSystemURL == other.m_fileSystemURL; 414 return m_fileSystemURL == other.m_fileSystemURL;
403 415
404 return uuid() == other.uuid(); 416 return uuid() == other.uuid();
405 } 417 }
406 418
407 } // namespace blink 419 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/blob/BlobData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698