Commit af547481 authored by hayesjordan's avatar hayesjordan Committed by Commit bot

Use LibraryLoader to check for native library

BUG=636490

Review-Url: https://codereview.chromium.org/2370943003
Cr-Commit-Position: refs/heads/master@{#422686}
parent f90d946c
...@@ -10,6 +10,7 @@ import android.os.AsyncTask; ...@@ -10,6 +10,7 @@ import android.os.AsyncTask;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.components.location.LocationUtils; import org.chromium.components.location.LocationUtils;
...@@ -64,7 +65,6 @@ public class PhysicalWebUma { ...@@ -64,7 +65,6 @@ public class PhysicalWebUma {
private static final String PREFERENCE = "Preference"; private static final String PREFERENCE = "Preference";
private static final int BOOLEAN_BOUNDARY = 2; private static final int BOOLEAN_BOUNDARY = 2;
private static final int TRISTATE_BOUNDARY = 3; private static final int TRISTATE_BOUNDARY = 3;
private static boolean sUploadAllowed = false;
/** /**
* Records a URL selection. * Records a URL selection.
...@@ -169,7 +169,7 @@ public class PhysicalWebUma { ...@@ -169,7 +169,7 @@ public class PhysicalWebUma {
* @param numUrls The number of URLs displayed to a user. * @param numUrls The number of URLs displayed to a user.
*/ */
public static void onUrlsDisplayed(Context context, int numUrls) { public static void onUrlsDisplayed(Context context, int numUrls) {
if (sUploadAllowed) { if (LibraryLoader.isInitialized()) {
RecordHistogram.recordCountHistogram(TOTAL_URLS_INITIAL_COUNTS, numUrls); RecordHistogram.recordCountHistogram(TOTAL_URLS_INITIAL_COUNTS, numUrls);
} else { } else {
storeValue(context, TOTAL_URLS_INITIAL_COUNTS, numUrls); storeValue(context, TOTAL_URLS_INITIAL_COUNTS, numUrls);
...@@ -181,7 +181,7 @@ public class PhysicalWebUma { ...@@ -181,7 +181,7 @@ public class PhysicalWebUma {
* @param numUrls The number of URLs displayed to a user. * @param numUrls The number of URLs displayed to a user.
*/ */
public static void onUrlsRefreshed(Context context, int numUrls) { public static void onUrlsRefreshed(Context context, int numUrls) {
if (sUploadAllowed) { if (LibraryLoader.isInitialized()) {
RecordHistogram.recordCountHistogram(TOTAL_URLS_REFRESH_COUNTS, numUrls); RecordHistogram.recordCountHistogram(TOTAL_URLS_REFRESH_COUNTS, numUrls);
} else { } else {
storeValue(context, TOTAL_URLS_REFRESH_COUNTS, numUrls); storeValue(context, TOTAL_URLS_REFRESH_COUNTS, numUrls);
...@@ -246,13 +246,8 @@ public class PhysicalWebUma { ...@@ -246,13 +246,8 @@ public class PhysicalWebUma {
/** /**
* Uploads metrics that we have deferred for uploading. * Uploads metrics that we have deferred for uploading.
* Additionally, this method will cause future stat records not to be deferred and instead
* uploaded immediately.
*/ */
public static void uploadDeferredMetrics() { public static void uploadDeferredMetrics() {
// If uploads have been explicitely requested, they are now allowed.
sUploadAllowed = true;
// Read the metrics. // Read the metrics.
SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
if (prefs.getBoolean(HAS_DEFERRED_METRICS_KEY, false)) { if (prefs.getBoolean(HAS_DEFERRED_METRICS_KEY, false)) {
...@@ -293,7 +288,7 @@ public class PhysicalWebUma { ...@@ -293,7 +288,7 @@ public class PhysicalWebUma {
} }
private static void handleAction(Context context, String key) { private static void handleAction(Context context, String key) {
if (sUploadAllowed) { if (LibraryLoader.isInitialized()) {
RecordUserAction.record(key); RecordUserAction.record(key);
} else { } else {
storeAction(context, key); storeAction(context, key);
...@@ -301,7 +296,7 @@ public class PhysicalWebUma { ...@@ -301,7 +296,7 @@ public class PhysicalWebUma {
} }
private static void handleTime(Context context, String key, long duration, TimeUnit tu) { private static void handleTime(Context context, String key, long duration, TimeUnit tu) {
if (sUploadAllowed) { if (LibraryLoader.isInitialized()) {
RecordHistogram.recordTimesHistogram(key, duration, tu); RecordHistogram.recordTimesHistogram(key, duration, tu);
} else { } else {
storeValue(context, key, duration); storeValue(context, key, duration);
...@@ -309,7 +304,7 @@ public class PhysicalWebUma { ...@@ -309,7 +304,7 @@ public class PhysicalWebUma {
} }
private static void handleEnum(Context context, String key, int value, int boundary) { private static void handleEnum(Context context, String key, int value, int boundary) {
if (sUploadAllowed) { if (LibraryLoader.isInitialized()) {
RecordHistogram.recordEnumeratedHistogram(key, value, boundary); RecordHistogram.recordEnumeratedHistogram(key, value, boundary);
} else { } else {
storeValue(context, key, value); storeValue(context, key, value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment