| 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 "components/cronet/android/org_chromium_net_UrlRequest.h" | 5 #include "components/cronet/android/org_chromium_net_UrlRequest.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/cronet/android/url_request_context_peer.h" | 10 #include "components/cronet/android/url_request_context_peer.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 static jlong GetContentLength(JNIEnv* env, | 294 static jlong GetContentLength(JNIEnv* env, |
| 295 jobject object, | 295 jobject object, |
| 296 jlong urlRequestPeer) { | 296 jlong urlRequestPeer) { |
| 297 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); | 297 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); |
| 298 if (request == NULL) { | 298 if (request == NULL) { |
| 299 return 0; | 299 return 0; |
| 300 } | 300 } |
| 301 return request->content_length(); | 301 return request->content_length(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 static jstring GetHeader( |
| 305 JNIEnv* env, jobject object, jlong urlRequestPeer, jstring name) { |
| 306 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); |
| 307 if (request == NULL) { |
| 308 return NULL; |
| 309 } |
| 310 |
| 311 std::string name_string = base::android::ConvertJavaStringToUTF8(env, name); |
| 312 std::string value = request->GetHeader(name_string); |
| 313 if (!value.empty()) { |
| 314 return ConvertUTF8ToJavaString(env, value.c_str()).Release(); |
| 315 } else { |
| 316 return NULL; |
| 317 } |
| 318 } |
| 319 |
| 304 } // namespace cronet | 320 } // namespace cronet |
| OLD | NEW |