| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/android/javatests/validation_test_util.h" | 5 #include "mojo/android/javatests/validation_test_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const JavaParamRef<jstring>& data_as_string) { | 30 const JavaParamRef<jstring>& data_as_string) { |
| 31 std::string input = | 31 std::string input = |
| 32 base::android::ConvertJavaStringToUTF8(env, data_as_string); | 32 base::android::ConvertJavaStringToUTF8(env, data_as_string); |
| 33 std::vector<uint8_t> data; | 33 std::vector<uint8_t> data; |
| 34 size_t num_handles; | 34 size_t num_handles; |
| 35 std::string error_message; | 35 std::string error_message; |
| 36 if (!test::ParseValidationTestInput( | 36 if (!test::ParseValidationTestInput( |
| 37 input, &data, &num_handles, &error_message)) { | 37 input, &data, &num_handles, &error_message)) { |
| 38 ScopedJavaLocalRef<jstring> j_error_message = | 38 ScopedJavaLocalRef<jstring> j_error_message = |
| 39 base::android::ConvertUTF8ToJavaString(env, error_message); | 39 base::android::ConvertUTF8ToJavaString(env, error_message); |
| 40 return Java_ValidationTestUtil_buildData(env, nullptr, 0, | 40 return Java_ValidationTestUtil_buildData(env, nullptr, 0, j_error_message); |
| 41 j_error_message.obj()); | |
| 42 } | 41 } |
| 43 void* data_ptr = &data[0]; | 42 void* data_ptr = &data[0]; |
| 44 if (!data_ptr) { | 43 if (!data_ptr) { |
| 45 DCHECK(!data.size()); | 44 DCHECK(!data.size()); |
| 46 data_ptr = &data; | 45 data_ptr = &data; |
| 47 } | 46 } |
| 48 jobject byte_buffer = | 47 jobject byte_buffer = |
| 49 env->NewDirectByteBuffer(data_ptr, data.size()); | 48 env->NewDirectByteBuffer(data_ptr, data.size()); |
| 50 return Java_ValidationTestUtil_buildData(env, byte_buffer, num_handles, | 49 return Java_ValidationTestUtil_buildData(env, byte_buffer, num_handles, |
| 51 nullptr); | 50 nullptr); |
| 52 } | 51 } |
| 53 | 52 |
| 54 } // namespace android | 53 } // namespace android |
| 55 } // namespace mojo | 54 } // namespace mojo |
| OLD | NEW |