| 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.SuppressLint; |
| 7 import android.app.Activity; | 8 import android.app.Activity; |
| 8 import android.net.Uri; | 9 import android.net.Uri; |
| 9 import android.os.AsyncTask; | 10 import android.os.AsyncTask; |
| 10 import android.os.Bundle; | 11 import android.os.Bundle; |
| 11 import android.os.Debug; | 12 import android.os.Debug; |
| 12 | 13 |
| 13 import org.chromium.net.urlconnection.CronetHttpURLStreamHandler; | 14 import org.chromium.net.urlconnection.CronetHttpURLStreamHandler; |
| 14 import org.json.JSONException; | 15 import org.json.JSONException; |
| 15 import org.json.JSONObject; | 16 import org.json.JSONObject; |
| 16 | 17 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 private void reportResult() { | 205 private void reportResult() { |
| 205 if (mStartTimeMs == -1 || mStopTimeMs == -1) | 206 if (mStartTimeMs == -1 || mStopTimeMs == -1) |
| 206 throw new IllegalStateException("startTimer() or stopTimer() not
called"); | 207 throw new IllegalStateException("startTimer() or stopTimer() not
called"); |
| 207 try { | 208 try { |
| 208 mResults.put(mName, mStopTimeMs - mStartTimeMs); | 209 mResults.put(mName, mStopTimeMs - mStartTimeMs); |
| 209 } catch (JSONException e) { | 210 } catch (JSONException e) { |
| 210 System.out.println("Failed to write JSON result for " + mName); | 211 System.out.println("Failed to write JSON result for " + mName); |
| 211 } | 212 } |
| 212 } | 213 } |
| 213 | 214 |
| 215 // TODO(pauljensen): Remove @SuppressLint once crbug.com/501591 is fixed
. |
| 216 @SuppressLint("NewApi") |
| 214 private void startLogging() { | 217 private void startLogging() { |
| 215 if (getConfigBoolean("CAPTURE_NETLOG")) { | 218 if (getConfigBoolean("CAPTURE_NETLOG")) { |
| 216 mCronetContext.startNetLogToFile(getFilesDir().getPath() + "/" +
mName + ".json", | 219 mCronetContext.startNetLogToFile(getFilesDir().getPath() + "/" +
mName + ".json", |
| 217 false); | 220 false); |
| 218 } | 221 } |
| 219 if (getConfigBoolean("CAPTURE_TRACE")) { | 222 if (getConfigBoolean("CAPTURE_TRACE")) { |
| 220 Debug.startMethodTracing(getFilesDir().getPath() + "/" + mName +
".trace"); | 223 Debug.startMethodTracing(getFilesDir().getPath() + "/" + mName +
".trace"); |
| 221 } else if (getConfigBoolean("CAPTURE_SAMPLED_TRACE")) { | 224 } else if (getConfigBoolean("CAPTURE_SAMPLED_TRACE")) { |
| 222 Debug.startMethodTracingSampling( | 225 Debug.startMethodTracingSampling( |
| 223 getFilesDir().getPath() + "/" + mName + ".trace", 800000
0, 10); | 226 getFilesDir().getPath() + "/" + mName + ".trace", 800000
0, 10); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 } | 586 } |
| 584 | 587 |
| 585 @Override | 588 @Override |
| 586 public void onCreate(Bundle savedInstanceState) { | 589 public void onCreate(Bundle savedInstanceState) { |
| 587 super.onCreate(savedInstanceState); | 590 super.onCreate(savedInstanceState); |
| 588 mConfig = getIntent().getData(); | 591 mConfig = getIntent().getData(); |
| 589 // Execute benchmarks on another thread to avoid networking on main thre
ad. | 592 // Execute benchmarks on another thread to avoid networking on main thre
ad. |
| 590 new BenchmarkTask().execute(); | 593 new BenchmarkTask().execute(); |
| 591 } | 594 } |
| 592 } | 595 } |
| OLD | NEW |