| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/common/android/resource_request_body_android.h" | 5 #include "content/common/android/resource_request_body_android.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "content/common/page_state_serialization.h" | 14 #include "content/common/page_state_serialization.h" |
| 15 #include "content/public/common/resource_request_body.h" | 15 #include "content/public/common/resource_request_body.h" |
| 16 #include "jni/ResourceRequestBody_jni.h" | 16 #include "jni/ResourceRequestBody_jni.h" |
| 17 | 17 |
| 18 using base::android::JavaParamRef; |
| 19 |
| 18 namespace content { | 20 namespace content { |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 base::android::ScopedJavaLocalRef<jbyteArray> | 24 base::android::ScopedJavaLocalRef<jbyteArray> |
| 23 ConvertResourceRequestBodyToJavaArray(JNIEnv* env, | 25 ConvertResourceRequestBodyToJavaArray(JNIEnv* env, |
| 24 const ResourceRequestBodyImpl& body) { | 26 const ResourceRequestBodyImpl& body) { |
| 25 std::string encoded = EncodeResourceRequestBody(body); | 27 std::string encoded = EncodeResourceRequestBody(body); |
| 26 return base::android::ToJavaByteArray( | 28 return base::android::ToJavaByteArray( |
| 27 env, reinterpret_cast<const uint8_t*>(encoded.data()), encoded.size()); | 29 env, reinterpret_cast<const uint8_t*>(encoded.data()), encoded.size()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return nullptr; | 82 return nullptr; |
| 81 | 83 |
| 82 std::vector<uint8_t> encoded; | 84 std::vector<uint8_t> encoded; |
| 83 base::android::JavaByteArrayToByteVector(env, j_encoded.obj(), &encoded); | 85 base::android::JavaByteArrayToByteVector(env, j_encoded.obj(), &encoded); |
| 84 | 86 |
| 85 return DecodeResourceRequestBody( | 87 return DecodeResourceRequestBody( |
| 86 reinterpret_cast<const char*>(encoded.data()), encoded.size()); | 88 reinterpret_cast<const char*>(encoded.data()), encoded.size()); |
| 87 } | 89 } |
| 88 | 90 |
| 89 } // namespace content | 91 } // namespace content |
| OLD | NEW |