Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: components/cronet/android/org_chromium_net_UrlRequest.cc

Issue 432553003: Remove redundant mapping of net errors to strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_certificate_importer_impl.cc ('k') | content/child/socket_stream_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698