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

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

Issue 57483002: Implement File constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed feedback, minus sequence vs array in File/Blob constructor. 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/V8BlobCustom.cpp b/Source/bindings/v8/custom/V8FileCustom.cpp
similarity index 82%
copy from Source/bindings/v8/custom/V8BlobCustom.cpp
copy to Source/bindings/v8/custom/V8FileCustom.cpp
index d514a4eff6a71eb5d36f0cdd090baecd2215bb7e..5ac9dd0fa5a825cd6d98a81c0403ad0f84748ee8 100644
--- a/Source/bindings/v8/custom/V8BlobCustom.cpp
+++ b/Source/bindings/v8/custom/V8FileCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,8 +29,9 @@
*/
#include "config.h"
-#include "V8Blob.h"
+#include "V8File.h"
+#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8Utilities.h"
@@ -41,11 +42,15 @@
namespace WebCore {
-void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8File::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- if (!info.Length()) {
- RefPtr<Blob> blob = Blob::create();
- info.GetReturnValue().Set(toV8(blob.get(), info.Holder(), info.GetIsolate()));
+ if (!RuntimeEnabledFeatures::fileConstructorEnabled()) {
+ throwTypeError("Illegal constructor", info.GetIsolate());
+ return;
+ }
+
+ if (info.Length() < 2) {
+ throwTypeError("Constructor requires at least two arguments", info.GetIsolate());
return;
}
@@ -55,16 +60,19 @@ void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
return;
}
+ v8::Local<v8::Value> secondArg = info[1];
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, fileName, secondArg);
+
String type;
String endings = "transparent";
- if (info.Length() > 1) {
- if (!info[1]->IsObject()) {
- throwTypeError("Second argument of the constructor is not of type Object", info.GetIsolate());
+ if (info.Length() > 2) {
+ if (!info[2]->IsObject()) {
+ throwTypeError("Third argument of the constructor is not of type Object", info.GetIsolate());
return;
}
- V8TRYCATCH_VOID(Dictionary, dictionary, Dictionary(info[1], info.GetIsolate()));
+ V8TRYCATCH_VOID(Dictionary, dictionary, Dictionary(info[2], info.GetIsolate()));
V8TRYCATCH_VOID(bool, containsEndings, dictionary.get("endings", endings));
if (containsEndings) {
@@ -111,8 +119,9 @@ void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
}
}
- RefPtr<Blob> blob = blobBuilder.getBlob(type);
- info.GetReturnValue().Set(toV8(blob.get(), info.Holder(), info.GetIsolate()));
+ RefPtr<File> file = blobBuilder.getFile(type, fileName, currentTime());
+ info.GetReturnValue().Set(toV8(file.get(), info.Holder(), info.GetIsolate()));
}
} // namespace WebCore
+

Powered by Google App Engine
This is Rietveld 408576698