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 package org.chromium.net; | 5 package org.chromium.net; |
6 | 6 |
7 import android.util.Log; | 7 import android.util.Log; |
8 | 8 |
9 import org.apache.http.conn.ConnectTimeoutException; | 9 import org.apache.http.conn.ConnectTimeoutException; |
10 import org.chromium.base.CalledByNative; | 10 import org.chromium.base.CalledByNative; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 return mCanceled; | 383 return mCanceled; |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 public boolean isRecycled() { | 387 public boolean isRecycled() { |
388 synchronized (mLock) { | 388 synchronized (mLock) { |
389 return mRecycled; | 389 return mRecycled; |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
| 393 @Override |
| 394 public String getNegotiatedProtocol() { |
| 395 validateNotRecycled(); |
| 396 validateHeadersAvailable(); |
| 397 return nativeGetNegotiatedProtocol(mUrlRequestAdapter); |
| 398 } |
| 399 |
393 public String getContentType() { | 400 public String getContentType() { |
394 return mContentType; | 401 return mContentType; |
395 } | 402 } |
396 | 403 |
397 public String getHeader(String name) { | 404 public String getHeader(String name) { |
| 405 validateNotRecycled(); |
398 validateHeadersAvailable(); | 406 validateHeadersAvailable(); |
399 return nativeGetHeader(mUrlRequestAdapter, name); | 407 return nativeGetHeader(mUrlRequestAdapter, name); |
400 } | 408 } |
401 | 409 |
402 // All response headers. | 410 // All response headers. |
403 public Map<String, List<String>> getAllHeaders() { | 411 public Map<String, List<String>> getAllHeaders() { |
| 412 validateNotRecycled(); |
404 validateHeadersAvailable(); | 413 validateHeadersAvailable(); |
405 ResponseHeadersMap result = new ResponseHeadersMap(); | 414 ResponseHeadersMap result = new ResponseHeadersMap(); |
406 nativeGetAllHeaders(mUrlRequestAdapter, result); | 415 nativeGetAllHeaders(mUrlRequestAdapter, result); |
407 return result; | 416 return result; |
408 } | 417 } |
409 | 418 |
410 public String getUrl() { | 419 public String getUrl() { |
411 return mUrl; | 420 return mUrl; |
412 } | 421 } |
413 | 422 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 689 |
681 private native String nativeGetContentType(long urlRequestAdapter); | 690 private native String nativeGetContentType(long urlRequestAdapter); |
682 | 691 |
683 private native long nativeGetContentLength(long urlRequestAdapter); | 692 private native long nativeGetContentLength(long urlRequestAdapter); |
684 | 693 |
685 private native String nativeGetHeader(long urlRequestAdapter, String name); | 694 private native String nativeGetHeader(long urlRequestAdapter, String name); |
686 | 695 |
687 private native void nativeGetAllHeaders(long urlRequestAdapter, | 696 private native void nativeGetAllHeaders(long urlRequestAdapter, |
688 ResponseHeadersMap headers); | 697 ResponseHeadersMap headers); |
689 | 698 |
| 699 private native String nativeGetNegotiatedProtocol(long urlRequestAdapter); |
| 700 |
690 // Explicit class to work around JNI-generator generics confusion. | 701 // Explicit class to work around JNI-generator generics confusion. |
691 private class ResponseHeadersMap extends HashMap<String, List<String>> { | 702 private class ResponseHeadersMap extends HashMap<String, List<String>> { |
692 } | 703 } |
693 } | 704 } |
OLD | NEW |