Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| index f492fdfbf072222f1e799595a744d27c148f4e7a..286b75575be66c86985a256dcaa9df9d83206137 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
| @@ -21,6 +21,7 @@ import org.chromium.chrome.browser.util.UrlUtilities; |
| import org.chromium.webapk.lib.client.WebApkVersion; |
| import java.util.Map; |
| +import java.util.Map.Entry; |
|
dominickn
2016/12/20 05:05:48
Minor nit: I would just use Map.Entry rather than
Xi Han
2016/12/20 20:25:08
I would like to, but the compiler complains if I r
dominickn
2016/12/21 02:51:49
I meant, only import java.util.Map, and don't impo
Xi Han
2016/12/21 22:45:44
I see. Updated!
|
| import java.util.concurrent.TimeUnit; |
| /** |
| @@ -116,13 +117,14 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| recordUpdate(storage, false); |
| if (fetchedInfo != null) { |
| - updateAsync(fetchedInfo, bestIconUrl); |
| + updateAsync(fetchedInfo, bestIconUrl, false); |
|
dominickn
2016/12/20 05:05:48
A useful pattern I've recently learned is
updateA
Xi Han
2016/12/20 20:25:08
Acknowledged.
|
| return; |
| } |
| - // Since we could not fetch the Web Manifest, we do not know what the best icon URL is. Pass |
| - // an empty "best icon URL" to tell the server that there is no best icon URL. |
| - updateAsync(mInfo, ""); |
| + // Tell the server that the our version of the Web Manifest might be stale and to ignore |
| + // our Web Manifest data if the server's Web Manifest data is newer. This scenario can |
| + // occur if the Web Manifest is temporarily unreachable. |
| + updateAsync(mInfo, "", true); |
|
dominickn
2016/12/20 05:05:48
true /* isManifestStale */)
Xi Han
2016/12/20 20:25:08
Acknowledged.
|
| } |
| /** |
| @@ -135,14 +137,22 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| /** |
| * Sends request to WebAPK Server to update WebAPK. |
| */ |
| - protected void updateAsync(WebApkInfo info, String bestIconUrl) { |
| + protected void updateAsync(WebApkInfo info, String bestIconUrl, boolean staleManifest) { |
|
dominickn
2016/12/20 05:05:48
Call this variable isManifestStale so make it more
Xi Han
2016/12/20 20:25:08
Done.
|
| int versionCode = readVersionCodeFromAndroidManifest(info.webApkPackageName()); |
| - String bestIconMurmur2Hash = info.iconUrlToMurmur2HashMap().get(bestIconUrl); |
| + int size = info.iconUrlToMurmur2HashMap().size(); |
| + String[] iconUrls = new String[size]; |
| + String[] iconHashes = new String[size]; |
| + int i = 0; |
| + for (Entry<String, String> entry : info.iconUrlToMurmur2HashMap().entrySet()) { |
| + iconUrls[i] = entry.getKey(); |
| + String iconHash = entry.getValue(); |
| + iconHashes[i] = iconHash != null ? iconHash : ""; |
| + i++; |
| + } |
| nativeUpdateAsync(info.id(), info.manifestStartUrl(), info.scopeUri().toString(), |
| - info.name(), info.shortName(), bestIconUrl, bestIconMurmur2Hash, info.icon(), |
| - info.iconUrlToMurmur2HashMap().keySet().toArray(new String[0]), info.displayMode(), |
| - info.orientation(), info.themeColor(), info.backgroundColor(), info.manifestUrl(), |
| - info.webApkPackageName(), versionCode); |
| + info.name(), info.shortName(), bestIconUrl, info.icon(), iconUrls, iconHashes, |
| + info.displayMode(), info.orientation(), info.themeColor(), info.backgroundColor(), |
| + info.manifestUrl(), info.webApkPackageName(), versionCode, staleManifest); |
| } |
| /** |
| @@ -310,7 +320,8 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| } |
| private static native void nativeUpdateAsync(String id, String startUrl, String scope, |
| - String name, String shortName, String bestIconUrl, String bestIconMurmur2Hash, |
| - Bitmap bestIcon, String[] iconUrls, int displayMode, int orientation, long themeColor, |
| - long backgroundColor, String manifestUrl, String webApkPackage, int webApkVersion); |
| + String name, String shortName, String bestIconUrl, Bitmap bestIcon, String[] iconUrls, |
| + String[] iconHashes, int displayMode, int orientation, long themeColor, |
| + long backgroundColor, String manifestUrl, String webApkPackage, int webApkVersion, |
| + boolean staleManifest); |
|
dominickn
2016/12/20 05:05:48
isManifestStale
Xi Han
2016/12/20 20:25:08
Done.
|
| } |