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

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: 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
« no previous file with comments | « Source/bindings/v8/custom/V8BlobCustomHelpers.h ('k') | Source/bindings/v8/custom/V8FileCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..19cea842d643fc8050ea922423c7bbd13ae7af32 100644
--- a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
+++ b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
@@ -43,9 +43,34 @@ 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)
+ , m_hasLastModifiedDate(false)
{
- ASSERT(endings == "transparent");
+}
+
+double ParsedProperties::lastModifiedDate()
+{
+ ASSERT(this->hasFileProperties);
+ if (!m_hasLastModifiedDate) {
+ m_lastModifiedDate = currentTime();
+ m_hasLastModifiedDate = true;
+ }
+ return m_lastModifiedDate;
+}
+
+void ParsedProperties::setLastModifiedDate(double lastModifiedDate)
+{
+ ASSERT(this->hasFileProperties);
+ m_lastModifiedDate = lastModifiedDate;
+ m_hasLastModifiedDate = true;
+}
+
+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 +82,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 +91,20 @@ 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() && !lastModifiedDate->IsNumber()) {
sof 2013/11/17 07:42:37 From spec standpoint, Number appears an extension;
pwnall-personal 2013/11/17 09:01:23 I was confused by step 3 sub-step 3 in the File co
sof 2013/11/17 12:53:40 By the time you come to those steps, value convers
pwnall-personal 2013/11/17 16:02:08 Thank you for explaining! I removed the support fo
+ throwError(v8SyntaxError, ExceptionMessages::failedToConstruct(blobClassName, "The \"lastModifiedDate\" property must be a Date instance."), isolate);
sof 2013/11/17 12:53:40 If the value conversion fails, a TypeError should
pwnall-personal 2013/11/17 16:02:08 Done. Thank you for catching this!
+ return false;
+ }
+ parsedProperties.setLastModifiedDate(static_cast<double>(lastModifiedDate->NumberValue()) / 1000.0); // ms to seconds
+ }
sof 2013/11/17 07:42:37 If you call setLastModifiedDate(currentTime()) her
pwnall-personal 2013/11/17 09:01:23 Sadly, that is not the case. This method is only c
sof 2013/11/17 12:53:40 Hmm, you're right - not quite as easy as it first
pwnall-personal 2013/11/17 16:02:08 I got rid of the boolean in release builds, which
+
return true;
}
« no previous file with comments | « Source/bindings/v8/custom/V8BlobCustomHelpers.h ('k') | Source/bindings/v8/custom/V8FileCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698