OLD | NEW |
1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
2 // All rights reserved. | 2 // 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 endings = "transparent"; | 64 endings = "transparent"; |
65 if (endings != "transparent" && endings != "native") { | 65 if (endings != "transparent" && endings != "native") { |
66 exception = Dart_NewStringFromCString("The endings property must be
either \"transparent\" or \"native\""); | 66 exception = Dart_NewStringFromCString("The endings property must be
either \"transparent\" or \"native\""); |
67 goto fail; | 67 goto fail; |
68 } | 68 } |
69 | 69 |
70 BlobBuilder blobBuilder; | 70 BlobBuilder blobBuilder; |
71 | 71 |
72 uint32_t length = blobParts.size(); | 72 uint32_t length = blobParts.size(); |
73 | 73 |
74 DartDOMData* domData = static_cast<DartDOMData*>(Dart_GetNativeIsolateDa
ta(args)); | |
75 for (uint32_t i = 0; i < length; ++i) { | 74 for (uint32_t i = 0; i < length; ++i) { |
76 Dart_Handle item = blobParts[i]; | 75 Dart_Handle item = blobParts[i]; |
77 if (DartUtilities::isTypedData(item)) { | 76 if (DartUtilities::isTypedData(item)) { |
78 RefPtr<ArrayBuffer> arrayBuffer = DartUtilities::dartToArrayBuff
er(item, exception); | 77 RefPtr<ArrayBuffer> arrayBuffer = DartUtilities::dartToArrayBuff
er(item, exception); |
79 if (exception) | 78 if (exception) |
80 goto fail; | 79 goto fail; |
81 ASSERT(arrayBuffer); | 80 ASSERT(arrayBuffer); |
82 blobBuilder.append(arrayBuffer.get()); | 81 blobBuilder.append(arrayBuffer.get()); |
83 } else if (DartDOMWrapper::instanceOf<DartBlob>(domData, item)) { | 82 } else if (DartDOMWrapper::subtypeOf(item, DartBlob::dartClassId)) { |
84 Blob* blob = DartBlob::toNative(item, exception); | 83 Blob* blob = DartBlob::toNative(item, exception); |
85 if (exception) | 84 if (exception) |
86 goto fail; | 85 goto fail; |
87 ASSERT(blob); | 86 ASSERT(blob); |
88 blobBuilder.append(blob); | 87 blobBuilder.append(blob); |
89 } else { | 88 } else { |
90 String stringValue = DartUtilities::dartToString(item, exception
); | 89 String stringValue = DartUtilities::dartToString(item, exception
); |
91 if (exception) | 90 if (exception) |
92 goto fail; | 91 goto fail; |
93 blobBuilder.append(stringValue, endings); | 92 blobBuilder.append(stringValue, endings); |
(...skipping 17 matching lines...) Expand all Loading... |
111 if (!blob) | 110 if (!blob) |
112 return Dart_Null(); | 111 return Dart_Null(); |
113 | 112 |
114 if (blob->isFile()) | 113 if (blob->isFile()) |
115 return DartFile::createWrapper(static_cast<File*>(blob)); | 114 return DartFile::createWrapper(static_cast<File*>(blob)); |
116 | 115 |
117 return DartDOMWrapper::createWrapper<DartBlob>(blob); | 116 return DartDOMWrapper::createWrapper<DartBlob>(blob); |
118 } | 117 } |
119 | 118 |
120 } | 119 } |
OLD | NEW |