Chromium Code Reviews| 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 0; | |
| 309 } | |
| 310 if (request == NULL) { | |
|
mmenke
2014/05/09 16:41:40
I don't think we need two of these. Probably best
mef
2014/05/09 18:49:16
Good catch, we don't.
| |
| 311 return NULL; | |
| 312 } | |
| 313 | |
| 314 std::string name_string = base::android::ConvertJavaStringToUTF8(env, name); | |
| 315 std::string value = request->GetHeader(name_string); | |
| 316 if (!value.empty()) { | |
| 317 return ConvertUTF8ToJavaString(env, value.c_str()).Release(); | |
| 318 } else { | |
| 319 return NULL; | |
| 320 } | |
| 321 } | |
| 322 | |
| 304 } // namespace cronet | 323 } // namespace cronet |
| OLD | NEW |