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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste
mURL, const FileMetadata& metadata) | 79 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste
mURL, const FileMetadata& metadata) |
80 { | 80 { |
81 OwnPtr<BlobData> blobData = BlobData::create(); | 81 OwnPtr<BlobData> blobData = BlobData::create(); |
82 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi
le::WellKnownContentTypes)); | 82 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi
le::WellKnownContentTypes)); |
83 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo
dificationTime); | 83 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo
dificationTime); |
84 return blobData.release(); | 84 return blobData.release(); |
85 } | 85 } |
86 | 86 |
87 PassRefPtr<File> File::createWithRelativePath(const String& path, const String&
relativePath) | 87 PassRefPtrWillBeRawPtr<File> File::createWithRelativePath(const String& path, co
nst String& relativePath) |
88 { | 88 { |
89 RefPtr<File> file = adoptRef(new File(path, AllContentTypes)); | 89 RefPtrWillBeRawPtr<File> file = adoptRefWillBeNoop(new File(path, AllContent
Types)); |
90 file->m_relativePath = relativePath; | 90 file->m_relativePath = relativePath; |
91 return file.release(); | 91 return file.release(); |
92 } | 92 } |
93 | 93 |
94 File::File(const String& path, ContentTypeLookupPolicy policy) | 94 File::File(const String& path, ContentTypeLookupPolicy policy) |
95 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) | 95 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) |
96 , m_hasBackingFile(true) | 96 , m_hasBackingFile(true) |
97 , m_path(path) | 97 , m_path(path) |
98 , m_name(blink::Platform::current()->fileUtilities()->baseName(path)) | 98 , m_name(blink::Platform::current()->fileUtilities()->baseName(path)) |
99 , m_snapshotSize(-1) | 99 , m_snapshotSize(-1) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return m_snapshotSize; | 174 return m_snapshotSize; |
175 | 175 |
176 // FIXME: JavaScript cannot represent sizes as large as unsigned long long,
we need to | 176 // FIXME: JavaScript cannot represent sizes as large as unsigned long long,
we need to |
177 // come up with an exception to throw if file size is not representable. | 177 // come up with an exception to throw if file size is not representable. |
178 long long size; | 178 long long size; |
179 if (!hasBackingFile() || !getFileSize(m_path, size)) | 179 if (!hasBackingFile() || !getFileSize(m_path, size)) |
180 return 0; | 180 return 0; |
181 return static_cast<unsigned long long>(size); | 181 return static_cast<unsigned long long>(size); |
182 } | 182 } |
183 | 183 |
184 PassRefPtr<Blob> File::slice(long long start, long long end, const String& conte
ntType) const | 184 PassRefPtrWillBeRawPtr<Blob> File::slice(long long start, long long end, const S
tring& contentType) const |
185 { | 185 { |
186 if (!m_hasBackingFile) | 186 if (!m_hasBackingFile) |
187 return Blob::slice(start, end, contentType); | 187 return Blob::slice(start, end, contentType); |
188 | 188 |
189 // FIXME: This involves synchronous file operation. We need to figure out ho
w to make it asynchronous. | 189 // FIXME: This involves synchronous file operation. We need to figure out ho
w to make it asynchronous. |
190 long long size; | 190 long long size; |
191 double modificationTime; | 191 double modificationTime; |
192 captureSnapshot(size, modificationTime); | 192 captureSnapshot(size, modificationTime); |
193 clampSliceOffsets(size, start, end); | 193 clampSliceOffsets(size, start, end); |
194 | 194 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 captureSnapshot(size, modificationTime); | 253 captureSnapshot(size, modificationTime); |
254 if (!m_fileSystemURL.isEmpty()) { | 254 if (!m_fileSystemURL.isEmpty()) { |
255 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; | 255 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; |
256 return; | 256 return; |
257 } | 257 } |
258 ASSERT(!m_path.isEmpty()); | 258 ASSERT(!m_path.isEmpty()); |
259 blobData.appendFile(m_path, 0, size, modificationTime); | 259 blobData.appendFile(m_path, 0, size, modificationTime); |
260 } | 260 } |
261 | 261 |
262 } // namespace WebCore | 262 } // namespace WebCore |
OLD | NEW |