Title: [119821] trunk/Source/WebCore
Revision
119821
Author
[email protected]
Date
2012-06-08 04:50:03 -0700 (Fri, 08 Jun 2012)

Log Message

File::lastModifiedDate should use NaN or separate boolean flag for null Date value
https://bugs.webkit.org/show_bug.cgi?id=87826

Reviewed by Kent Tamura.

Test: http/tests/local/fileapi/file-last-modified-after-delete.html

* fileapi/File.cpp:
(WebCore::File::File):
(WebCore::File::captureSnapshot):
(WebCore::File::lastModifiedDate):
(WebCore::File::lastModifiedDateForBinding): Removed.
* fileapi/File.h:
(File):
* fileapi/File.idl:
* platform/FileMetadata.h:
(WebCore::FileMetadata::FileMetadata):
* platform/FileSystem.h:
* platform/chromium/support/WebHTTPBody.cpp:
(WebKit::WebHTTPBody::elementAt):
* platform/network/BlobData.h:
(WebCore::BlobDataItem::doNotCheckFileChange): Removed.
* platform/network/BlobData.cpp:
* platform/network/cf/FormDataStreamCFNet.cpp:
(WebCore::advanceCurrentStream):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::blobIsOutOfDate):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (119820 => 119821)


--- trunk/Source/WebCore/ChangeLog	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/ChangeLog	2012-06-08 11:50:03 UTC (rev 119821)
@@ -1,3 +1,33 @@
+2012-06-07  Kinuko Yasuda  <[email protected]>
+
+        File::lastModifiedDate should use NaN or separate boolean flag for null Date value
+        https://bugs.webkit.org/show_bug.cgi?id=87826
+
+        Reviewed by Kent Tamura.
+
+        Test: http/tests/local/fileapi/file-last-modified-after-delete.html
+
+        * fileapi/File.cpp:
+        (WebCore::File::File):
+        (WebCore::File::captureSnapshot):
+        (WebCore::File::lastModifiedDate):
+        (WebCore::File::lastModifiedDateForBinding): Removed.
+        * fileapi/File.h:
+        (File):
+        * fileapi/File.idl:
+        * platform/FileMetadata.h:
+        (WebCore::FileMetadata::FileMetadata):
+        * platform/FileSystem.h:
+        * platform/chromium/support/WebHTTPBody.cpp:
+        (WebKit::WebHTTPBody::elementAt):
+        * platform/network/BlobData.h:
+        (WebCore::BlobDataItem::doNotCheckFileChange): Removed.
+        * platform/network/BlobData.cpp:
+        * platform/network/cf/FormDataStreamCFNet.cpp:
+        (WebCore::advanceCurrentStream):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::blobIsOutOfDate):
+
 2012-06-08  Kent Tamura  <[email protected]>
 
         Move form-related functions of Document to FormController

Modified: trunk/Source/WebCore/fileapi/File.cpp (119820 => 119821)


--- trunk/Source/WebCore/fileapi/File.cpp	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/fileapi/File.cpp	2012-06-08 11:50:03 UTC (rev 119821)
@@ -86,7 +86,7 @@
     , m_name(pathGetFileName(path))
 #if ENABLE(FILE_SYSTEM)
     , m_snapshotSize(-1)
-    , m_snapshotModificationTime(0)
+    , m_snapshotModificationTime(invalidFileTime())
 #endif
 {
 }
@@ -96,7 +96,7 @@
     , m_path(path)
 #if ENABLE(FILE_SYSTEM)
     , m_snapshotSize(-1)
-    , m_snapshotModificationTime(0)
+    , m_snapshotModificationTime(invalidFileTime())
 #endif
 {
     m_name = pathGetFileName(path);
@@ -111,7 +111,7 @@
     , m_name(name)
 #if ENABLE(FILE_SYSTEM)
     , m_snapshotSize(-1)
-    , m_snapshotModificationTime(0)
+    , m_snapshotModificationTime(invalidFileTime())
 #endif
 {
 }
@@ -136,18 +136,12 @@
 
     time_t modificationTime;
     if (!getFileModificationTime(m_path, modificationTime))
-        return 0;
+        return invalidFileTime();
 
     // Needs to return epoch time in milliseconds for Date.
     return modificationTime * 1000.0;
 }
 
