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

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

Issue 2528073002: Add a flag in WebAPK's proto when the Web App Manifest is no longer available. (Closed)
Patch Set: Try to fix the compile error. Created 4 years 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/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 66c0bc540a1892dd807aa5024aab2ec9daed021d..2d801bc399fcb82f8cc93cd4b6949c9c1bcdf77f 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;
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);
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);
}
/**
@@ -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) {
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);
}
/**
@@ -316,7 +326,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);
}

Powered by Google App Engine
This is Rietveld 408576698