mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1021922 - Record telemetry for browser database operations. r=mfinkle
This commit is contained in:
parent
c7a1e3b298
commit
86c8096326
@ -5,24 +5,28 @@
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
class GlobalHistory {
|
||||
private static final String LOGTAG = "GeckoGlobalHistory";
|
||||
|
||||
private static GlobalHistory sInstance = new GlobalHistory();
|
||||
private static final String TELEMETRY_HISTOGRAM_ADD = "FENNEC_GLOBALHISTORY_ADD_MS";
|
||||
private static final String TELEMETRY_HISTOGRAM_UPDATE = "FENNEC_GLOBALHISTORY_UPDATE_MS";
|
||||
private static final String TELEMETRY_HISTOGRAM_BUILD_VISITED_LINK = "FENNEC_GLOBALHISTORY_VISITED_BUILD_MS";
|
||||
|
||||
private static final GlobalHistory sInstance = new GlobalHistory();
|
||||
|
||||
static GlobalHistory getInstance() {
|
||||
return sInstance;
|
||||
@ -48,35 +52,38 @@ class GlobalHistory {
|
||||
public void run() {
|
||||
Set<String> visitedSet = mVisitedCache.get();
|
||||
if (visitedSet == null) {
|
||||
// the cache was wiped away, repopulate it
|
||||
// The cache was wiped. Repopulate it.
|
||||
Log.w(LOGTAG, "Rebuilding visited link set...");
|
||||
visitedSet = new HashSet<String>();
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = BrowserDB.getAllVisitedHistory(GeckoAppShell.getContext().getContentResolver());
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
final Cursor c = BrowserDB.getAllVisitedHistory(GeckoAppShell.getContext().getContentResolver());
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
visitedSet = new HashSet<String>();
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
visitedSet.add(c.getString(0));
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
mVisitedCache = new SoftReference<Set<String>>(visitedSet);
|
||||
final long end = SystemClock.uptimeMillis();
|
||||
final long took = end - start;
|
||||
Telemetry.HistogramAdd(TELEMETRY_HISTOGRAM_BUILD_VISITED_LINK, (int) Math.min(took, Integer.MAX_VALUE));
|
||||
} finally {
|
||||
if (c != null)
|
||||
c.close();
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
// this runs on the same handler thread as the checkUriVisited code,
|
||||
// so no synchronization needed
|
||||
// This runs on the same handler thread as the checkUriVisited code,
|
||||
// so no synchronization is needed.
|
||||
while (true) {
|
||||
String uri = mPendingUris.poll();
|
||||
final String uri = mPendingUris.poll();
|
||||
if (uri == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (visitedSet.contains(uri)) {
|
||||
GeckoAppShell.notifyUriVisited(uri);
|
||||
}
|
||||
@ -95,12 +102,23 @@ class GlobalHistory {
|
||||
}
|
||||
|
||||
public void add(String uri) {
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
BrowserDB.updateVisitedHistory(GeckoAppShell.getContext().getContentResolver(), uri);
|
||||
final long end = SystemClock.uptimeMillis();
|
||||
final long took = end - start;
|
||||
Log.d(LOGTAG, "GlobalHistory.add took " + took + "msec.");
|
||||
Telemetry.HistogramAdd(TELEMETRY_HISTOGRAM_ADD, (int) Math.min(took, Integer.MAX_VALUE));
|
||||
addToGeckoOnly(uri);
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public void update(String uri, String title) {
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
BrowserDB.updateHistoryTitle(GeckoAppShell.getContext().getContentResolver(), uri, title);
|
||||
final long end = SystemClock.uptimeMillis();
|
||||
final long took = end - start;
|
||||
Log.d(LOGTAG, "GlobalHistory.update took " + took + "msec.");
|
||||
Telemetry.HistogramAdd(TELEMETRY_HISTOGRAM_UPDATE, (int) Math.min(took, Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
public void checkUriVisited(final String uri) {
|
||||
|
@ -5,20 +5,24 @@
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Encapsulates the implementation of the search cursor loader.
|
||||
*/
|
||||
class SearchLoader {
|
||||
// Key for search terms
|
||||
public static final String LOGTAG = "GeckoSearchLoader";
|
||||
|
||||
private static final String KEY_SEARCH_TERM = "search_term";
|
||||
|
||||
private SearchLoader() {
|
||||
@ -53,6 +57,8 @@ class SearchLoader {
|
||||
}
|
||||
|
||||
public static class SearchCursorLoader extends SimpleCursorLoader {
|
||||
private static final String TELEMETRY_HISTOGRAM_LOAD_CURSOR = "FENNEC_SEARCH_LOADER_TIME_MS";
|
||||
|
||||
// Max number of search results
|
||||
private static final int SEARCH_LIMIT = 100;
|
||||
|
||||
@ -66,7 +72,12 @@ class SearchLoader {
|
||||
|
||||
@Override
|
||||
public Cursor loadCursor() {
|
||||
return BrowserDB.filter(getContext().getContentResolver(), mSearchTerm, SEARCH_LIMIT);
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
final Cursor cursor = BrowserDB.filter(getContext().getContentResolver(), mSearchTerm, SEARCH_LIMIT);
|
||||
final long end = SystemClock.uptimeMillis();
|
||||
final long took = end - start;
|
||||
Telemetry.HistogramAdd(TELEMETRY_HISTOGRAM_LOAD_CURSOR, (int) Math.min(took, Integer.MAX_VALUE));
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public String getSearchTerm() {
|
||||
|
@ -31,9 +31,9 @@ import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
@ -430,8 +430,9 @@ public class TopSitesPanel extends HomeFragment {
|
||||
}
|
||||
|
||||
private static class TopSitesLoader extends SimpleCursorLoader {
|
||||
// Max number of search results
|
||||
// Max number of search results.
|
||||
private static final int SEARCH_LIMIT = 30;
|
||||
private static final String TELEMETRY_HISTOGRAM_LOAD_CURSOR = "FENNEC_TOPSITES_LOADER_TIME_MS";
|
||||
private int mMaxGridEntries;
|
||||
|
||||
public TopSitesLoader(Context context) {
|
||||
@ -441,8 +442,12 @@ public class TopSitesPanel extends HomeFragment {
|
||||
|
||||
@Override
|
||||
public Cursor loadCursor() {
|
||||
trace("TopSitesLoader.loadCursor()");
|
||||
return BrowserDB.getTopSites(getContext().getContentResolver(), mMaxGridEntries, SEARCH_LIMIT);
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
final Cursor cursor = BrowserDB.getTopSites(getContext().getContentResolver(), mMaxGridEntries, SEARCH_LIMIT);
|
||||
final long end = SystemClock.uptimeMillis();
|
||||
final long took = end - start;
|
||||
Telemetry.HistogramAdd(TELEMETRY_HISTOGRAM_LOAD_CURSOR, (int) Math.min(took, Integer.MAX_VALUE));
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4281,13 +4281,31 @@
|
||||
"description": "Number of history entries in the original XUL places database",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_AWESOMEBAR_ALLPAGES_EMPTY_TIME": {
|
||||
"FENNEC_GLOBALHISTORY_ADD_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"low": 10,
|
||||
"high": "20000",
|
||||
"n_buckets": 20,
|
||||
"description": "Fennec: Time for the Awesomebar Top Sites query to return with no filter set (ms)",
|
||||
"description": "Time for a record to be added to history (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_GLOBALHISTORY_UPDATE_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"low": 10,
|
||||
"high": "20000",
|
||||
"n_buckets": 20,
|
||||
"description": "Time for a record to be updated in history (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_GLOBALHISTORY_VISITED_BUILD_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"low": 10,
|
||||
"high": "20000",
|
||||
"n_buckets": 20,
|
||||
"description": "Time to update the visited link set (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_LOWMEM_TAB_COUNT": {
|
||||
@ -4304,13 +4322,20 @@
|
||||
"description": "Fennec is starting up but the Gecko thread was still running",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_STARTUP_TIME_JAVAUI": {
|
||||
"FENNEC_SEARCH_LOADER_TIME_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"low": 100,
|
||||
"high": "5000",
|
||||
"low": 10,
|
||||
"high": "20000",
|
||||
"n_buckets": 20,
|
||||
"description": "Time for the Java UI to load (ms)",
|
||||
"description": "Time for a URL bar DB search to return (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_STARTUP_GECKOAPP_ACTION": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
"n_values": 4,
|
||||
"description": "The way the GeckoApp was launched. (Normal, URL, Prefetch, Redirector)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_STARTUP_TIME_ABOUTHOME": {
|
||||
@ -4331,11 +4356,13 @@
|
||||
"description": "Time for the Gecko:Ready message to arrive (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_STARTUP_GECKOAPP_ACTION": {
|
||||
"FENNEC_STARTUP_TIME_JAVAUI": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
"n_values": 4,
|
||||
"description": "The way the GeckoApp was launched. (Normal, URL, Prefetch, Redirector)",
|
||||
"kind": "exponential",
|
||||
"low": 100,
|
||||
"high": "5000",
|
||||
"n_buckets": 20,
|
||||
"description": "Time for the Java UI to load (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_TAB_EXPIRED": {
|
||||
@ -4358,6 +4385,15 @@
|
||||
"description": "How long (in seconds) a tab was inactive when it was OOM-zombified",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_TOPSITES_LOADER_TIME_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"low": 10,
|
||||
"high": "20000",
|
||||
"n_buckets": 20,
|
||||
"description": "Time for the home screen Top Sites query to return with no filter set (ms)",
|
||||
"cpp_guard": "ANDROID"
|
||||
},
|
||||
"FENNEC_WAS_KILLED": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "flag",
|
||||
|
Loading…
Reference in New Issue
Block a user