-double File::lastModifiedDateForBinding() const
-{
-    double value = lastModifiedDate();
-    return (!value) ? std::numeric_limits<double>::quiet_NaN() : value;
-}
-
 unsigned long long File::size() const
 {
 #if ENABLE(FILE_SYSTEM)
@@ -178,7 +172,7 @@
     FileMetadata metadata;
     if (!getFileMetadata(m_path, metadata)) {
         snapshotSize = 0;
-        snapshotModificationTime = 0;
+        snapshotModificationTime = invalidFileTime();
         return;
     }
 

Modified: trunk/Source/WebCore/fileapi/File.h (119820 => 119821)


--- trunk/Source/WebCore/fileapi/File.h	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/fileapi/File.h	2012-06-08 11:50:03 UTC (rev 119821)
@@ -77,12 +77,9 @@
     const String& path() const { return m_path; }
     const String& name() const { return m_name; }
 
-    // This may return zero if getFileModificationTime() platform call has failed or zero snapshot lastModifiedTime is given at construction time.
+    // This may return NaN (which is converted to null Date in _javascript_ layer) if getFileModificationTime() platform call has failed or the information is not available.
     double lastModifiedDate() const;
 
-    // For binding. We want to return null Date if we get the value 0 Date (which is used to indicate the information is unavailable).
-    double lastModifiedDateForBinding() const;
-
 #if ENABLE(DIRECTORY_UPLOAD)
     // Returns the relative path of this file in the context of a directory selection.
     const String& webkitRelativePath() const { return m_relativePath; }

Modified: trunk/Source/WebCore/fileapi/File.idl (119820 => 119821)


--- trunk/Source/WebCore/fileapi/File.idl	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/fileapi/File.idl	2012-06-08 11:50:03 UTC (rev 119821)
@@ -32,7 +32,7 @@
     ] File : Blob {
         readonly attribute DOMString name;
 #if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
-        readonly attribute [ImplementedAs=lastModifiedDateForBinding] Date lastModifiedDate;
+        readonly attribute Date lastModifiedDate;
 #endif
 #if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD
         readonly attribute DOMString webkitRelativePath;

Modified: trunk/Source/WebCore/platform/FileMetadata.h (119820 => 119821)


--- trunk/Source/WebCore/platform/FileMetadata.h	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/FileMetadata.h	2012-06-08 11:50:03 UTC (rev 119821)
@@ -31,6 +31,7 @@
 #ifndef FileMetadata_h
 #define FileMetadata_h
 
+#include "FileSystem.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -56,7 +57,7 @@
     String platformPath;
 #endif
 
-    FileMetadata() : modificationTime(0.0), length(-1), type(TypeUnknown) { }
+    FileMetadata() : modificationTime(invalidFileTime()), length(-1), type(TypeUnknown) { }
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/FileSystem.h (119820 => 119821)


--- trunk/Source/WebCore/platform/FileSystem.h	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/FileSystem.h	2012-06-08 11:50:03 UTC (rev 119821)
@@ -33,6 +33,7 @@
 #include "PlatformString.h"
 #include <time.h>
 #include <wtf/Forward.h>
+#include <wtf/MathExtras.h>
 #include <wtf/Vector.h>
 
 #if USE(CF)
@@ -174,6 +175,9 @@
 
 inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; }
 
+inline double invalidFileTime() { return std::numeric_limits<double>::quiet_NaN(); }
+inline bool isValidFileTime(double time) { return isfinite(time); }
+
 // Prefix is what the filename should be prefixed with, not the full path.
 String openTemporaryFile(const String& prefix, PlatformFileHandle&);
 PlatformFileHandle openFile(const String& path, FileOpenMode);

Modified: trunk/Source/WebCore/platform/chromium/support/WebHTTPBody.cpp (119820 => 119821)


--- trunk/Source/WebCore/platform/chromium/support/WebHTTPBody.cpp	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/chromium/support/WebHTTPBody.cpp	2012-06-08 11:50:03 UTC (rev 119821)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include <public/WebHTTPBody.h>
 
+#include "FileSystem.h"
 #include "FormData.h"
 
 using namespace WebCore;
@@ -77,7 +78,7 @@
     result.filePath.reset();
     result.fileStart = 0;
     result.fileLength = 0;
