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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 return result; | 649 return result; |
641 } catch (Exception e) { | 650 } catch (Exception e) { |
642 onCalledByNativeException(e); | 651 onCalledByNativeException(e); |
643 } | 652 } |
644 return -1; | 653 return -1; |
645 } | 654 } |
646 | 655 |
647 // Native methods are implemented in chromium_url_request.cc. | 656 // Native methods are implemented in chromium_url_request.cc. |
648 | 657 |
649 private native long nativeCreateRequestAdapter( | 658 private native long nativeCreateRequestAdapter( |
650 long ChromiumUrlRequestContextAdapter, String url, int priority); | 659 long urlRequestContextAdapter, String url, int priority); |
651 | 660 |
652 private native void nativeAddHeader(long urlRequestAdapter, String name, | 661 private native void nativeAddHeader(long urlRequestAdapter, String name, |
653 String value); | 662 String value); |
654 | 663 |
655 private native void nativeSetMethod(long urlRequestAdapter, String method); | 664 private native void nativeSetMethod(long urlRequestAdapter, String method); |
656 | 665 |
657 private native void nativeSetUploadData(long urlRequestAdapter, | 666 private native void nativeSetUploadData(long urlRequestAdapter, |
658 String contentType, byte[] content); | 667 String contentType, byte[] content); |
659 | 668 |
660 private native void nativeSetUploadChannel(long urlRequestAdapter, | 669 private native void nativeSetUploadChannel(long urlRequestAdapter, |
(...skipping 19 matching lines...) Expand all 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 |