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

Unified Diff: base/android/java/src/org/chromium/base/ResourceExtractor.java

Issue 2164483007: android: Move ResourceExtractor tracing to TraceEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/ResourceExtractor.java
diff --git a/base/android/java/src/org/chromium/base/ResourceExtractor.java b/base/android/java/src/org/chromium/base/ResourceExtractor.java
index 2854b02dd41d514d87dbafd9ccab7c09aa2cf803..32233ad486277899dde6f051cd5d9975414037c4 100644
--- a/base/android/java/src/org/chromium/base/ResourceExtractor.java
+++ b/base/android/java/src/org/chromium/base/ResourceExtractor.java
@@ -4,16 +4,13 @@
package org.chromium.base;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
-import android.os.Build;
import android.os.Handler;
import android.os.Looper;
-import android.os.Trace;
import org.chromium.base.annotations.SuppressFBWarnings;
@@ -92,12 +89,12 @@ public class ResourceExtractor {
return;
}
- beginTraceSection("checkPakTimeStamp");
+ TraceEvent.begin("checkPakTimeStamp");
long curAppVersion = getApkVersion();
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
long prevAppVersion = sharedPrefs.getLong(APP_VERSION_PREF, 0);
boolean versionChanged = curAppVersion != prevAppVersion;
- endTraceSection();
+ TraceEvent.end("checkPakTimeStamp");
if (versionChanged) {
deleteFiles();
@@ -107,7 +104,7 @@ public class ResourceExtractor {
sharedPrefs.edit().putLong(APP_VERSION_PREF, curAppVersion).apply();
}
- beginTraceSection("WalkAssets");
+ TraceEvent.begin("WalkAssets");
byte[] buffer = new byte[BUFFER_SIZE];
try {
for (ResourceEntry entry : sResourcesToExtract) {
@@ -117,13 +114,13 @@ public class ResourceExtractor {
if (output.length() != 0) {
continue;
}
- beginTraceSection("ExtractResource");
+ TraceEvent.begin("ExtractResource");
InputStream inputStream = mContext.getResources().openRawResource(
entry.resourceId);
try {
extractResourceHelper(inputStream, output, buffer);
} finally {
- endTraceSection(); // ExtractResource
+ TraceEvent.end("ExtractResource");
}
}
} catch (IOException e) {
@@ -135,21 +132,17 @@ public class ResourceExtractor {
deleteFiles();
return;
} finally {
- endTraceSection(); // WalkAssets
+ TraceEvent.end("WalkAssets");
}
}
@Override
protected Void doInBackground(Void... unused) {
- // TODO(lizeb): Use chrome tracing here (and above in
- // doInBackgroundImpl) when it will be possible. This is currently
- // not doable since the native library is not loaded yet, and the
- // TraceEvent calls are dropped before this point.
- beginTraceSection("ResourceExtractor.ExtractTask.doInBackground");
+ TraceEvent.begin("ResourceExtractor.ExtractTask.doInBackground");
try {
doInBackgroundImpl();
} finally {
- endTraceSection();
+ TraceEvent.end("ResourceExtractor.ExtractTask.doInBackground");
}
return null;
}
@@ -163,11 +156,11 @@ public class ResourceExtractor {
@Override
protected void onPostExecute(Void result) {
- beginTraceSection("ResourceExtractor.ExtractTask.onPostExecute");
+ TraceEvent.begin("ResourceExtractor.ExtractTask.onPostExecute");
try {
onPostExecuteImpl();
} finally {
- endTraceSection();
+ TraceEvent.end("ResourceExtractor.ExtractTask.onPostExecute");
}
}
@@ -182,18 +175,6 @@ public class ResourceExtractor {
throw new RuntimeException(e);
}
}
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
- private void beginTraceSection(String section) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return;
- Trace.beginSection(section);
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
- private void endTraceSection() {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return;
- Trace.endSection();
- }
}
private final Context mContext;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698