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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 244 } |
245 return REQUEST_ERROR_UNKNOWN; | 245 return REQUEST_ERROR_UNKNOWN; |
246 } | 246 } |
247 | 247 |
248 static jstring GetErrorString(JNIEnv* env, | 248 static jstring GetErrorString(JNIEnv* env, |
249 jobject object, | 249 jobject object, |
250 jlong urlRequestPeer) { | 250 jlong urlRequestPeer) { |
251 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); | 251 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); |
252 int error_code = request->error_code(); | 252 int error_code = request->error_code(); |
253 char buffer[200]; | 253 char buffer[200]; |
| 254 std::string error_string = net::ErrorToString(error_code); |
254 snprintf(buffer, | 255 snprintf(buffer, |
255 sizeof(buffer), | 256 sizeof(buffer), |
256 "System error: %s(%d)", | 257 "System error: %s(%d)", |
257 net::ErrorToString(error_code), | 258 error_string.c_str(), |
258 error_code); | 259 error_code); |
259 return ConvertUTF8ToJavaString(env, buffer).Release(); | 260 return ConvertUTF8ToJavaString(env, buffer).Release(); |
260 } | 261 } |
261 | 262 |
262 static jint GetHttpStatusCode(JNIEnv* env, | 263 static jint GetHttpStatusCode(JNIEnv* env, |
263 jobject object, | 264 jobject object, |
264 jlong urlRequestPeer) { | 265 jlong urlRequestPeer) { |
265 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); | 266 URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer); |
266 return request->http_status_code(); | 267 return request->http_status_code(); |
267 } | 268 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 std::string name_string = base::android::ConvertJavaStringToUTF8(env, name); | 302 std::string name_string = base::android::ConvertJavaStringToUTF8(env, name); |
302 std::string value = request->GetHeader(name_string); | 303 std::string value = request->GetHeader(name_string); |
303 if (!value.empty()) { | 304 if (!value.empty()) { |
304 return ConvertUTF8ToJavaString(env, value.c_str()).Release(); | 305 return ConvertUTF8ToJavaString(env, value.c_str()).Release(); |
305 } else { | 306 } else { |
306 return NULL; | 307 return NULL; |
307 } | 308 } |
308 } | 309 } |
309 | 310 |
310 } // namespace cronet | 311 } // namespace cronet |
OLD | NEW |