mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 875151 - Shutdown/startup race in BrowserHealthRecorder. r=nalexander
This commit is contained in:
parent
2eac6fb615
commit
3d3929ab7c
@ -66,9 +66,9 @@ public class BrowserHealthRecorder implements GeckoEventListener {
|
||||
protected volatile State state = State.NOT_INITIALIZED;
|
||||
|
||||
private volatile int env = -1;
|
||||
private HealthReportDatabaseStorage storage;
|
||||
private volatile HealthReportDatabaseStorage storage;
|
||||
private final ProfileInformationCache profileCache;
|
||||
private ContentProviderClient client;
|
||||
private ProfileInformationCache profileCache;
|
||||
|
||||
/**
|
||||
* Persist the opaque identifier for the current Firefox Health Report environment.
|
||||
@ -278,9 +278,9 @@ public class BrowserHealthRecorder implements GeckoEventListener {
|
||||
/**
|
||||
* Add provider-specific initialization in this method.
|
||||
*/
|
||||
private void initialize(final Context context,
|
||||
final String profilePath,
|
||||
final EventDispatcher dispatcher)
|
||||
private synchronized void initialize(final Context context,
|
||||
final String profilePath,
|
||||
final EventDispatcher dispatcher)
|
||||
throws java.io.IOException {
|
||||
|
||||
Log.d(LOG_TAG, "Initializing profile cache.");
|
||||
@ -289,6 +289,8 @@ public class BrowserHealthRecorder implements GeckoEventListener {
|
||||
|
||||
this.profileCache.setProfileCreationTime(getAndPersistProfileInitTime(context, profilePath));
|
||||
|
||||
final BrowserHealthRecorder self = this;
|
||||
|
||||
PrefHandler handler = new PrefsHelper.PrefHandlerBase() {
|
||||
@Override
|
||||
public void prefValue(String pref, boolean value) {
|
||||
@ -318,27 +320,40 @@ public class BrowserHealthRecorder implements GeckoEventListener {
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
storage.beginInitialization();
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Failed to init storage.", e);
|
||||
state = State.INITIALIZATION_FAILED;
|
||||
return;
|
||||
}
|
||||
synchronized (self) {
|
||||
if (state != State.INITIALIZING) {
|
||||
Log.w(LOG_TAG, "Unexpected state during init: " + state);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Initialize each provider here.
|
||||
// Belt and braces.
|
||||
if (storage == null) {
|
||||
Log.w(LOG_TAG, "Storage is null during init; shutting down?");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(LOG_TAG, "Ensuring environment.");
|
||||
ensureEnvironment();
|
||||
try {
|
||||
storage.beginInitialization();
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Failed to init storage.", e);
|
||||
state = State.INITIALIZATION_FAILED;
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(LOG_TAG, "Finishing init.");
|
||||
storage.finishInitialization();
|
||||
state = State.INITIALIZED;
|
||||
} catch (Exception e) {
|
||||
state = State.INITIALIZATION_FAILED;
|
||||
storage.abortInitialization();
|
||||
Log.e(LOG_TAG, "Initialization failed.", e);
|
||||
try {
|
||||
// Initialize each provider here.
|
||||
|
||||
Log.d(LOG_TAG, "Ensuring environment.");
|
||||
ensureEnvironment();
|
||||
|
||||
Log.d(LOG_TAG, "Finishing init.");
|
||||
storage.finishInitialization();
|
||||
state = State.INITIALIZED;
|
||||
} catch (Exception e) {
|
||||
state = State.INITIALIZATION_FAILED;
|
||||
storage.abortInitialization();
|
||||
Log.e(LOG_TAG, "Initialization failed.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user