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

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

Issue 74213009: File constructor understands lastModified. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to latest File API ED. 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/V8FileCustom.cpp
diff --git a/Source/bindings/v8/custom/V8FileCustom.cpp b/Source/bindings/v8/custom/V8FileCustom.cpp
index 6983ef2188946414cbbeb6a688c5b9914d1d3b51..735beb8a5e27d634af0174e94dca89d6ce854933 100644
--- a/Source/bindings/v8/custom/V8FileCustom.cpp
+++ b/Source/bindings/v8/custom/V8FileCustom.cpp
@@ -62,25 +62,49 @@ void V8File::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, fileName, info[1]);
- String contentType;
- String endings = "transparent"; // default if no BlobPropertyBag is passed
+ V8BlobCustomHelpers::ParsedProperties properties(true);
if (info.Length() > 2) {
if (!info[2]->IsObject()) {
throwTypeError(ExceptionMessages::failedToConstruct("File", "The 3rd argument is not of type Object."), info.GetIsolate());
return;
}
- if (!V8BlobCustomHelpers::processBlobPropertyBag(info[2], "File", contentType, endings, info.GetIsolate()))
+ if (!properties.parseBlobPropertyBag(info[2], "File", info.GetIsolate()))
return;
+ } else {
+ properties.setDefaultLastModified();
}
BlobBuilder blobBuilder;
v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]);
- if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, endings, blobBuilder, info.GetIsolate()))
+ if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, properties.endings, blobBuilder, info.GetIsolate()))
return;
- RefPtr<File> file = blobBuilder.createFile(contentType, fileName, currentTime());
+ RefPtr<File> file = blobBuilder.createFile(properties.contentType, fileName, properties.lastModified());
v8SetReturnValue(info, file.release());
}
+void V8File::lastModifiedDateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ // The auto-generated getters return null when the method in the underlying
+ // implementation returns NaN. The File API says we should return the
+ // current time when the last modification time is unknown.
+ // Section 7.2 of the File API spec. http://dev.w3.org/2006/webapi/FileAPI/
+
+ File* file = V8File::toNative(info.Holder());
+ double lastModified = file->lastModifiedDate();
+ if (!isValidFileTime(lastModified))
+ lastModified = currentTime();
+ v8SetReturnValue(info, v8::Date::New(lastModified));
+}
+
+void V8File::lastModifiedAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ File* file = V8File::toNative(info.Holder());
+ double lastModified = file->lastModifiedDate();
+ if (!isValidFileTime(lastModified))
+ lastModified = currentTime();
kinuko 2013/11/20 08:01:22 Shouldn't this be currentTimeMS()?
pwnall-personal 2013/11/20 09:51:07 Done. Yikes, thank you for catching this! I had t
+ v8SetReturnValue(info, floor(lastModified));
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698