OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #endif // NDEBUG | 62 #endif // NDEBUG |
63 } | 63 } |
64 | 64 |
65 void ParsedProperties::setDefaultLastModified() | 65 void ParsedProperties::setDefaultLastModified() |
66 { | 66 { |
67 setLastModified(currentTime()); | 67 setLastModified(currentTime()); |
68 } | 68 } |
69 | 69 |
70 bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, co
nst char* blobClassName, ExceptionState& exceptionState, v8::Isolate* isolate) | 70 bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, co
nst char* blobClassName, ExceptionState& exceptionState, v8::Isolate* isolate) |
71 { | 71 { |
72 V8TRYCATCH_RETURN(Dictionary, dictionary, Dictionary(propertyBag, isolate),
false); | 72 TONATIVE_BOOL(Dictionary, dictionary, Dictionary(propertyBag, isolate), fals
e); |
73 | 73 |
74 String endings; | 74 String endings; |
75 V8TRYCATCH_RETURN(bool, containsEndings, dictionary.get("endings", endings),
false); | 75 TONATIVE_BOOL(bool, containsEndings, dictionary.get("endings", endings), fal
se); |
76 if (containsEndings) { | 76 if (containsEndings) { |
77 if (endings != "transparent" && endings != "native") { | 77 if (endings != "transparent" && endings != "native") { |
78 exceptionState.throwTypeError("The 'endings' property must be either
'transparent' or 'native'."); | 78 exceptionState.throwTypeError("The 'endings' property must be either
'transparent' or 'native'."); |
79 return false; | 79 return false; |
80 } | 80 } |
81 if (endings == "native") | 81 if (endings == "native") |
82 m_normalizeLineEndingsToNative = true; | 82 m_normalizeLineEndingsToNative = true; |
83 } | 83 } |
84 | 84 |
85 V8TRYCATCH_RETURN(bool, containsType, dictionary.get("type", m_contentType),
false); | 85 TONATIVE_BOOL(bool, containsType, dictionary.get("type", m_contentType), fal
se); |
86 if (containsType) { | 86 if (containsType) { |
87 if (!m_contentType.containsOnlyASCII()) { | 87 if (!m_contentType.containsOnlyASCII()) { |
88 exceptionState.throwDOMException(SyntaxError, "The 'type' property m
ust consist of ASCII characters."); | 88 exceptionState.throwDOMException(SyntaxError, "The 'type' property m
ust consist of ASCII characters."); |
89 return false; | 89 return false; |
90 } | 90 } |
91 m_contentType = m_contentType.lower(); | 91 m_contentType = m_contentType.lower(); |
92 } | 92 } |
93 | 93 |
94 if (!m_hasFileProperties) | 94 if (!m_hasFileProperties) |
95 return true; | 95 return true; |
96 | 96 |
97 v8::Local<v8::Value> lastModified; | 97 v8::Local<v8::Value> lastModified; |
98 V8TRYCATCH_RETURN(bool, containsLastModified, dictionary.get("lastModified",
lastModified), false); | 98 TONATIVE_BOOL(bool, containsLastModified, dictionary.get("lastModified", las
tModified), false); |
99 if (containsLastModified) { | 99 if (containsLastModified) { |
100 V8TRYCATCH_RETURN(long long, lastModifiedInt, toInt64(lastModified), fal
se); | 100 TONATIVE_BOOL(long long, lastModifiedInt, toInt64(lastModified), false); |
101 setLastModified(static_cast<double>(lastModifiedInt) / msPerSecond); | 101 setLastModified(static_cast<double>(lastModifiedInt) / msPerSecond); |
102 } else { | 102 } else { |
103 setDefaultLastModified(); | 103 setDefaultLastModified(); |
104 } | 104 } |
105 | 105 |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
109 bool processBlobParts(v8::Local<v8::Object> blobParts, uint32_t blobPartsLength,
bool normalizeLineEndingsToNative, BlobData& blobData, v8::Isolate* isolate) | 109 bool processBlobParts(v8::Local<v8::Object> blobParts, uint32_t blobPartsLength,
bool normalizeLineEndingsToNative, BlobData& blobData, v8::Isolate* isolate) |
110 { | 110 { |
111 for (uint32_t i = 0; i < blobPartsLength; ++i) { | 111 for (uint32_t i = 0; i < blobPartsLength; ++i) { |
112 v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(isolate, i)); | 112 v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(isolate, i)); |
113 if (item.IsEmpty()) | 113 if (item.IsEmpty()) |
114 return false; | 114 return false; |
115 | 115 |
116 if (V8ArrayBuffer::hasInstance(item, isolate)) { | 116 if (V8ArrayBuffer::hasInstance(item, isolate)) { |
117 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Ob
ject>::Cast(item)); | 117 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Ob
ject>::Cast(item)); |
118 ASSERT(arrayBuffer); | 118 ASSERT(arrayBuffer); |
119 blobData.appendArrayBuffer(arrayBuffer); | 119 blobData.appendArrayBuffer(arrayBuffer); |
120 } else if (V8ArrayBufferView::hasInstance(item, isolate)) { | 120 } else if (V8ArrayBufferView::hasInstance(item, isolate)) { |
121 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::H
andle<v8::Object>::Cast(item)); | 121 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::H
andle<v8::Object>::Cast(item)); |
122 ASSERT(arrayBufferView); | 122 ASSERT(arrayBufferView); |
123 blobData.appendArrayBufferView(arrayBufferView); | 123 blobData.appendArrayBufferView(arrayBufferView); |
124 } else if (V8Blob::hasInstance(item, isolate)) { | 124 } else if (V8Blob::hasInstance(item, isolate)) { |
125 Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); | 125 Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); |
126 ASSERT(blob); | 126 ASSERT(blob); |
127 blob->appendTo(blobData); | 127 blob->appendTo(blobData); |
128 } else { | 128 } else { |
129 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringVal
ue, item, false); | 129 TOSTRING_BOOL_BOOL(V8StringResource<>, stringValue, item, false); |
130 blobData.appendText(stringValue, normalizeLineEndingsToNative); | 130 blobData.appendText(stringValue, normalizeLineEndingsToNative); |
131 } | 131 } |
132 } | 132 } |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 } // namespace V8BlobCustomHelpers | 136 } // namespace V8BlobCustomHelpers |
137 | 137 |
138 } // namespace WebCore | 138 } // namespace WebCore |
OLD | NEW |