OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.net.TrafficStats; | 8 import android.net.TrafficStats; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.util.Log; | 10 import android.util.Log; |
(...skipping 18 matching lines...) Expand all Loading... |
29 import java.util.concurrent.atomic.AtomicBoolean; | 29 import java.util.concurrent.atomic.AtomicBoolean; |
30 import java.util.concurrent.atomic.AtomicReference; | 30 import java.util.concurrent.atomic.AtomicReference; |
31 | 31 |
32 /** | 32 /** |
33 * Pure java UrlRequest, backed by {@link HttpURLConnection}. | 33 * Pure java UrlRequest, backed by {@link HttpURLConnection}. |
34 */ | 34 */ |
35 @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) // TrafficStats only availabl
e on ICS | 35 @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) // TrafficStats only availabl
e on ICS |
36 final class JavaUrlRequest implements UrlRequest { | 36 final class JavaUrlRequest implements UrlRequest { |
37 private static final String X_ANDROID = "X-Android"; | 37 private static final String X_ANDROID = "X-Android"; |
38 private static final String X_ANDROID_SELECTED_TRANSPORT = "X-Android-Select
ed-Transport"; | 38 private static final String X_ANDROID_SELECTED_TRANSPORT = "X-Android-Select
ed-Transport"; |
39 private static final String TAG = "JavaUrlConnection"; | 39 private static final String TAG = JavaUrlRequest.class.getSimpleName(); |
40 private static final int DEFAULT_UPLOAD_BUFFER_SIZE = 8192; | 40 private static final int DEFAULT_UPLOAD_BUFFER_SIZE = 8192; |
41 private static final int DEFAULT_CHUNK_LENGTH = DEFAULT_UPLOAD_BUFFER_SIZE; | 41 private static final int DEFAULT_CHUNK_LENGTH = DEFAULT_UPLOAD_BUFFER_SIZE; |
42 private static final String USER_AGENT = "User-Agent"; | 42 private static final String USER_AGENT = "User-Agent"; |
43 private final AsyncUrlRequestCallback mCallbackAsync; | 43 private final AsyncUrlRequestCallback mCallbackAsync; |
44 private final Executor mExecutor; | 44 private final Executor mExecutor; |
45 private final String mUserAgent; | 45 private final String mUserAgent; |
46 private final Map<String, String> mRequestHeaders = | 46 private final Map<String, String> mRequestHeaders = |
47 new TreeMap<>(String.CASE_INSENSITIVE_ORDER); | 47 new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
48 private final List<String> mUrlChain = new ArrayList<>(); | 48 private final List<String> mUrlChain = new ArrayList<>(); |
49 /** | 49 /** |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 if (closeable == null) { | 844 if (closeable == null) { |
845 return; | 845 return; |
846 } | 846 } |
847 try { | 847 try { |
848 closeable.close(); | 848 closeable.close(); |
849 } catch (IOException e) { | 849 } catch (IOException e) { |
850 e.printStackTrace(); | 850 e.printStackTrace(); |
851 } | 851 } |
852 } | 852 } |
853 } | 853 } |
OLD | NEW |