Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeBackupAgent.java

Issue 2124583003: Replace Shared Prefs commit with apply. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix merge conflict. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeBackupAgent.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackupAgent.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackupAgent.java
index 9f9a80abbe01b9ec4e462a53ce282209520f8630..7bcb0b3b97e240e317e022eac903eafb85335344 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackupAgent.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeBackupAgent.java
@@ -6,6 +6,7 @@ package org.chromium.chrome.browser;
import android.accounts.Account;
import android.accounts.AccountManager;
+import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.backup.BackupAgent;
import android.app.backup.BackupDataInput;
@@ -187,12 +188,16 @@ public class ChromeBackupAgent extends BackupAgent {
Log.d(TAG, "onRestoreFinished complete");
}
+ @SuppressLint("CommitPrefEdits")
private void clearAllPrefs(SharedPreferences sharedPrefs, File prefsFile) {
deleteFileIfPossible(prefsFile);
+ // Android restore closes down the process immediately, so we want to make sure that the
+ // prefs changes are committed to disk before exiting.
sharedPrefs.edit().clear().commit();
}
- private boolean restoreAndroidPrefs(SharedPreferences sharedPrefs, String userName) {
+ @SuppressLint("CommitPrefEdits")
+ private void restoreAndroidPrefs(SharedPreferences sharedPrefs, String userName) {
Set<String> prefNames = sharedPrefs.getAll().keySet();
SharedPreferences.Editor editor = sharedPrefs.edit();
// Throw away prefs we don't want to restore.
@@ -204,8 +209,9 @@ public class ChromeBackupAgent extends BackupAgent {
// will sign in the user on first run to the account in FIRST_RUN_FLOW_SIGNIN_ACCOUNT_NAME
// if any. If the rest of FRE has been completed this will happen silently.
editor.putString(FirstRunSignInProcessor.FIRST_RUN_FLOW_SIGNIN_ACCOUNT_NAME, userName);
- boolean commitResult = editor.commit();
- return commitResult;
+ // Android restore closes down the process immediately, so we want to make sure that the
+ // prefs changes are committed to disk before exiting.
+ editor.commit();
}
private boolean filterChromePrefs(File prefsFile) {
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698