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/cronet_url_request_adapter.h" | 5 #include "components/cronet/android/cronet_url_request_adapter.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 } | 352 } |
353 | 353 |
354 base::android::ScopedJavaLocalRef<jobjectArray> | 354 base::android::ScopedJavaLocalRef<jobjectArray> |
355 CronetURLRequestAdapter::GetResponseHeaders(JNIEnv* env) { | 355 CronetURLRequestAdapter::GetResponseHeaders(JNIEnv* env) { |
356 DCHECK(context_->IsOnNetworkThread()); | 356 DCHECK(context_->IsOnNetworkThread()); |
357 | 357 |
358 std::vector<std::string> response_headers; | 358 std::vector<std::string> response_headers; |
359 const net::HttpResponseHeaders* headers = url_request_->response_headers(); | 359 const net::HttpResponseHeaders* headers = url_request_->response_headers(); |
360 // Returns an empty array if |headers| is nullptr. | 360 // Returns an empty array if |headers| is nullptr. |
361 if (headers != nullptr) { | 361 if (headers != nullptr) { |
362 void* iter = nullptr; | 362 size_t iter = 0; |
363 std::string header_name; | 363 std::string header_name; |
364 std::string header_value; | 364 std::string header_value; |
365 while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) { | 365 while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) { |
366 response_headers.push_back(header_name); | 366 response_headers.push_back(header_name); |
367 response_headers.push_back(header_value); | 367 response_headers.push_back(header_value); |
368 } | 368 } |
369 } | 369 } |
370 return base::android::ToJavaArrayOfStrings(env, response_headers); | 370 return base::android::ToJavaArrayOfStrings(env, response_headers); |
371 } | 371 } |
372 | 372 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 << " on chromium request: " << initial_url_.possibly_invalid_spec(); | 412 << " on chromium request: " << initial_url_.possibly_invalid_spec(); |
413 JNIEnv* env = base::android::AttachCurrentThread(); | 413 JNIEnv* env = base::android::AttachCurrentThread(); |
414 cronet::Java_CronetUrlRequest_onError( | 414 cronet::Java_CronetUrlRequest_onError( |
415 env, owner_.obj(), net_error, | 415 env, owner_.obj(), net_error, |
416 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj(), | 416 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj(), |
417 request->GetTotalReceivedBytes()); | 417 request->GetTotalReceivedBytes()); |
418 return true; | 418 return true; |
419 } | 419 } |
420 | 420 |
421 } // namespace cronet | 421 } // namespace cronet |
OLD | NEW |