| 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.content.Context; | 7 import android.content.Context; |
| 8 import android.os.ConditionVariable; | 8 import android.os.ConditionVariable; |
| 9 import android.os.Environment; | 9 import android.os.Environment; |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Initializes Cronet legacy API. | 58 // Initializes Cronet legacy API. |
| 59 public static final String LEGACY = "legacy"; | 59 public static final String LEGACY = "legacy"; |
| 60 // Initializes Cronet HttpURLConnection API. | 60 // Initializes Cronet HttpURLConnection API. |
| 61 public static final String HTTP_URL_CONNECTION = "http_url_connection"; | 61 public static final String HTTP_URL_CONNECTION = "http_url_connection"; |
| 62 // Do not initialize. | 62 // Do not initialize. |
| 63 public static final String NONE = "none"; | 63 public static final String NONE = "none"; |
| 64 | 64 |
| 65 private LibraryInitType() {} | 65 private LibraryInitType() {} |
| 66 } | 66 } |
| 67 | 67 |
| 68 private static boolean sLibCronetJavaTestsLoaded; |
| 69 |
| 68 public URLStreamHandlerFactory mStreamHandlerFactory; | 70 public URLStreamHandlerFactory mStreamHandlerFactory; |
| 69 public CronetEngine mCronetEngine; | 71 public CronetEngine mCronetEngine; |
| 70 @SuppressWarnings("deprecation") HttpUrlRequestFactory mRequestFactory; | 72 @SuppressWarnings("deprecation") HttpUrlRequestFactory mRequestFactory; |
| 71 | 73 |
| 72 private final String[] mCommandLine; | 74 private final String[] mCommandLine; |
| 73 private final Context mContext; | 75 private final Context mContext; |
| 74 | 76 |
| 75 private String mUrl; | 77 private String mUrl; |
| 76 private int mHttpStatusCode = 0; | 78 private int mHttpStatusCode = 0; |
| 77 | 79 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 @Override | 94 @Override |
| 93 public void onRequestComplete(HttpUrlRequest request) { | 95 public void onRequestComplete(HttpUrlRequest request) { |
| 94 mComplete.open(); | 96 mComplete.open(); |
| 95 } | 97 } |
| 96 | 98 |
| 97 public void blockForComplete() { | 99 public void blockForComplete() { |
| 98 mComplete.block(); | 100 mComplete.block(); |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 | 103 |
| 104 private static void ensureLibCronetJavaTestsLoaded() { |
| 105 if (!sLibCronetJavaTestsLoaded) { |
| 106 sLibCronetJavaTestsLoaded = true; |
| 107 System.loadLibrary("cronet_javatests"); |
| 108 } |
| 109 } |
| 110 |
| 102 // TODO(crbug.com/547160): Fix this findbugs error and remove the suppressio
n. | 111 // TODO(crbug.com/547160): Fix this findbugs error and remove the suppressio
n. |
| 103 @SuppressFBWarnings("EI_EXPOSE_REP2") | 112 @SuppressFBWarnings("EI_EXPOSE_REP2") |
| 104 public CronetTestFramework( | 113 public CronetTestFramework( |
| 105 String appUrl, String[] commandLine, Context context, CronetEngine.B
uilder builder) { | 114 String appUrl, String[] commandLine, Context context, CronetEngine.B
uilder builder) { |
| 106 mCommandLine = commandLine; | 115 mCommandLine = commandLine; |
| 107 mContext = context; | 116 mContext = context; |
| 108 | 117 |
| 118 ensureLibCronetJavaTestsLoaded(); |
| 119 |
| 109 // Print out extra arguments passed in starting this activity. | 120 // Print out extra arguments passed in starting this activity. |
| 110 if (commandLine != null) { | 121 if (commandLine != null) { |
| 111 assertEquals(0, commandLine.length % 2); | 122 assertEquals(0, commandLine.length % 2); |
| 112 for (int i = 0; i < commandLine.length / 2; i++) { | 123 for (int i = 0; i < commandLine.length / 2; i++) { |
| 113 Log.i(TAG, "Cronet commandLine %s = %s", commandLine[i * 2], | 124 Log.i(TAG, "Cronet commandLine %s = %s", commandLine[i * 2], |
| 114 commandLine[i * 2 + 1]); | 125 commandLine[i * 2 + 1]); |
| 115 } | 126 } |
| 116 } | 127 } |
| 117 | 128 |
| 118 // Initializes CronetEngine.Builder from commandLine args. | 129 // Initializes CronetEngine.Builder from commandLine args. |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 319 |
| 309 public void stopNetLog() { | 320 public void stopNetLog() { |
| 310 if (mRequestFactory != null) { | 321 if (mRequestFactory != null) { |
| 311 mRequestFactory.stopNetLog(); | 322 mRequestFactory.stopNetLog(); |
| 312 } | 323 } |
| 313 if (mCronetEngine != null) { | 324 if (mCronetEngine != null) { |
| 314 mCronetEngine.stopNetLog(); | 325 mCronetEngine.stopNetLog(); |
| 315 } | 326 } |
| 316 } | 327 } |
| 317 } | 328 } |
| OLD | NEW |