Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
| 6 #include "bin/filter.h" | 6 #include "bin/filter.h" |
| 7 #include "bin/io_buffer.h" | 7 #include "bin/io_buffer.h" |
| 8 | 8 |
| 9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 Filter* filter = GetFilter(filter_obj); | 147 Filter* filter = GetFilter(filter_obj); |
| 148 Dart_Handle data_obj = Dart_GetNativeArgument(args, 1); | 148 Dart_Handle data_obj = Dart_GetNativeArgument(args, 1); |
| 149 intptr_t start = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2)); | 149 intptr_t start = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2)); |
| 150 intptr_t end = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3)); | 150 intptr_t end = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3)); |
| 151 intptr_t chunk_length = end - start; | 151 intptr_t chunk_length = end - start; |
| 152 intptr_t length; | 152 intptr_t length; |
| 153 Dart_TypedData_Type type; | 153 Dart_TypedData_Type type; |
| 154 uint8_t* buffer = NULL; | 154 uint8_t* buffer = NULL; |
| 155 Dart_Handle result = Dart_TypedDataAcquireData( | 155 Dart_Handle result = Dart_TypedDataAcquireData( |
| 156 data_obj, &type, reinterpret_cast<void**>(&buffer), &length); | 156 data_obj, &type, reinterpret_cast<void**>(&buffer), &length); |
| 157 | |
| 157 if (!Dart_IsError(result)) { | 158 if (!Dart_IsError(result)) { |
| 159 ASSERT(type == Dart_TypedData_kUint8 || type == Dart_TypedData_kInt8); | |
|
Lasse Reichstein Nielsen
2015/10/08 11:26:57
Are we sure we want to treat Int8List as bytes?
| |
| 158 uint8_t* zlib_buffer = new uint8_t[chunk_length]; | 160 uint8_t* zlib_buffer = new uint8_t[chunk_length]; |
| 159 if (zlib_buffer == NULL) { | 161 if (zlib_buffer == NULL) { |
| 160 Dart_TypedDataReleaseData(data_obj); | 162 Dart_TypedDataReleaseData(data_obj); |
| 161 Dart_ThrowException(DartUtils::NewInternalError( | 163 Dart_ThrowException(DartUtils::NewInternalError( |
| 162 "Failed to allocate buffer for zlib")); | 164 "Failed to allocate buffer for zlib")); |
| 163 } | 165 } |
| 164 memmove(zlib_buffer, buffer + start, chunk_length); | 166 memmove(zlib_buffer, buffer + start, chunk_length); |
| 165 Dart_TypedDataReleaseData(data_obj); | 167 Dart_TypedDataReleaseData(data_obj); |
| 166 buffer = zlib_buffer; | 168 buffer = zlib_buffer; |
| 167 } else { | 169 } else { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 } | 401 } |
| 400 | 402 |
| 401 delete[] current_buffer_; | 403 delete[] current_buffer_; |
| 402 current_buffer_ = NULL; | 404 current_buffer_ = NULL; |
| 403 // Either 0 Byte processed or error | 405 // Either 0 Byte processed or error |
| 404 return error ? -1 : 0; | 406 return error ? -1 : 0; |
| 405 } | 407 } |
| 406 | 408 |
| 407 } // namespace bin | 409 } // namespace bin |
| 408 } // namespace dart | 410 } // namespace dart |
| OLD | NEW |