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

Unified Diff: Source/WebCore/fileapi/File.cpp

Issue 7356002: Merge 90308 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/WebCore/platform/MIMETypeRegistry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/fileapi/File.cpp
===================================================================
--- Source/WebCore/fileapi/File.cpp (revision 90866)
+++ Source/WebCore/fileapi/File.cpp (working copy)
@@ -33,20 +33,34 @@
namespace WebCore {
-static PassOwnPtr<BlobData> createBlobDataForFile(const String& path, const String& name = String())
+static PassOwnPtr<BlobData> createBlobDataForFileWithType(const String& path, const String& contentType)
{
- String type;
- const String& nameForMIMEType = !name.isEmpty() ? name : path;
- int index = nameForMIMEType.reverseFind('.');
- if (index != -1)
- type = MIMETypeRegistry::getMIMETypeForExtension(nameForMIMEType.substring(index + 1));
-
OwnPtr<BlobData> blobData = BlobData::create();
- blobData->setContentType(type);
+ blobData->setContentType(contentType);
blobData->appendFile(path);
return blobData.release();
}
+static PassOwnPtr<BlobData> createBlobDataForFile(const String& path)
+{
+ String type;
+ int index = path.reverseFind('.');
+ if (index != -1)
+ type = MIMETypeRegistry::getMIMETypeForExtension(path.substring(index + 1));
+ return createBlobDataForFileWithType(path, type);
+}
+
+#if ENABLE(FILE_SYSTEM)
+static PassOwnPtr<BlobData> createBlobDataForFileSystemFile(const String& path, const String& fileSystemName)
+{
+ String type;
+ int index = fileSystemName.reverseFind('.');
+ if (index != -1)
+ type = MIMETypeRegistry::getWellKnownMIMETypeForExtension(fileSystemName.substring(index + 1));
+ return createBlobDataForFileWithType(path, type);
+}
+#endif
+
#if ENABLE(DIRECTORY_UPLOAD)
PassRefPtr<File> File::createWithRelativePath(const String& path, const String& relativePath)
{
@@ -68,11 +82,14 @@
, m_path(path)
{
m_name = pathGetFileName(path);
+ // FIXME: File object serialization/deserialization does not include
+ // newer file object data members: m_name and m_relativePath.
+ // See SerializedScriptValue.cpp for js and v8.
}
#if ENABLE(FILE_SYSTEM)
File::File(const String& path, const String& name)
- : Blob(createBlobDataForFile(path, name), -1)
+ : Blob(createBlobDataForFileSystemFile(path, name), -1)
, m_path(path)
, m_name(name)
{
« no previous file with comments | « no previous file | Source/WebCore/platform/MIMETypeRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698