| Index: chrome/android/java/src/org/chromium/chrome/browser/tab/TabIdManager.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabIdManager.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabIdManager.java
|
| index 30113b1e2c6141a9e83b5a1873847271dfa0be89..4ccdf7cef0c3062dfc1bfef78c219a9814457463 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabIdManager.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabIdManager.java
|
| @@ -10,6 +10,7 @@ import android.preference.PreferenceManager;
|
|
|
| import org.chromium.base.ApplicationStatus;
|
| import org.chromium.base.VisibleForTesting;
|
| +import org.chromium.chrome.browser.tabmodel.TabModel;
|
|
|
| import java.util.concurrent.atomic.AtomicInteger;
|
|
|
| @@ -38,6 +39,8 @@ public class TabIdManager {
|
| private final Context mContext;
|
| private final AtomicInteger mIdCounter = new AtomicInteger();
|
|
|
| + private SharedPreferences mPreferences;
|
| +
|
| /** Returns the Singleton instance of the TabIdManager. */
|
| public static TabIdManager getInstance() {
|
| return getInstance(ApplicationStatus.getApplicationContext());
|
| @@ -80,14 +83,7 @@ public class TabIdManager {
|
| // It's possible idCounter has been incremented between the get and the add but that's OK --
|
| // in the worst case mIdCounter will just be overly incremented.
|
| mIdCounter.addAndGet(diff);
|
| - updateSharedPreference();
|
| - }
|
| -
|
| - private void updateSharedPreference() {
|
| - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
| - SharedPreferences.Editor editor = prefs.edit();
|
| - editor.putInt(PREF_NEXT_ID, mIdCounter.get());
|
| - editor.apply();
|
| + mPreferences.edit().putInt(PREF_NEXT_ID, mIdCounter.get()).apply();
|
| }
|
|
|
| private TabIdManager(Context context) {
|
| @@ -96,7 +92,7 @@ public class TabIdManager {
|
| // Read the shared preference. This has to be done on the critical path to ensure that the
|
| // myriad Activities that serve as entries into Chrome are all synchronized on the correct
|
| // maximum Tab ID.
|
| - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
| - mIdCounter.set(prefs.getInt(PREF_NEXT_ID, 0));
|
| + mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
| + mIdCounter.set(mPreferences.getInt(PREF_NEXT_ID, 0));
|
| }
|
| }
|
|
|