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

Side by Side Diff: Source/bindings/core/v8/custom/V8BlobCustomHelpers.cpp

Issue 373423002: Split Dictionary's get and convert into DictionaryHelper. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/core/v8/custom/V8BlobCustomHelpers.h" 32 #include "bindings/core/v8/custom/V8BlobCustomHelpers.h"
33 33
34 #include "bindings/core/v8/Dictionary.h" 34 #include "bindings/core/v8/Dictionary.h"
35 #include "bindings/core/v8/DictionaryHelper.h"
35 #include "bindings/core/v8/ExceptionState.h" 36 #include "bindings/core/v8/ExceptionState.h"
36 #include "bindings/core/v8/V8Binding.h" 37 #include "bindings/core/v8/V8Binding.h"
37 #include "bindings/core/v8/V8Blob.h" 38 #include "bindings/core/v8/V8Blob.h"
38 #include "bindings/core/v8/custom/V8ArrayBufferCustom.h" 39 #include "bindings/core/v8/custom/V8ArrayBufferCustom.h"
39 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" 40 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h"
40 #include "wtf/DateMath.h" 41 #include "wtf/DateMath.h"
41 42
42 namespace WebCore { 43 namespace WebCore {
43 44
44 namespace V8BlobCustomHelpers { 45 namespace V8BlobCustomHelpers {
(...skipping 20 matching lines...) Expand all
65 void ParsedProperties::setDefaultLastModified() 66 void ParsedProperties::setDefaultLastModified()
66 { 67 {
67 setLastModified(currentTime()); 68 setLastModified(currentTime());
68 } 69 }
69 70
70 bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, co nst char* blobClassName, ExceptionState& exceptionState, v8::Isolate* isolate) 71 bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, co nst char* blobClassName, ExceptionState& exceptionState, v8::Isolate* isolate)
71 { 72 {
72 TONATIVE_DEFAULT(Dictionary, dictionary, Dictionary(propertyBag, isolate), f alse); 73 TONATIVE_DEFAULT(Dictionary, dictionary, Dictionary(propertyBag, isolate), f alse);
73 74
74 String endings; 75 String endings;
75 TONATIVE_DEFAULT(bool, containsEndings, dictionary.get("endings", endings), false); 76 TONATIVE_DEFAULT(bool, containsEndings, DictionaryHelper::get(dictionary, "e ndings", endings), false);
76 if (containsEndings) { 77 if (containsEndings) {
77 if (endings != "transparent" && endings != "native") { 78 if (endings != "transparent" && endings != "native") {
78 exceptionState.throwTypeError("The 'endings' property must be either 'transparent' or 'native'."); 79 exceptionState.throwTypeError("The 'endings' property must be either 'transparent' or 'native'.");
79 return false; 80 return false;
80 } 81 }
81 if (endings == "native") 82 if (endings == "native")
82 m_normalizeLineEndingsToNative = true; 83 m_normalizeLineEndingsToNative = true;
83 } 84 }
84 85
85 TONATIVE_DEFAULT(bool, containsType, dictionary.get("type", m_contentType), false); 86 TONATIVE_DEFAULT(bool, containsType, DictionaryHelper::get(dictionary, "type ", m_contentType), false);
86 if (containsType) { 87 if (containsType) {
87 if (!m_contentType.containsOnlyASCII()) { 88 if (!m_contentType.containsOnlyASCII()) {
88 exceptionState.throwDOMException(SyntaxError, "The 'type' property m ust consist of ASCII characters."); 89 exceptionState.throwDOMException(SyntaxError, "The 'type' property m ust consist of ASCII characters.");
89 return false; 90 return false;
90 } 91 }
91 m_contentType = m_contentType.lower(); 92 m_contentType = m_contentType.lower();
92 } 93 }
93 94
94 if (!m_hasFileProperties) 95 if (!m_hasFileProperties)
95 return true; 96 return true;
96 97
97 v8::Local<v8::Value> lastModified; 98 v8::Local<v8::Value> lastModified;
98 TONATIVE_DEFAULT(bool, containsLastModified, dictionary.get("lastModified", lastModified), false); 99 TONATIVE_DEFAULT(bool, containsLastModified, DictionaryHelper::get(dictionar y, "lastModified", lastModified), false);
99 if (containsLastModified) { 100 if (containsLastModified) {
100 TONATIVE_DEFAULT(long long, lastModifiedInt, toInt64(lastModified), fals e); 101 TONATIVE_DEFAULT(long long, lastModifiedInt, toInt64(lastModified), fals e);
101 setLastModified(static_cast<double>(lastModifiedInt) / msPerSecond); 102 setLastModified(static_cast<double>(lastModifiedInt) / msPerSecond);
102 } else { 103 } else {
103 setDefaultLastModified(); 104 setDefaultLastModified();
104 } 105 }
105 106
106 return true; 107 return true;
107 } 108 }
108 109
(...skipping 20 matching lines...) Expand all
129 TOSTRING_DEFAULT(V8StringResource<>, stringValue, item, false); 130 TOSTRING_DEFAULT(V8StringResource<>, stringValue, item, false);
130 blobData.appendText(stringValue, normalizeLineEndingsToNative); 131 blobData.appendText(stringValue, normalizeLineEndingsToNative);
131 } 132 }
132 } 133 }
133 return true; 134 return true;
134 } 135 }
135 136
136 } // namespace V8BlobCustomHelpers 137 } // namespace V8BlobCustomHelpers
137 138
138 } // namespace WebCore 139 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698