-    result.modificationTime = 0.0;
+    result.modificationTime = invalidFileTime();
     result.blobURL = KURL();
 
     switch (element.m_type) {

Modified: trunk/Source/WebCore/platform/network/BlobData.cpp (119820 => 119821)


--- trunk/Source/WebCore/platform/network/BlobData.cpp	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/network/BlobData.cpp	2012-06-08 11:50:03 UTC (rev 119821)
@@ -30,6 +30,7 @@
 
 #include "config.h"
 #include "BlobData.h"
+#include "FileSystem.h"
 
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
@@ -40,7 +41,6 @@
 namespace WebCore {
 
 const long long BlobDataItem::toEndOfFile = -1;
-const double BlobDataItem::doNotCheckFileChange = 0;
 
 RawData::RawData()
 {

Modified: trunk/Source/WebCore/platform/network/BlobData.h (119820 => 119821)


--- trunk/Source/WebCore/platform/network/BlobData.h	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/network/BlobData.h	2012-06-08 11:50:03 UTC (rev 119821)
@@ -31,6 +31,7 @@
 #ifndef BlobData_h
 #define BlobData_h
 
+#include "FileSystem.h"
 #include "KURL.h"
 #include "PlatformString.h"
 #include <wtf/Forward.h>
@@ -59,14 +60,13 @@
 
 struct BlobDataItem {
     static const long long toEndOfFile;
-    static const double doNotCheckFileChange;
 
     // Default constructor.
     BlobDataItem()
         : type(Data)
         , offset(0)
         , length(toEndOfFile)
-        , expectedModificationTime(doNotCheckFileChange)
+        , expectedModificationTime(invalidFileTime())
     {
     }
 
@@ -76,7 +76,7 @@
         , data(data)
         , offset(0)
         , length(toEndOfFile)
-        , expectedModificationTime(doNotCheckFileChange)
+        , expectedModificationTime(invalidFileTime())
     {
     }
 
@@ -86,7 +86,7 @@
         , path(path)
         , offset(0)
         , length(toEndOfFile)
-        , expectedModificationTime(doNotCheckFileChange)
+        , expectedModificationTime(invalidFileTime())
     {
     }
 
@@ -99,14 +99,14 @@
         , expectedModificationTime(expectedModificationTime)
     {
     }
-    
+
     // Constructor for Blob type.
     BlobDataItem(const KURL& url, long long offset, long long length)
         : type(Blob)
         , url(url)
         , offset(offset)
         , length(length)
-        , expectedModificationTime(doNotCheckFileChange)
+        , expectedModificationTime(invalidFileTime())
     {
     }
 
@@ -114,7 +114,7 @@
     void detachFromCurrentThread();
 
     enum { Data, File, Blob } type;
-    
+
     // For Data type.
     RefPtr<RawData> data;
 
@@ -137,7 +137,7 @@
         , data(data)
         , offset(offset)
         , length(length)
-        , expectedModificationTime(doNotCheckFileChange)
+        , expectedModificationTime(invalidFileTime())
     {
     }
 };

Modified: trunk/Source/WebCore/platform/network/FormData.cpp (119820 => 119821)


--- trunk/Source/WebCore/platform/network/FormData.cpp	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/network/FormData.cpp	2012-06-08 11:50:03 UTC (rev 119821)
@@ -164,7 +164,7 @@
 void FormData::appendFile(const String& filename, bool shouldGenerateFile)
 {
 #if ENABLE(BLOB)
-    m_elements.append(FormDataElement(filename, 0, BlobDataItem::toEndOfFile, BlobDataItem::doNotCheckFileChange, shouldGenerateFile));
+    m_elements.append(FormDataElement(filename, 0, BlobDataItem::toEndOfFile, invalidFileTime(), shouldGenerateFile));
 #else
     m_elements.append(FormDataElement(filename, shouldGenerateFile));
 #endif

Modified: trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp (119820 => 119821)


--- trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp	2012-06-08 11:50:03 UTC (rev 119821)
@@ -156,7 +156,7 @@
     } else {
 #if ENABLE(BLOB)
         // Check if the file has been changed or not if required.
-        if (nextInput.m_expectedFileModificationTime != BlobDataItem::doNotCheckFileChange) {
+        if (isValidFileTime(nextInput.m_expectedFileModificationTime)) {
             time_t fileModificationTime;
             if (!getFileModificationTime(nextInput.m_filename, fileModificationTime) || fileModificationTime != static_cast<time_t>(nextInput.m_expectedFileModificationTime))
                 return false;

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (119820 => 119821)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2012-06-08 11:44:12 UTC (rev 119820)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2012-06-08 11:50:03 UTC (rev 119821)
@@ -428,7 +428,7 @@
 static bool blobIsOutOfDate(const BlobDataItem& blobItem)
 {
     ASSERT(blobItem.type == BlobDataItem::File);
-    if (blobItem.expectedModificationTime == BlobDataItem::doNotCheckFileChange)
+    if (!isValidFileTime(blobItem.expectedModificationTime))
         return false;
 
     time_t fileModificationTime;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to