| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/fileapi/File.h" | 26 #include "core/fileapi/File.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
| 29 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/ExceptionCode.h" |
| 30 #include "core/fileapi/FilePropertyBag.h" | 30 #include "core/fileapi/FilePropertyBag.h" |
| 31 #include "core/frame/UseCounter.h" |
| 31 #include "platform/FileMetadata.h" | 32 #include "platform/FileMetadata.h" |
| 32 #include "platform/MIMETypeRegistry.h" | 33 #include "platform/MIMETypeRegistry.h" |
| 33 #include "platform/blob/BlobData.h" | 34 #include "platform/blob/BlobData.h" |
| 34 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
| 35 #include "public/platform/WebFileUtilities.h" | 36 #include "public/platform/WebFileUtilities.h" |
| 36 #include "wtf/CurrentTime.h" | 37 #include "wtf/CurrentTime.h" |
| 37 #include "wtf/DateMath.h" | 38 #include "wtf/DateMath.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste
mURL, const FileMetadata& metadata) | 83 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste
mURL, const FileMetadata& metadata) |
| 83 { | 84 { |
| 84 OwnPtr<BlobData> blobData = BlobData::create(); | 85 OwnPtr<BlobData> blobData = BlobData::create(); |
| 85 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi
le::WellKnownContentTypes)); | 86 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi
le::WellKnownContentTypes)); |
| 86 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo
dificationTime / msPerSecond); | 87 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo
dificationTime / msPerSecond); |
| 87 return blobData.release(); | 88 return blobData.release(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 // static | 91 // static |
| 91 File* File::create(const HeapVector<BlobOrStringOrArrayBufferViewOrArrayBuffer>&
fileBits, const String& fileName, const FilePropertyBag& options, ExceptionStat
e& exceptionState) | 92 File* File::create(ExecutionContext* context, const HeapVector<BlobOrStringOrArr
ayBufferViewOrArrayBuffer>& fileBits, const String& fileName, const FileProperty
Bag& options, ExceptionState& exceptionState) |
| 92 { | 93 { |
| 93 ASSERT(options.hasType()); | 94 ASSERT(options.hasType()); |
| 94 if (!options.type().containsOnlyASCII()) { | 95 if (!options.type().containsOnlyASCII()) { |
| 95 exceptionState.throwDOMException(SyntaxError, "The 'type' property must
consist of ASCII characters."); | 96 exceptionState.throwDOMException(SyntaxError, "The 'type' property must
consist of ASCII characters."); |
| 96 return nullptr; | 97 return nullptr; |
| 97 } | 98 } |
| 98 | 99 |
| 99 double lastModified; | 100 double lastModified; |
| 100 if (options.hasLastModified()) | 101 if (options.hasLastModified()) |
| 101 lastModified = static_cast<double>(options.lastModified()); | 102 lastModified = static_cast<double>(options.lastModified()); |
| 102 else | 103 else |
| 103 lastModified = currentTimeMS(); | 104 lastModified = currentTimeMS(); |
| 104 ASSERT(options.hasEndings()); | 105 ASSERT(options.hasEndings()); |
| 105 bool normalizeLineEndingsToNative = options.endings() == "native"; | 106 bool normalizeLineEndingsToNative = options.endings() == "native"; |
| 107 if (normalizeLineEndingsToNative) |
| 108 UseCounter::count(context, UseCounter::FileAPINativeLineEndings); |
| 106 | 109 |
| 107 OwnPtr<BlobData> blobData = BlobData::create(); | 110 OwnPtr<BlobData> blobData = BlobData::create(); |
| 108 blobData->setContentType(options.type().lower()); | 111 blobData->setContentType(options.type().lower()); |
| 109 populateBlobData(blobData.get(), fileBits, normalizeLineEndingsToNative); | 112 populateBlobData(blobData.get(), fileBits, normalizeLineEndingsToNative); |
| 110 | 113 |
| 111 long long fileSize = blobData->length(); | 114 long long fileSize = blobData->length(); |
| 112 return File::create(fileName, lastModified, BlobDataHandle::create(blobData.
release(), fileSize)); | 115 return File::create(fileName, lastModified, BlobDataHandle::create(blobData.
release(), fileSize)); |
| 113 } | 116 } |
| 114 | 117 |
| 115 File* File::createWithRelativePath(const String& path, const String& relativePat
h) | 118 File* File::createWithRelativePath(const String& path, const String& relativePat
h) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) | 357 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) |
| 355 return false; | 358 return false; |
| 356 | 359 |
| 357 if (!m_fileSystemURL.isEmpty()) | 360 if (!m_fileSystemURL.isEmpty()) |
| 358 return m_fileSystemURL == other.m_fileSystemURL; | 361 return m_fileSystemURL == other.m_fileSystemURL; |
| 359 | 362 |
| 360 return uuid() == other.uuid(); | 363 return uuid() == other.uuid(); |
| 361 } | 364 } |
| 362 | 365 |
| 363 } // namespace blink | 366 } // namespace blink |
| OLD | NEW |