From 17b7e709616d77cdb34302deea276ba514808b93 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 7 Jun 2013 10:20:59 -0700 Subject: [PATCH] Bug 880171 - Part 2: handle failure to retrieve storage from EnvironmentBuilder. r=nalexander --- .../base/health/BrowserHealthRecorder.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/health/BrowserHealthRecorder.java b/mobile/android/base/health/BrowserHealthRecorder.java index b640b207ec0..0c0bc7e9b15 100644 --- a/mobile/android/base/health/BrowserHealthRecorder.java +++ b/mobile/android/base/health/BrowserHealthRecorder.java @@ -84,9 +84,10 @@ public class BrowserHealthRecorder implements GeckoEventListener { private final AtomicBoolean orphanChecked = new AtomicBoolean(false); private volatile int env = -1; + + private ContentProviderClient client; private volatile HealthReportDatabaseStorage storage; private final ProfileInformationCache profileCache; - private ContentProviderClient client; private final EventDispatcher dispatcher; public static class SessionInformation { @@ -238,7 +239,12 @@ public class BrowserHealthRecorder implements GeckoEventListener { this.storage = EnvironmentBuilder.getStorage(this.client, profilePath); if (this.storage == null) { - throw new IllegalStateException("No storage in health recorder!"); + // Stick around even if we don't have storage: eventually we'll + // want to report total failures of FHR storage itself, and this + // way callers don't need to worry about whether their health + // recorder didn't initialize. + this.client.release(); + this.client = null; } this.profileCache = new ProfileInformationCache(profilePath); @@ -334,6 +340,10 @@ public class BrowserHealthRecorder implements GeckoEventListener { if (this.env != -1) { return this.env; } + if (this.storage == null) { + // Oh well. + return -1; + } return this.env = EnvironmentBuilder.registerCurrentEnvironment(this.storage, this.profileCache); } @@ -467,6 +477,9 @@ public class BrowserHealthRecorder implements GeckoEventListener { // Belt and braces. if (storage == null) { Log.w(LOG_TAG, "Storage is null during init; shutting down?"); + if (state == State.INITIALIZING) { + state = State.INITIALIZATION_FAILED; + } return; }