Index: Source/bindings/v8/custom/V8BlobCustomHelpers.cpp |
diff --git a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp |
index ee359371b85b659787f80360eee7cc35104bd2fd..6bb8c61dfec582c375a10a5ba50daf8ad6c0ff8e 100644 |
--- a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp |
+++ b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp |
@@ -38,12 +38,44 @@ |
#include "bindings/v8/custom/V8ArrayBufferCustom.h" |
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" |
#include "core/fileapi/BlobBuilder.h" |
+#include "wtf/DateMath.h" |
namespace WebCore { |
namespace V8BlobCustomHelpers { |
-bool processBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobClassName, String& contentType, String& endings, v8::Isolate* isolate) |
+ParsedProperties::ParsedProperties(bool hasFileProperties) |
+ : endings("transparent") |
+ , hasFileProperties(hasFileProperties) |
+#ifndef NDEBUG |
+ , m_hasLastModifiedDate(false) |
+#endif // NDEBUG |
+{ |
+} |
+ |
+double ParsedProperties::lastModifiedDate() |
+{ |
+ ASSERT(this->hasFileProperties); |
+ ASSERT(this->m_hasLastModifiedDate); |
+ return m_lastModifiedDate; |
+} |
+ |
+void ParsedProperties::setLastModifiedDate(double lastModifiedDate) |
+{ |
+ ASSERT(this->hasFileProperties); |
+ ASSERT(!this->m_hasLastModifiedDate); |
+ m_lastModifiedDate = lastModifiedDate; |
+#ifndef NDEBUG |
+ m_hasLastModifiedDate = true; |
+#endif // NDEBUG |
+} |
+ |
+void ParsedProperties::setDefaultLastModifiedDate() |
+{ |
+ setLastModifiedDate(currentTime()); |
+} |
+ |
+bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobClassName, v8::Isolate* isolate) |
{ |
ASSERT(endings == "transparent"); |
@@ -65,6 +97,23 @@ bool processBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobCl |
} |
contentType = contentType.lower(); |
} |
+ |
+ if (!hasFileProperties) |
+ return true; |
+ |
+ v8::Local<v8::Value> lastModifiedDate; |
+ V8TRYCATCH_RETURN(bool, containsLastModifiedDate, dictionary.get("lastModifiedDate", lastModifiedDate), false); |
+ if (containsLastModifiedDate) { |
+ if (!lastModifiedDate->IsDate()) { |
+ throwTypeError(ExceptionMessages::failedToConstruct(blobClassName, "The \"lastModifiedDate\" property must be a Date instance."), isolate); |
+ return false; |
+ } |
+ double dateValue = toWebCoreDate(lastModifiedDate); |
+ setLastModifiedDate(dateValue / msPerSecond); |
+ } else { |
+ setDefaultLastModifiedDate(); |
+ } |
+ |
return true; |
} |