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

Unified Diff: Source/bindings/v8/custom/V8BlobCustomHelpers.cpp

Issue 74213009: File constructor understands lastModified. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed unnecessary branches for NaN. Created 7 years, 1 month 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
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..0e5a4bb648e11ae61fe0f3095d26ec0f99fdccbb 100644
--- a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
+++ b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
@@ -38,14 +38,47 @@
#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
{
- ASSERT(endings == "transparent");
+}
+
+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 processBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobClassName, ParsedProperties& parsedProperties, v8::Isolate* isolate)
+{
+ ASSERT(parsedProperties.endings == "transparent");
+ String& endings = parsedProperties.endings;
V8TRYCATCH_RETURN(Dictionary, dictionary, Dictionary(propertyBag, isolate), false);
@@ -57,6 +90,7 @@ bool processBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobCl
}
}
+ String& contentType = parsedProperties.contentType;
V8TRYCATCH_RETURN(bool, containsType, dictionary.get("type", contentType), false);
if (containsType) {
if (!contentType.containsOnlyASCII()) {
@@ -65,6 +99,23 @@ bool processBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobCl
}
contentType = contentType.lower();
}
+
+ if (!parsedProperties.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 = static_cast<double>(v8::Local<v8::Date>::Cast(lastModifiedDate)->ValueOf());
haraken 2013/11/18 10:27:48 You can use toWebCoreDate() in V8Binding.h.
pwnall-personal 2013/11/18 11:23:45 I avoided toWebCoreDate() because it does an unnec
haraken 2013/11/18 11:29:07 We want to use utility methods in V8Binding.h as m
pwnall-personal 2013/11/18 12:48:57 Done.
+ parsedProperties.setLastModifiedDate(dateValue / msPerSecond);
+ } else {
+ parsedProperties.setDefaultLastModifiedDate();
+ }
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698