Implement latest File object spec (including its constructor).
https://bugs.webkit.org/show_bug.cgi?id=156511

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/files/file-constructor.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:

* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue):
* bindings/js/JSDictionary.h:

* bindings/js/JSFileCustom.cpp: Added.
(WebCore::constructJSFile):

* fileapi/File.cpp:
(WebCore::File::File):
(WebCore::File::lastModified):
(WebCore::File::lastModifiedDate): Deleted.
* fileapi/File.h:
* fileapi/File.idl:

LayoutTests:

* fast/files/file-constructor-expected.txt: Added.
* fast/files/file-constructor.html: Added.

* http/tests/local/fileapi/file-last-modified-after-delete-expected.txt:
* http/tests/local/fileapi/script-tests/file-last-modified-after-delete.js:

* http/tests/local/fileapi/file-last-modified-expected.txt:
* http/tests/local/fileapi/script-tests/file-last-modified.js:

* imported/blink/storage/indexeddb/blob-basics-metadata-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200032 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/fileapi/File.h b/Source/WebCore/fileapi/File.h
index 268fc7d..c1735d0 100644
--- a/Source/WebCore/fileapi/File.h
+++ b/Source/WebCore/fileapi/File.h
@@ -27,6 +27,7 @@
 #define File_h
 
 #include "Blob.h"
+#include <wtf/Optional.h>
 #include <wtf/Ref.h>
 #include <wtf/TypeCasts.h>
 #include <wtf/text/WTFString.h>
@@ -42,6 +43,12 @@
         return adoptRef(*new File(path));
     }
 
+    // Create a File using the 'new File' constructor.
+    static Ref<File> create(Vector<BlobPart> blobParts, const String& filename, const String& contentType, int64_t lastModified)
+    {
+        return adoptRef(*new File(WTFMove(blobParts), filename, contentType, lastModified));
+    }
+
     static Ref<File> deserialize(const String& path, const URL& srcURL, const String& type, const String& name)
     {
         return adoptRef(*new File(deserializationContructor, path, srcURL, type, name));
@@ -59,9 +66,7 @@
 
     const String& path() const { return m_path; }
     const String& name() const { return m_name; }
-
-    // This returns the current date and time if the file's last modification date is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate).
-    double lastModifiedDate() const;
+    double lastModified() const;
 
     static String contentTypeForFile(const String& path);
 
@@ -72,6 +77,7 @@
 private:
     WEBCORE_EXPORT explicit File(const String& path);
     File(const String& path, const String& nameOverride);
+    File(Vector<BlobPart>&& blobParts, const String& filename, const String& contentType, int64_t lastModified);
 
     File(DeserializationContructor, const String& path, const URL& srcURL, const String& type, const String& name);
 
@@ -82,6 +88,9 @@
 
     String m_path;
     String m_name;
+
+    Optional<String> m_overrideFilename;
+    Optional<int64_t> m_overrideLastModifiedDate;
 };
 
 } // namespace WebCore