mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
Bug 753175 - Race condition in Sync Migration / Preference:Get. r=gcp
This commit is contained in:
parent
0e6b28c1e9
commit
84849ba27c
@ -518,7 +518,12 @@ public class ProfileMigrator {
|
||||
// This includes personal info, so don't log.
|
||||
// Log.d(LOGTAG, "Message: " + message.toString());
|
||||
JSONArray jsonPrefs = message.getJSONArray("preferences");
|
||||
parsePrefs(jsonPrefs);
|
||||
|
||||
// Check that the batch of preferences we got notified of are in
|
||||
// the ones we requested and not those requested by other java code.
|
||||
if (!parsePrefs(jsonPrefs))
|
||||
return;
|
||||
|
||||
GeckoAppShell.unregisterGeckoEventListener("Preferences:Data",
|
||||
(GeckoEventListener)this);
|
||||
|
||||
@ -576,12 +581,18 @@ public class ProfileMigrator {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void parsePrefs(JSONArray jsonPrefs) {
|
||||
// Returns true if we sucessfully got the preferences we requested.
|
||||
protected boolean parsePrefs(JSONArray jsonPrefs) {
|
||||
try {
|
||||
final int length = jsonPrefs.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
JSONObject jPref = jsonPrefs.getJSONObject(i);
|
||||
final String prefName = jPref.getString("name");
|
||||
|
||||
// Check to make sure we're working with preferences we requested.
|
||||
if (!mSyncSettingsList.contains(prefName))
|
||||
return false;
|
||||
|
||||
final String prefType = jPref.getString("type");
|
||||
if ("bool".equals(prefType)) {
|
||||
final boolean value = jPref.getBoolean("value");
|
||||
@ -599,7 +610,10 @@ public class ProfileMigrator {
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "Exception handling preferences answer: "
|
||||
+ e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void configureSync() {
|
||||
|
Loading…
Reference in New Issue
Block a user