| 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..5d9af5fcb45562bb3ea75b4e7276c0f3eb99ffa2 100644
|
| --- a/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
|
| +++ b/Source/bindings/v8/custom/V8BlobCustomHelpers.cpp
|
| @@ -38,33 +38,71 @@
|
| #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)
|
| + : m_endings("transparent")
|
| + , m_hasFileProperties(hasFileProperties)
|
| +#ifndef NDEBUG
|
| + , m_hasLastModified(false)
|
| +#endif // NDEBUG
|
| {
|
| - ASSERT(endings == "transparent");
|
| +}
|
| +
|
| +void ParsedProperties::setLastModified(double lastModified)
|
| +{
|
| + ASSERT(m_hasFileProperties);
|
| + ASSERT(!m_hasLastModified);
|
| + m_lastModified = lastModified;
|
| +#ifndef NDEBUG
|
| + m_hasLastModified = true;
|
| +#endif // NDEBUG
|
| +}
|
| +
|
| +void ParsedProperties::setDefaultLastModified()
|
| +{
|
| + setLastModified(currentTime());
|
| +}
|
| +
|
| +bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobClassName, v8::Isolate* isolate)
|
| +{
|
| + ASSERT(m_endings == "transparent");
|
|
|
| V8TRYCATCH_RETURN(Dictionary, dictionary, Dictionary(propertyBag, isolate), false);
|
|
|
| - V8TRYCATCH_RETURN(bool, containsEndings, dictionary.get("endings", endings), false);
|
| + V8TRYCATCH_RETURN(bool, containsEndings, dictionary.get("endings", m_endings), false);
|
| if (containsEndings) {
|
| - if (endings != "transparent" && endings != "native") {
|
| + if (m_endings != "transparent" && m_endings != "native") {
|
| throwTypeError(ExceptionMessages::failedToConstruct(blobClassName, "The \"endings\" property must be either \"transparent\" or \"native\"."), isolate);
|
| return false;
|
| }
|
| }
|
|
|
| - V8TRYCATCH_RETURN(bool, containsType, dictionary.get("type", contentType), false);
|
| + V8TRYCATCH_RETURN(bool, containsType, dictionary.get("type", m_contentType), false);
|
| if (containsType) {
|
| - if (!contentType.containsOnlyASCII()) {
|
| + if (!m_contentType.containsOnlyASCII()) {
|
| throwError(v8SyntaxError, ExceptionMessages::failedToConstruct(blobClassName, "The \"type\" property must consist of ASCII characters."), isolate);
|
| return false;
|
| }
|
| - contentType = contentType.lower();
|
| + m_contentType = m_contentType.lower();
|
| + }
|
| +
|
| + if (!m_hasFileProperties)
|
| + return true;
|
| +
|
| + v8::Local<v8::Value> lastModified;
|
| + V8TRYCATCH_RETURN(bool, containsLastModified, dictionary.get("lastModified", lastModified), false);
|
| + if (containsLastModified) {
|
| + V8TRYCATCH_RETURN(long long, lastModifiedInt, toInt64(lastModified), false);
|
| + setLastModified(static_cast<double>(lastModifiedInt) / msPerSecond);
|
| + } else {
|
| + setDefaultLastModified();
|
| }
|
| +
|
| return true;
|
| }
|
|
|
|
|