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

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

Issue 2879853003: [Payments] Code Refactoring for the Subkey Request (Closed)
Patch Set: Final nit Created 3 years, 7 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
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
index aaaad4a92e795c7d4069721fd0797b81ba760cac..8c843ce9150ed66a8f72b3146d7035c6bf032303 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
@@ -335,40 +335,20 @@ public class AddressEditor
/** Requests the list of admin areas. */
private void loadAdminAreasForCountry(String countryCode) {
- // Used to check if the callback is called (for time-out).
+ // Used to check if the callback is called (for the cancellation).
mAdminAreasLoaded = false;
- onAdminAreasLoading();
- // In each rule, admin area keys are saved under sub-keys of country.
- PersonalDataManager.getInstance().loadRulesForSubKeys(countryCode);
- PersonalDataManager.getInstance().getRegionSubKeys(countryCode, this);
- }
-
- /** Cancels the request for the list of admin areas. */
- private void cancelAdminAreasRequest() {
- if (mAdminAreasLoaded) return;
- onSubKeysReceived(null);
- PersonalDataManager.getInstance().cancelPendingGetSubKeys();
- }
-
- /**
- * In case the the admin areas are not loaded yet, or the time out is set to 0 for testing,
- * starts a timer to cancel the request.
- */
- public void onAdminAreasLoading() {
- if (mAdminAreasLoaded) return;
- // Handler().postDelayed sometimes adds an additional delay to the time-out,
- // therefore the case for time-out == 0 is checked initially.
+ // For tests, the time-out is set to 0. In this case, we should not
+ // fetch the admin-areas, and show a text-field instead.
+ // This is to have the tests independent of the network status.
if (PersonalDataManager.getInstance().getRequestTimeoutMS() == 0) {
- cancelAdminAreasRequest();
+ onSubKeysReceived(null);
return;
}
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- cancelAdminAreasRequest();
- }
- }, PersonalDataManager.getInstance().getRequestTimeoutMS());
+
+ // In each rule, admin area keys are saved under sub-keys of country.
+ PersonalDataManager.getInstance().loadRulesForSubKeys(countryCode);
+ PersonalDataManager.getInstance().getRegionSubKeys(countryCode, this);
}
/**

Powered by Google App Engine
This is Rietveld 408576698