Bug 960709 - Part 4: Use HealthRecorder.isEnabled to make StubbedHealthRecorder use more efficient. r=rnewman

This commit is contained in:
Michael Comella 2014-02-04 19:41:29 -08:00
parent fb2e5f4267
commit b7f35a03cb
5 changed files with 14 additions and 3 deletions

View File

@ -2594,7 +2594,7 @@ abstract public class BrowserApp extends GeckoApp
final EventDispatcher dispatcher,
final String osLocale,
final String appLocale,
SessionInformation previousSession) {
final SessionInformation previousSession) {
return new BrowserHealthRecorder(context,
profilePath,
dispatcher,

View File

@ -2117,7 +2117,7 @@ public abstract class GeckoApp
final HealthRecorder rec = mHealthRecorder;
mHealthRecorder = null;
if (rec != null) {
if (rec != null && rec.isEnabled()) {
// Closing a BrowserHealthRecorder could incur a write.
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
@ -2834,7 +2834,7 @@ public abstract class GeckoApp
final EventDispatcher dispatcher,
final String osLocale,
final String appLocale,
SessionInformation previousSession) {
final SessionInformation previousSession) {
// GeckoApp does not need to record any health information - return a stub.
return new StubbedHealthRecorder();
}

View File

@ -168,6 +168,10 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
}
}
public boolean isEnabled() {
return true;
}
/**
* Shut down database connections, unregister event listeners, and perform
* provider-specific uninitialization.

View File

@ -13,6 +13,11 @@ import org.json.JSONObject;
* HealthRecorder is an interface into the Firefox Health Report storage system.
*/
public interface HealthRecorder {
/**
* Returns whether the Health Recorder is actively recording events.
*/
public boolean isEnabled();
public void setCurrentSession(SessionInformation session);
public void checkForOrphanSessions();

View File

@ -14,6 +14,8 @@ import org.json.JSONObject;
* nothing.
*/
public class StubbedHealthRecorder implements HealthRecorder {
public boolean isEnabled() { return false; }
public void setCurrentSession(SessionInformation session) { }
public void checkForOrphanSessions() { }