Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java

Issue 2333713003: Move PathUtils to use ContextUtils. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java
diff --git a/components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java b/components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java
index 0ca39e04d70f29fd8d97a5c32be5f01f20f4c461..6211a754f57732dacef48f25f0f1a53c0291f556 100644
--- a/components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java
+++ b/components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java
@@ -11,11 +11,12 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Debug;
-import org.chromium.base.PathUtils;
-
import org.json.JSONException;
import org.json.JSONObject;
+import org.chromium.base.ContextUtils;
+import org.chromium.base.PathUtils;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -331,8 +332,7 @@ public class CronetPerfTestActivity extends Activity {
// GET or POST to one particular URL using Cronet's asynchronous API
private class CronetAsyncFetchTask implements Callable<Boolean> {
// A message-queue for asynchronous tasks to post back to.
- private final LinkedBlockingQueue<Runnable> mWorkQueue =
- new LinkedBlockingQueue<Runnable>();
+ private final LinkedBlockingQueue<Runnable> mWorkQueue = new LinkedBlockingQueue<>();
private final WorkQueueExecutor mWorkQueueExecutor = new WorkQueueExecutor();
private int mRemainingRequests;
@@ -351,6 +351,7 @@ public class CronetPerfTestActivity extends Activity {
if (mUseNetworkThread) {
// Post empty task so message loop exit condition is retested.
postToWorkQueue(new Runnable() {
+ @Override
public void run() {}
});
}
@@ -358,6 +359,7 @@ public class CronetPerfTestActivity extends Activity {
}
mRemainingRequests--;
final Runnable completionCallback = new Runnable() {
+ @Override
public void run() {
initiateRequest(buffer);
}
@@ -381,10 +383,12 @@ public class CronetPerfTestActivity extends Activity {
mRemainingBytes = mLength;
}
+ @Override
public long getLength() {
return mLength;
}
+ @Override
public void read(UploadDataSink uploadDataSink, ByteBuffer byteBuffer) {
mBuffer.clear();
// Don't post more than |mLength|.
@@ -400,6 +404,7 @@ public class CronetPerfTestActivity extends Activity {
uploadDataSink.onReadSucceeded(false);
}
+ @Override
public void rewind(UploadDataSink uploadDataSink) {
uploadDataSink.onRewindError(new Exception("no rewinding"));
}
@@ -496,7 +501,7 @@ public class CronetPerfTestActivity extends Activity {
*/
public void run() {
final ExecutorService executor = Executors.newFixedThreadPool(mConcurrency);
- final List<Callable<Boolean>> tasks = new ArrayList<Callable<Boolean>>(mIterations);
+ final List<Callable<Boolean>> tasks = new ArrayList<>(mIterations);
startLogging();
// Prepare list of tasks to run.
switch (mMode) {
@@ -519,7 +524,7 @@ public class CronetPerfTestActivity extends Activity {
}
// Execute tasks.
boolean success = true;
- List<Future<Boolean>> futures = new ArrayList<Future<Boolean>>();
+ List<Future<Boolean>> futures = new ArrayList<>();
try {
startTimer();
// If possible execute directly to lessen impact of thread-pool overhead.
@@ -614,7 +619,9 @@ public class CronetPerfTestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this);
+ // Initializing application context here due to lack of custom CronetPerfTestApplication.
+ ContextUtils.initApplicationContext(getApplicationContext());
+ PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
mConfig = getIntent().getData();
// Execute benchmarks on another thread to avoid networking on main thread.
new BenchmarkTask().execute();

Powered by Google App Engine
This is Rietveld 408576698