mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1042951 - Part 2: allow for delayed recording of searches with FHR. r=margaret
This commit is contained in:
parent
a6f8911b76
commit
6d7da5da76
@ -1910,6 +1910,7 @@ public abstract class GeckoApp
|
||||
final HealthRecorder rec = mHealthRecorder;
|
||||
if (rec != null) {
|
||||
rec.setCurrentSession(currentSession);
|
||||
rec.processDelayed();
|
||||
} else {
|
||||
Log.w(LOGTAG, "Can't record session: rec is null.");
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -899,4 +900,42 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
|
||||
// double-counted on next run.
|
||||
session.recordCompletion(editor);
|
||||
}
|
||||
|
||||
private static class Search {
|
||||
public final String location;
|
||||
public final String engineID;
|
||||
|
||||
public Search(final String location, final String engineID) {
|
||||
if (!SEARCH_LOCATIONS.contains(location)) {
|
||||
throw new IllegalArgumentException("Unknown search location: " + location);
|
||||
}
|
||||
|
||||
this.location = location;
|
||||
this.engineID = engineID;
|
||||
}
|
||||
}
|
||||
|
||||
private static ConcurrentLinkedQueue<Search> delayedSearches = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void recordSearchDelayed(String location, String engineID) {
|
||||
final Search search = new Search(location, engineID);
|
||||
delayedSearches.add(search);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processDelayed() {
|
||||
if (delayedSearches.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state != State.INITIALIZED) {
|
||||
Log.d(LOG_TAG, "Not initialized: not processing delayed items. (" + this.state + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
Search poll;
|
||||
while ((poll = delayedSearches.poll()) != null) {
|
||||
recordSearch(poll.engineID, poll.location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,6 @@ public interface HealthRecorder {
|
||||
public void onEnvironmentChanged(final boolean startNewSession, final String sessionEndReason);
|
||||
|
||||
public void close();
|
||||
|
||||
public void processDelayed();
|
||||
}
|
||||
|
@ -32,4 +32,7 @@ public class StubbedHealthRecorder implements HealthRecorder {
|
||||
public void onEnvironmentChanged(final boolean startNewSession, final String sessionEndReason) { }
|
||||
|
||||
public void close() { }
|
||||
|
||||
@Override
|
||||
public void processDelayed() { }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user