|
|
Chromium Code Reviews
DescriptionSend all of the icon URLs listed in Web Manifest to WebAPK Server.
So far, Chrome only sends the best icon URL to WebAPK Minter Server to
create/install WebAPKs. However, in the multiple icon world, it isn't correct
to still keep the "best icon URL" and the "best icon hash" in
AndroidManifest.xml. This is because the best icon URL will be different for
devices with different resolution. For example, a nexus 5 and an Android one
device will have different best icon URL. To prevent creating a WebAPK for
a device with a wrong baked metadata, the "best icon URL" and "best Icon
Hash" are removed from the metadata. Instead, all of the icon URLs, as well
as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs
and Hashes are stored as a space separated single <meta-data> tag, as:
"URL1 hash1 URL2 hash2 URL3 hash3..."
Another change in this CL is to send all the icon URLs to the server, since
the server wants to check if any of these icon URLs changed before starting
a fetch of the raw icon data.
Some behavior changes are involved:
1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best
icon hash + best icon raw image) to the Server. The reason to still send the best
icon is for one-off WebAPKs which use the image from Chrome, since server will fail
to fetch any of them. Server generates all the icon Hashs and bakes them in the
WebAPK's metadata in AndroidManifest.xml.
2) When checking updates, Chrome compute the best icon URL and hash when fetching
the Web Manifest, and compare the new computed hash with the one backed in
the metadata to see whether the image is updated.
The icon URL and icon Hash pairs are stored in a map in WebApkMetaData.
BUG=627593
Committed: https://crrev.com/75ca9beb7e7fcd03feb23bb1e246be3ff5de6b6e
Cr-Commit-Position: refs/heads/master@{#433215}
Patch Set 1 #
Total comments: 48
Patch Set 2 : Remove best_icon_url and best_icon_hash from metadata, but add all icon urls and icon hashs in. #
Total comments: 60
Patch Set 3 : pkotwicz@'s comments. #
Total comments: 28
Patch Set 4 : Store icon Urls and murmur2 hashes in one single metadata tag. #
Total comments: 8
Patch Set 5 : use space to separate icon_url and icon_hash. #
Total comments: 22
Patch Set 6 : dominickn@'s comments. #Patch Set 7 : Remove icon urls comparison when checking updates. #
Total comments: 10
Patch Set 8 : Use String[] for icon urls. #
Total comments: 6
Patch Set 9 : Nits. #Messages
Total messages: 73 (51 generated)
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. Chrome only sends the best icon url to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, the icon urls are added to ShortcutInfo, so they can be sent to the WebAPK server. These icon URLs are stored as a <meta-data> tag in the WebAPK's AndroidManifest.xml. Besides, the change of the icon URLs will request an update for the WebAPK. BUG=627593 ==========
The CQ bit was checked by hanxi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_clang_dbg_recipe on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_clan...) android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...) cast_shell_android on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/cast_shell_a...) linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by hanxi@chromium.org to run a CQ dry run
Patchset #2 (id:20001) has been deleted
Patchset #1 (id:1) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
hanxi@chromium.org changed reviewers: + pkotwicz@chromium.org
Hi Peter, could you please take a look? Thanks!
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Nits and a few comments for follow up CLs https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:156: fetchedData.iconUrls = new HashSet<String>(); Nit: Use org.chromium.base.CollectionUtil.newHashSet() https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:175: if (!urlsMatchIgnoringFragments(mMetaData.bestIconUrl, fetchedData.bestIconUrl) For a different CL This check is not correct in a multiple icon world. The bestIconUrl is different for different devices. When minting a WebAPK for https://webapk-test.appspot.com/generated.html?name=Long%20Train%20%F0%9F%9A%... the best icon is different on an Android One device and on a Nexus 5 device. ManifestUpgradeDetectorFetcher should get the hash for the icon which is the best icon according to the "Android Manifest" as opposed to recomputing the best icon. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaData.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaData.java:26: public String iconMurmur2Hash; Nits: |iconId| -> |bestIconId| |iconMurmur2Hash| -> |bestIconMurmur2Hash| Move |iconUrls| either above or below all of the "best" properties https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:152: public static String convertIconUrlsToString(Set<String> iconUrlSet) { I can't find any calls to this function https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:167: */ How about: "Extract the icon URLs from the WebAPK's meta data. The icon URLs are stored as a space separated list in a single meta data tag in the WebAPK's AndroidManifest.xml." My version: - Is more explicit about what this function does "Extract the icon URLs from the WebAPK's meta data" - Provides more details about how the icon URLs are stored https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:168: public static Set<String> getIconUrlsFromString(String iconUrls) { Can you please modify WebApkMetaDataUtils#testSanity() to check parsing the meta data tag https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:173: iconUrlSet.addAll(Arrays.asList(urls)); I think you can use CollectionUtil.newHashSet() https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:166: iconUrls.toArray(new String[iconUrls.size()]), displayMode, orientation, themeColor, Is this better: iconUrls.toArray(new String[0]) https://codereview.chromium.org/2453423002/diff/40001/chrome/android/junit/sr... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/junit/sr... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:103: mFetchedData.iconUrls.toArray(new String[mFetchedData.iconUrls.size()]), Is this more correct: mFetchedData.iconUrls.toArray(new String[0]) https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/l... File chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkConstants.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/l... chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkConstants.java:26: public static final String ICON_URL_SEPARATOR = "; "; Can the separator be just ' '? I don't think that much is gained by making the separator "; " instead of " ". Both https://www.google.com/a b https://www.google.com/a; b are valid URLs This CL puts a requirement on the WebAPK server to escape ' ' as %20 The WebAPK server should not do any other escaping. In particular, Chrome has some very special handling for "https://www.google.com/%2%32" Chrome escapes "https://www.google.com/%2%32" as "https://www.google.com/%2522" https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... File chrome/android/webapk/shell_apk/AndroidManifest.xml (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... chrome/android/webapk/shell_apk/AndroidManifest.xml:49: <meta-data android:name="org.chromium.webapk.shell_apk.iconId" android:resource="@mipmap/app_icon" /> Nit: rename iconId -> bestIconId https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... chrome/android/webapk/shell_apk/AndroidManifest.xml:51: <meta-data android:name="org.chromium.webapk.shell_apk.iconUrls" android:value="{{ icon_urls }}" /> Nit: Move this line before all of the "best" <meta-data> tags or after all of the "best" <meta-data> tags https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... chrome/android/webapk/shell_apk/AndroidManifest.xml:52: <meta-data android:name="org.chromium.webapk.shell_apk.iconMurmur2Hash" android:value="{{ icon_murmur2_hash }}" /> Nit: Rename iconMurmur2Hash -> bestIconMurmur2Hash https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/shortcut_info.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/shortcut_info.cc:67: // Set the icon urls based on the icons on the manifest, if any. Nit: "on the manifest" -> "in the manifest" https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/shortcut_info.cc:69: for (const auto& icon : manifest.icons) Nit: "const auto& icon" -> "const Icon& icon" https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:162: const std::string& icon_murmur2_hash) { Nit: Rename |icon_murmur2_hash| to |best_icon_murmur2_hash| https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:171: OnDataAvailable(info_, icon_murmur2_hash, icon_); Nit: |icon_| -> |best_icon_| https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:193: gfx::ConvertToJavaBitmap(&icon_bitmap); Nit: |java_bitmap| -> |java_best_bitmap| https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:196: for (const auto& icon_url : info.icon_urls) Nit: "const auto& icon_url" -> "const GURL& icon_url" https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_installer.cc:119: webapk::Image* image = web_app_manifest->add_icons(); Nit: Rename |image| -> |best_image| https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_installer.cc:126: for (const auto& icon_url : shortcut_info.icon_urls) { Nit: "const auto& icon_url" -> "const GURL& icon_url" https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_installer.cc:131: } Can you check with Glenn whether reordering is ok? When I talked to Glenn offline about something unrelated he mentioned that the reordering might be suboptimial. (I guess we could asssume that reordering is OK and fix it once we know whether it actually is ok) https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/webapk/webapk_update_manager.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_update_manager.cc:56: const JavaParamRef<jobject>& java_icon_bitmap, Nit: |java_icon_murmur2_hash| -> |java_best_icon_murmur2_hash| |java_icon_bitmap| -> |java_best_icon_bitmap|
Patchset #2 (id:60001) has been deleted
Patchset #2 (id:80001) has been deleted
Patchset #2 (id:100001) has been deleted
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. Chrome only sends the best icon url to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, the icon urls are added to ShortcutInfo, so they can be sent to the WebAPK server. These icon URLs are stored as a <meta-data> tag in the WebAPK's AndroidManifest.xml. Besides, the change of the icon URLs will request an update for the WebAPK. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. Chrome only sends the best icon url to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon urls are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multipe icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space seperated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server genereates all the icon hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. Chrome only sends the best icon url to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon urls are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multipe icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space seperated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server genereates all the icon hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon url to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon urls are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multipe icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space seperated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server genereates all the icon hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon url to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon urls are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multipe icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space seperated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server genereates all the icon hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ==========
The CQ bit was checked by hanxi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Hi Peter, I update this CL according to the decision to put all the icon urls and icon hashs in the AndroidManifest.xml. Please take another look, thanks! https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:156: fetchedData.iconUrls = new HashSet<String>(); On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: Use org.chromium.base.CollectionUtil.newHashSet() Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:175: if (!urlsMatchIgnoringFragments(mMetaData.bestIconUrl, fetchedData.bestIconUrl) On 2016/11/01 00:29:49, pkotwicz wrote: > For a different CL > > This check is not correct in a multiple icon world. The bestIconUrl is different > for different devices. When minting a WebAPK for > https://webapk-test.appspot.com/generated.html?name=Long%20Train%20%F0%9F%9A%... > the best icon is different on an Android One device and on a Nexus 5 device. > > ManifestUpgradeDetectorFetcher should get the hash for the icon which is the > best icon according to the "Android Manifest" as opposed to recomputing the best > icon. Good catch. As discussed offline, the best icon URL and hash are removed from the metadata, and have all the icon URLs and hashs in. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaData.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaData.java:26: public String iconMurmur2Hash; On 2016/11/01 00:29:49, pkotwicz wrote: > Nits: > |iconId| -> |bestIconId| > |iconMurmur2Hash| -> |bestIconMurmur2Hash| > > Move |iconUrls| either above or below all of the "best" properties Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:152: public static String convertIconUrlsToString(Set<String> iconUrlSet) { On 2016/11/01 00:29:49, pkotwicz wrote: > I can't find any calls to this function Good catch, the caller was removed after I rebased this CL after the changes of WebApkMetaData. Now it is called from WebApkMetaDataUtilsTest, so I moved it there. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:167: */ On 2016/11/01 00:29:49, pkotwicz wrote: > How about: "Extract the icon URLs from the WebAPK's meta data. The icon URLs are > stored as a space separated list in a single meta data tag in the WebAPK's > AndroidManifest.xml." > > My version: > - Is more explicit about what this function does "Extract the icon URLs from the > WebAPK's meta data" > - Provides more details about how the icon URLs are stored Sounds better, thanks. Only one change: space -> {@link WebApkConstants#ICON_URL_SEPARATOR}. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:168: public static Set<String> getIconUrlsFromString(String iconUrls) { On 2016/11/01 00:29:49, pkotwicz wrote: > Can you please modify WebApkMetaDataUtils#testSanity() to check parsing the meta > data tag Good idea. I add a separate test since the icon urls aren't in WebappInfo. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:173: iconUrlSet.addAll(Arrays.asList(urls)); On 2016/11/01 00:29:49, pkotwicz wrote: > I think you can use CollectionUtil.newHashSet() Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:166: iconUrls.toArray(new String[iconUrls.size()]), displayMode, orientation, themeColor, On 2016/11/01 00:29:49, pkotwicz wrote: > Is this better: > iconUrls.toArray(new String[0]) I am not sure which one is preferred, since both of them are used in chromium's code base. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/junit/sr... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/junit/sr... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:103: mFetchedData.iconUrls.toArray(new String[mFetchedData.iconUrls.size()]), On 2016/11/01 00:29:49, pkotwicz wrote: > Is this more correct: > mFetchedData.iconUrls.toArray(new String[0]) Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/l... File chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkConstants.java (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/l... chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkConstants.java:26: public static final String ICON_URL_SEPARATOR = "; "; On 2016/11/01 00:29:49, pkotwicz wrote: > Can the separator be just ' '? > > I don't think that much is gained by making the separator "; " instead of " ". > Both > https://www.google.com/a b > https://www.google.com/a; b > are valid URLs > > This CL puts a requirement on the WebAPK server to escape ' ' as %20 > The WebAPK server should not do any other escaping. In particular, Chrome has > some very special handling for "https://www.google.com/%2%32" > Chrome escapes "https://www.google.com/%2%32" as "https://www.google.com/%2522" We definitely could only use a space, since space is the only one that I find shouldn't be in a valid URL. Yes, server will prepare such a metadata tag and store it in the AndroidManifest.xml. Since Chrome canonicalizes all the URLs and Serve just uses them and add a space between two icon URLs, we could handle it correct when parsing the metadata. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... File chrome/android/webapk/shell_apk/AndroidManifest.xml (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... chrome/android/webapk/shell_apk/AndroidManifest.xml:49: <meta-data android:name="org.chromium.webapk.shell_apk.iconId" android:resource="@mipmap/app_icon" /> On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: rename iconId -> bestIconId Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... chrome/android/webapk/shell_apk/AndroidManifest.xml:51: <meta-data android:name="org.chromium.webapk.shell_apk.iconUrls" android:value="{{ icon_urls }}" /> On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: Move this line before all of the "best" <meta-data> tags or after all of > the "best" <meta-data> tags Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/android/webapk/s... chrome/android/webapk/shell_apk/AndroidManifest.xml:52: <meta-data android:name="org.chromium.webapk.shell_apk.iconMurmur2Hash" android:value="{{ icon_murmur2_hash }}" /> On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: Rename iconMurmur2Hash -> bestIconMurmur2Hash Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/shortcut_info.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/shortcut_info.cc:67: // Set the icon urls based on the icons on the manifest, if any. On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: "on the manifest" -> "in the manifest" Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/shortcut_info.cc:69: for (const auto& icon : manifest.icons) On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: "const auto& icon" -> "const Icon& icon" content::Manifest::Icon, personally I would prefer to use "auto". https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:162: const std::string& icon_murmur2_hash) { On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: Rename |icon_murmur2_hash| to |best_icon_murmur2_hash| Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:171: OnDataAvailable(info_, icon_murmur2_hash, icon_); On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: |icon_| -> |best_icon_| Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:193: gfx::ConvertToJavaBitmap(&icon_bitmap); On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: |java_bitmap| -> |java_best_bitmap| Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:196: for (const auto& icon_url : info.icon_urls) On 2016/11/01 00:29:49, pkotwicz wrote: > Nit: "const auto& icon_url" -> "const GURL& icon_url" Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_installer.cc:119: webapk::Image* image = web_app_manifest->add_icons(); On 2016/11/01 00:29:50, pkotwicz wrote: > Nit: Rename |image| -> |best_image| Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_installer.cc:126: for (const auto& icon_url : shortcut_info.icon_urls) { On 2016/11/01 00:29:50, pkotwicz wrote: > Nit: "const auto& icon_url" -> "const GURL& icon_url" Done. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_installer.cc:131: } On 2016/11/01 00:29:49, pkotwicz wrote: > Can you check with Glenn whether reordering is ok? When I talked to Glenn > offline about something unrelated he mentioned that the reordering might be > suboptimial. (I guess we could asssume that reordering is OK and fix it once we > know whether it actually is ok) I talked to Glenn and he prefers to have the best one as the first, and others as ordered in the Web Manifest. Since we didn't change the orders of the urls except the best, I assume it should be just fine. https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/webapk/webapk_update_manager.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/webapk/webapk_update_manager.cc:56: const JavaParamRef<jobject>& java_icon_bitmap, On 2016/11/01 00:29:50, pkotwicz wrote: > Nit: > |java_icon_murmur2_hash| -> |java_best_icon_murmur2_hash| > |java_icon_bitmap| -> |java_best_icon_bitmap| Done.
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. The metadata changes requires some behavior changes: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. Some behavior changes involved: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. Some behavior changes involved: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. Internally, the icon URL and icon Hash pairs are stored in a map. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. Internally, the icon URL and icon Hash pairs are stored in a map. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map underneath the code. BUG=627593 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
A few more comments. Mostly nits. Sorry for taking so long to review the CL https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/shortcut_info.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/shortcut_info.cc:69: for (const auto& icon : manifest.icons) This is the official guideline for using auto: https://google.github.io/styleguide/cppguide.html In my opinion, using auto here is borderline. It isn't immediately obvious what type content::Manifest::icons is. I initially thought that content::Manifest::icons was of type std::vector<GURL> https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:156: fetchedData.iconUrls = CollectionUtil.newHashSet(); - In which scenario is iconUrls null? - Sorry I should have been clearer. I was thinking of doing: fetchedData.iconUrls = CollectionUtil.newHashSet(iconUrls); https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:174: private boolean needsUpgrade(FetchedManifestData fetchedData) { Can we simplify this function return !mMetaData.iconURLAndHashMap.containsKey(fetchedData.bestIconUrl) || !mMetaData.iconURLAndHashMap.get(fetchedData.bestIconUrl).equals(fetchedData.bestIconMurmur2Hash) || !urlsMatchIgnoringFragments(mMetaData.scope, fetchedData.scopeUrl) || !urlsMatchIgnoringFragments(mMetaData.startUrl, fetchedData.startUrl) || ... https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:199: || !mMetaData.iconURLAndHashMap.keySet().equals(fetchedData.iconUrls)) { Nit: Maybe iconUrlAndMurmur2HashMap() - https://google.github.io/styleguide/javaguide.html#s5.3-camel-case suggests capitalizing only the first character of acronyms - java.util.HashMap is a common Java class. I am suggesting adding "Murmur2" to the name to make it clearer that the "Hash" in iconUrlAndMurmur2HashMap does not refer to java.util.HashMap https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:25: String bestIconUrl, String bestIconMurmur2Hash, Bitmap iconBitmap, iconBitmap -> bestIconBitmap https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:90: String bestIconUrl, String bestIconMurmur2Hash, Bitmap iconBitmap, String[] iconUrls, iconBitmap -> bestIconBitmap https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:125: * Extract the icon URLs and icon hashs from the WebAPK's meta data, and returns a map of these Nit: hashs -> hashes https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:127: * single meta data tag in the WebAPK's AndroidManifest.xml respectively. Perhaps it would be better to store this in a single meta data tag instead of two. The benefit of doing this is that you can get rid of the murmur2HashFromString() function https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:132: String iconHashs = metaData.getString(WebApkMetaDataKeys.ICON_MURMUR2_HASHS); Nit: iconHashs -> iconHashes https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:136: String[] hashs = iconHashs.split(WebApkConstants.ICON_URL_SEPARATOR); Nit: hashs -> hashes https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:138: iconUrlAndHashMap.put(urls[i], murmur2HashFromString(hashs[i])); Won't you run into problems if hashes.length < urls.length? https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:200: * {@link Long#MAX_VALUE}. An empty string if the hash could not be extracted. How about: Extracts the Murmur2 hash from a meta-data string. The return value is a string because the hash can take values up to 2^64-1 which is greater than {@link Long#MAX_VALUE}. Returns an empty string ... I think that my version makes it clearer what this function does. It is slightly confusing that both the parameter is a string and the return value is a string. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:150: private void updateAsyncUsingAndroidManifestMetaData() { Please add a comment why you are passing in an empty bestIconUrl and an empty bestIconMurmur2Hash https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:160: String bestIconUrl, String bestIconMurmur2Hash, Bitmap icon, Set<String> iconUrls, Nit: icon -> bestIcon https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:269: Bitmap icon, String[] iconUrls, int displayMode, int orientation, long themeColor, Nit: icon -> bestIcon https://codereview.chromium.org/2453423002/diff/120001/chrome/android/javates... File chrome/android/javatests/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcherTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/javates... chrome/android/javatests/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcherTest.java:56: String shortName, String bestIconUrl, String bestIconMurmur2Hash, Bitmap iconBitmap, Nit: iconBitmap -> bestIconBitmap https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:192: private TestManifestUpgradeDetector createDetector(WebappInfoCreationData oldData, Can this be WebApkMetaData instead? https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:308: */ Nit: Make this a single line comment like this: /** Test ... Manifest. */ (I know that I have not done this in many of my CLs.) https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:319: } I think that it is worthwhile to add a test case where the Web Manifest has multiple icons but an update is not requested https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java:54: */ Nit: I would keep the test about reading 2^64-1 as a separate test https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java:141: String bestIconUrl, String bestIconMurmur2Hash, Bitmap icon, Set<String> iconUrls, Nit: icon -> bestIcon https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... File chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java:23: public static final String ICON_MURMUR2_HASHS = Nit: HASHES not HASHS https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java:24: "org.chromium.webapk.shell_apk.IconMurmur2Hashs"; Nit: iconMurmur2Hashes not IconMurmur2Hashs I made the suffix lowercase to match the other suffixes https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... File chrome/android/webapk/shell_apk/AndroidManifest.xml (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/shell_apk/AndroidManifest.xml:52: <meta-data android:name="org.chromium.webapk.shell_apk.iconHashs" android:value="{{ icon_hashs }}" /> Make sure that the key matches the constant in WebApkMetaDataKeys https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... File chrome/android/webapk/shell_apk/BUILD.gn (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/shell_apk/BUILD.gn:35: webapk_icon_hashs = "$webapk_icon_murmur2_hash $webapk_icon_murmur2_hash" Nit: webapk_icon_hashs -> webapk_icon_hashes https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:103: if (shortcut_icon_murmur2_hash.empty()) An empty |shortcut_icon_murmur2_hash| shouldn't have a special meaning. Instead of making an empty proto have a special meaning I would rather add a new proto member: "client_data_stale" perhaps? https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:121: scope->assign(GetScope(shortcut_info).spec()); Nit: Add a new line for clarity https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... File chrome/browser/android/webapk/webapk_update_manager.cc (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:100: std::vector<std::string> icon_urls; Nit: Move this block before |java_bitmap_lock|. That way we finish populating |info| prior to setting |best_icon_bitmap| https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:101: if (!java_icon_urls.is_null()) { Is |java_icon_urls| ever null? https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:105: for (const auto& icon_url : icon_urls) I think this use of auto is OK
Patchset #3 (id:140001) has been deleted
Patchset #4 (id:180001) has been deleted
Patchset #3 (id:160001) has been deleted
PTAL, thanks! https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... File chrome/browser/android/shortcut_info.cc (right): https://codereview.chromium.org/2453423002/diff/40001/chrome/browser/android/... chrome/browser/android/shortcut_info.cc:69: for (const auto& icon : manifest.icons) On 2016/11/11 21:04:18, pkotwicz wrote: > This is the official guideline for using auto: > https://google.github.io/styleguide/cppguide.html > > In my opinion, using auto here is borderline. It isn't immediately obvious what > type content::Manifest::icons is. I initially thought that > content::Manifest::icons was of type std::vector<GURL> Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:156: fetchedData.iconUrls = CollectionUtil.newHashSet(); On 2016/11/11 21:04:18, pkotwicz wrote: > - In which scenario is iconUrls null? > - Sorry I should have been clearer. I was thinking of doing: > fetchedData.iconUrls = CollectionUtil.newHashSet(iconUrls); I did try this, but eclipse gave an error to me last time. Now it works. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:174: private boolean needsUpgrade(FetchedManifestData fetchedData) { On 2016/11/11 21:04:18, pkotwicz wrote: > Can we simplify this function > > return !mMetaData.iconURLAndHashMap.containsKey(fetchedData.bestIconUrl) || > > !mMetaData.iconURLAndHashMap.get(fetchedData.bestIconUrl).equals(fetchedData.bestIconMurmur2Hash) > || > !urlsMatchIgnoringFragments(mMetaData.scope, fetchedData.scopeUrl) || > !urlsMatchIgnoringFragments(mMetaData.startUrl, fetchedData.startUrl) || > ... Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:199: || !mMetaData.iconURLAndHashMap.keySet().equals(fetchedData.iconUrls)) { On 2016/11/11 21:04:18, pkotwicz wrote: > Nit: Maybe iconUrlAndMurmur2HashMap() > > - https://google.github.io/styleguide/javaguide.html#s5.3-camel-case suggests > capitalizing only the first character of acronyms > > - java.util.HashMap is a common Java class. I am suggesting adding "Murmur2" to > the name to make it clearer that the "Hash" in iconUrlAndMurmur2HashMap does not > refer to java.util.HashMap Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:25: String bestIconUrl, String bestIconMurmur2Hash, Bitmap iconBitmap, On 2016/11/11 21:04:18, pkotwicz wrote: > iconBitmap -> bestIconBitmap Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:90: String bestIconUrl, String bestIconMurmur2Hash, Bitmap iconBitmap, String[] iconUrls, On 2016/11/11 21:04:18, pkotwicz wrote: > iconBitmap -> bestIconBitmap Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:125: * Extract the icon URLs and icon hashs from the WebAPK's meta data, and returns a map of these On 2016/11/11 21:04:18, pkotwicz wrote: > Nit: hashs -> hashes Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:127: * single meta data tag in the WebAPK's AndroidManifest.xml respectively. On 2016/11/11 21:04:18, pkotwicz wrote: > Perhaps it would be better to store this in a single meta data tag instead of > two. It easy to parse if they are stored in two metadata tags, this is the main reason why it is designed in this way. > The benefit of doing this is that you can get rid of the murmur2HashFromString() > function By removing the last "L" in the hash, we could get rid of murmur2HashFromString() even with two separate tags, I don't see there is a blocker. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:132: String iconHashs = metaData.getString(WebApkMetaDataKeys.ICON_MURMUR2_HASHS); On 2016/11/11 21:04:18, pkotwicz wrote: > Nit: iconHashs -> iconHashes Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:136: String[] hashs = iconHashs.split(WebApkConstants.ICON_URL_SEPARATOR); On 2016/11/11 21:04:18, pkotwicz wrote: > Nit: hashs -> hashes Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:138: iconUrlAndHashMap.put(urls[i], murmur2HashFromString(hashs[i])); On 2016/11/11 21:04:19, pkotwicz wrote: > Won't you run into problems if hashes.length < urls.length? Talked with Glenn offline before, and he said server will add "0L" in the murmur2hash for the case of no hash values. These two arrays are expected in the same length. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:200: * {@link Long#MAX_VALUE}. An empty string if the hash could not be extracted. On 2016/11/11 21:04:18, pkotwicz wrote: > How about: Extracts the Murmur2 hash from a meta-data string. The return value > is a string because the hash can take values up to 2^64-1 which is greater than > {@link Long#MAX_VALUE}. Returns an empty string ... > > I think that my version makes it clearer what this function does. It is slightly > confusing that both the parameter is a string and the return value is a string. Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:150: private void updateAsyncUsingAndroidManifestMetaData() { On 2016/11/11 21:04:19, pkotwicz wrote: > Please add a comment why you are passing in an empty bestIconUrl and an empty > bestIconMurmur2Hash Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:160: String bestIconUrl, String bestIconMurmur2Hash, Bitmap icon, Set<String> iconUrls, On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: icon -> bestIcon Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:269: Bitmap icon, String[] iconUrls, int displayMode, int orientation, long themeColor, On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: icon -> bestIcon Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/javates... File chrome/android/javatests/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcherTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/javates... chrome/android/javatests/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcherTest.java:56: String shortName, String bestIconUrl, String bestIconMurmur2Hash, Bitmap iconBitmap, On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: iconBitmap -> bestIconBitmap Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:192: private TestManifestUpgradeDetector createDetector(WebappInfoCreationData oldData, On 2016/11/11 21:04:19, pkotwicz wrote: > Can this be WebApkMetaData instead? Good ctach. Yes, WebappInfoCreationData is an alias of WebApkMetaData. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:308: */ On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: Make this a single line comment like this: > /** Test ... Manifest. */ > > (I know that I have not done this in many of my CLs.) Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:319: } On 2016/11/11 21:04:19, pkotwicz wrote: > I think that it is worthwhile to add a test case where the Web Manifest has > multiple icons but an update is not requested Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java:54: */ On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: I would keep the test about reading 2^64-1 as a separate test Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java:141: String bestIconUrl, String bestIconMurmur2Hash, Bitmap icon, Set<String> iconUrls, On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: icon -> bestIcon Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... File chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java:23: public static final String ICON_MURMUR2_HASHS = On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: HASHES not HASHS Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java:24: "org.chromium.webapk.shell_apk.IconMurmur2Hashs"; On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: iconMurmur2Hashes not IconMurmur2Hashs > > I made the suffix lowercase to match the other suffixes Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... File chrome/android/webapk/shell_apk/AndroidManifest.xml (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/shell_apk/AndroidManifest.xml:52: <meta-data android:name="org.chromium.webapk.shell_apk.iconHashs" android:value="{{ icon_hashs }}" /> On 2016/11/11 21:04:19, pkotwicz wrote: > Make sure that the key matches the constant in WebApkMetaDataKeys Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... File chrome/android/webapk/shell_apk/BUILD.gn (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/webapk/... chrome/android/webapk/shell_apk/BUILD.gn:35: webapk_icon_hashs = "$webapk_icon_murmur2_hash $webapk_icon_murmur2_hash" On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: webapk_icon_hashs -> webapk_icon_hashes Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:103: if (shortcut_icon_murmur2_hash.empty()) On 2016/11/11 21:04:19, pkotwicz wrote: > An empty |shortcut_icon_murmur2_hash| shouldn't have a special meaning. Instead > of making an empty proto have a special meaning I would rather add a new proto > member: "client_data_stale" perhaps? Yes, I will wait for Glenn to add this new attribute in the proto and update here. https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:121: scope->assign(GetScope(shortcut_info).spec()); On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: Add a new line for clarity Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... File chrome/browser/android/webapk/webapk_update_manager.cc (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:100: std::vector<std::string> icon_urls; On 2016/11/11 21:04:19, pkotwicz wrote: > Nit: Move this block before |java_bitmap_lock|. That way we finish populating > |info| prior to setting |best_icon_bitmap| Done. https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:101: if (!java_icon_urls.is_null()) { On 2016/11/11 21:04:19, pkotwicz wrote: > Is |java_icon_urls| ever null? Double checked again, and it seems it shouldn't be null. Remove the check. https://codereview.chromium.org/2453423002/diff/120001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:105: for (const auto& icon_url : icon_urls) On 2016/11/11 21:04:19, pkotwicz wrote: > I think this use of auto is OK Acknowledged.
LGTM with nits https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:127: * single meta data tag in the WebAPK's AndroidManifest.xml respectively. If we have two lists we cannot remove the last "L". If we did and the list has a single element Bundle#getString() will fail because Android will think that the value is an int. (Provided that the Murmur2 Hash is below Integer#MAX_VALUE). We can get rid of the last "L" if everything is one meta data tag because Android will not think that the meta data tag value is an int In my opinion, it is just as easy to parse a single meta data tag as it is to parse two meta data tags https://codereview.chromium.org/2453423002/diff/120001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:138: iconUrlAndHashMap.put(urls[i], murmur2HashFromString(hashs[i])); We should not assume that the WebAPK server is bug free :) https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:173: fetchedData.bestIconMurmur2Hash) Nit: I think you can simplify that top two lines to: String metaDataBestIconMurmur2Hash = mMetaData.iconUrlAndMurmur2HashMap.get(fetchedData.bestIconUrl); return !TextUtils.equals(metaDataBestIconMurmur2Hash, fetchedData.bestIconMurmur2Hash) https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:182: || !mMetaData.iconUrlAndMurmur2HashMap.keySet().equals(fetchedData.iconUrls); Nit: Group the if statements related to iconUrlAndMurmur2HashMap together https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:154: // icon URL. In this case, pass an empty URL to indicate that there isn't any best icon URL. Nits: - "to indicate" -> "to tell the server" (I think that my version is more descriptive) - "any best icon URL" -> "a best icon URL" https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:168: data.backgroundColor = WEBAPK_BACKGROUND_COLOR; Nit: Can you add a new line for clarity. You are initializing iconUrlAndMurmur2HashMap in two lines which is kind of different. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:170: data.iconUrlAndMurmur2HashMap.put(WEBAPK_ICON_URL, WEBAPK_ICON_MURMUR2_HASH); Can you please add a new line for clarity https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:316: * Manifest. How about: "Test that an upgrade isn't requested when the Web Manifest has multiple icons and the Web Manifest has not changed." https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:328: fetchedData.iconUrls.add(icon2); For the sake of fun, make bestIconUrl and bestIconMurmur2Hash point to the second icon (To make sure that we don't do any fancy handling with the first icon) https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java:50: */ Nit: "can read icon URLs and icon murmur2 hashes" -> "can read multiple icon URLs and multiple icon Murmur2 hashes" https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java:89: Assert.assertEquals(iconUrlSet, iconUrlAndIconMurmur2HashMap.keySet()); I think that you can simplify things by doing this: Assert.assertEquals(1, iconUrlAndIconMurmur2HashMap.size(); Assert.assertTrue(iconUrlAndIconMurmur2HashMap.containsKey(iconUrl)); That enables you to get rid of |iconUrlSet| https://codereview.chromium.org/2453423002/diff/200001/chrome/android/webapk/... File chrome/android/webapk/shell_apk/AndroidManifest.xml (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/webapk/... chrome/android/webapk/shell_apk/AndroidManifest.xml:52: <meta-data android:name="org.chromium.webapk.shell_apk.iconHashes" android:value="{{ icon_hashes }}" /> Please make this match with the constant in WebApkMetaDataKeys.java https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/shortcut_info.h (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/shortcut_info.h:8: #include <stdint.h> Nit: #include <vector> https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:198: Nit: Remove new line https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:104: // that the Web Manifest is staled. How about: "crbug.com/665078. Add a flag in WebAPK's proto to indicate that the Web Manifest data in the proto might be stale." In my version: - It is clearer that the data in the proto might be stale - I use stale instead of staled because I am not using "stale" as a verb https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer_unittest.cc (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer_unittest.cc:101: icon_url_(icon_url) {} Nit: |icon_url_| -> |best_icon_url_|
Patchset #5 (id:240001) has been deleted
Patchset #5 (id:260001) has been deleted
Patchset #5 (id:280001) has been deleted
Patchset #4 (id:220001) has been deleted
Patchset #5 (id:320001) has been deleted
Patchset #4 (id:300001) has been deleted
Hi Peter, I merge the icon urls and murmur2 hash into one single metadata tag, PTAL, thanks! https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:173: fetchedData.bestIconMurmur2Hash) On 2016/11/14 22:43:10, pkotwicz wrote: > Nit: I think you can simplify that top two lines to: > > String metaDataBestIconMurmur2Hash = > mMetaData.iconUrlAndMurmur2HashMap.get(fetchedData.bestIconUrl); > > return !TextUtils.equals(metaDataBestIconMurmur2Hash, > fetchedData.bestIconMurmur2Hash) Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:182: || !mMetaData.iconUrlAndMurmur2HashMap.keySet().equals(fetchedData.iconUrls); On 2016/11/14 22:43:10, pkotwicz wrote: > Nit: Group the if statements related to iconUrlAndMurmur2HashMap together Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:154: // icon URL. In this case, pass an empty URL to indicate that there isn't any best icon URL. On 2016/11/14 22:43:11, pkotwicz wrote: > Nits: > - "to indicate" -> "to tell the server" (I think that my version is more > descriptive) > - "any best icon URL" -> "a best icon URL" Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:168: data.backgroundColor = WEBAPK_BACKGROUND_COLOR; On 2016/11/14 22:43:11, pkotwicz wrote: > Nit: Can you add a new line for clarity. You are initializing > iconUrlAndMurmur2HashMap in two lines which is kind of different. Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:170: data.iconUrlAndMurmur2HashMap.put(WEBAPK_ICON_URL, WEBAPK_ICON_MURMUR2_HASH); On 2016/11/14 22:43:11, pkotwicz wrote: > Can you please add a new line for clarity Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:316: * Manifest. On 2016/11/14 22:43:11, pkotwicz wrote: > How about: "Test that an upgrade isn't requested when the Web Manifest has > multiple icons and the Web Manifest has not changed." Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:328: fetchedData.iconUrls.add(icon2); On 2016/11/14 22:43:11, pkotwicz wrote: > For the sake of fun, make bestIconUrl and bestIconMurmur2Hash point to the > second icon > (To make sure that we don't do any fancy handling with the first icon) Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java:50: */ On 2016/11/14 22:43:11, pkotwicz wrote: > Nit: "can read icon URLs and icon murmur2 hashes" -> "can read multiple icon > URLs and multiple icon Murmur2 hashes" Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtilsTest.java:89: Assert.assertEquals(iconUrlSet, iconUrlAndIconMurmur2HashMap.keySet()); On 2016/11/14 22:43:11, pkotwicz wrote: > I think that you can simplify things by doing this: > Assert.assertEquals(1, iconUrlAndIconMurmur2HashMap.size(); > Assert.assertTrue(iconUrlAndIconMurmur2HashMap.containsKey(iconUrl)); > > That enables you to get rid of |iconUrlSet| Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/android/webapk/... File chrome/android/webapk/shell_apk/AndroidManifest.xml (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/android/webapk/... chrome/android/webapk/shell_apk/AndroidManifest.xml:52: <meta-data android:name="org.chromium.webapk.shell_apk.iconHashes" android:value="{{ icon_hashes }}" /> On 2016/11/14 22:43:11, pkotwicz wrote: > Please make this match with the constant in WebApkMetaDataKeys.java Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/shortcut_info.h (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/shortcut_info.h:8: #include <stdint.h> On 2016/11/14 22:43:11, pkotwicz wrote: > Nit: #include <vector> Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:198: On 2016/11/14 22:43:11, pkotwicz wrote: > Nit: Remove new line Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:104: // that the Web Manifest is staled. On 2016/11/14 22:43:11, pkotwicz wrote: > How about: "crbug.com/665078. Add a flag in WebAPK's proto to indicate that the > Web Manifest data in the proto might be stale." > > In my version: > - It is clearer that the data in the proto might be stale > - I use stale instead of staled because I am not using "stale" as a verb > Done. https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer_unittest.cc (right): https://codereview.chromium.org/2453423002/diff/200001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer_unittest.cc:101: icon_url_(icon_url) {} On 2016/11/14 22:43:11, pkotwicz wrote: > Nit: |icon_url_| -> |best_icon_url_| Done.
The CQ bit was checked by hanxi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linu...)
Still LGTM https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:130: * WebAPK's AndroidManifest.xml as followings: Nit: followings -> following https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:131: * {URL1 hash1}{URL2 hash2}{URL3 hash3}... Personally, I would have made the format: "URL1 hash1 URL2 hash2 URL3 hash3..." but this is ok too https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:156: if (i + 1 > urlsAndHashes.length - 1) { Can you move this check outside the for loop if (urlsAndHashes.length % 2 != 0) { } https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:170: * @return The hash. An empty string if the hash could not be extracted. Not breaking existing users is good! Kudos for caring about our users!!!
hanxi@chromium.org changed reviewers: + dominickn@chromium.org
Hi Dominick, could you please take a look? Thanks! https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:130: * WebAPK's AndroidManifest.xml as followings: On 2016/11/15 22:04:46, pkotwicz wrote: > Nit: followings -> following Done. https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:131: * {URL1 hash1}{URL2 hash2}{URL3 hash3}... On 2016/11/15 22:04:46, pkotwicz wrote: > Personally, I would have made the format: > "URL1 hash1 URL2 hash2 URL3 hash3..." > but this is ok too This does simplify things. Updated. https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:156: if (i + 1 > urlsAndHashes.length - 1) { On 2016/11/15 22:04:46, pkotwicz wrote: > Can you move this check outside the for loop > > if (urlsAndHashes.length % 2 != 0) { > } Done. https://codereview.chromium.org/2453423002/diff/340001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:170: * @return The hash. An empty string if the hash could not be extracted. On 2016/11/15 22:04:46, pkotwicz wrote: > Not breaking existing users is good! Kudos for caring about our users!!! Acknowledged.
Why is it necessary for all of the icon URLs to match for an upgrade to not be triggered? That's a functional change from before where you only update if they best icon + hash doesn't match. Put another way, if you check the manifest, and the best icon is still exactly the same as the one you currently have, and all the other details match, why do you need to upgrade? If the WebAPK server is now minting a WebAPK with different icons in it, but the specific icon you use is the same, do you need to upgrade? https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:63: public Set<String> iconUrls; Why does this need to be a set? It looks like it's an array elsewhere. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:24: void onGotManifestData(String startUrl, String scopeUrl, String name, String shortName, It's really confusing that this onGotManifestData takes lots of arguments, but the onGotManifestData in WebApkUpdateManager just takes the FetchedManifestData. I really think that all of them should take a WebApkInfo object and that should have everything in it. The only time you should have an argument list this long is for a CalledByNative method. Otherwise, we should use objects to encapsulate the arguments. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:31: private static final String TAG = "cr_WebApkMetaData"; Nit: newline after this. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:56: metaData.backgroundColor, false, webApkPackageName); Should this be metaData.iconUrlAndIconMurmur2HashMap.isEmpty() or something like that? https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:142: if (TextUtils.isEmpty(iconUrl)) { Reverse this conditional, move line 145 inside, and remove line 143. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:151: String[] urlsAndHashes = iconUrlsAndIconMurmur2Hashes.split("[ ]+"); Is it ever possible for a URL to be printed that contains a space? Or (even worse) two spaces? Can this be tested in some way? https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:166: String bestIconUrl, String bestIconMurmur2Hash, Bitmap bestIcon, Set<String> iconUrls, This shouldn't be a set. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:170: bestIconMurmur2Hash, bestIcon, iconUrls.toArray(new String[0]), displayMode, Declare String[] iconUrlsArray = new String[iconUrls.size()]. Then call iconUrls.toArray(iconUrlsArray). Relying on the JVM to implicitly resize the array is magical (and seeing String[0] is just weird). https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... File chrome/browser/android/shortcut_info.h (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... chrome/browser/android/shortcut_info.h:57: std::vector<GURL> icon_urls; Why is this a vector but it's a set in Java? Also, I'm not a big fan of the "best" terminology. I'll think about it overnight... Also, is there any need for this to be a container of GURLs? It looks like everything that accesses this member calls spec() on each object (or starts with a string and has to call GURL()). Why not have a container of strings?
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, the server wants to have all the icon URLs listed in the Web Manifest sent. In this CL, all of the icon URLs are added to ShortcutInfo, so they can be sent to the WebAPK server. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs are stored as a space separated single <meta-data> tag, and so do the icon Hashs. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + the best icon URL + best icon hash to the Server, and Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map underneath the code. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the icon images. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which uses the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked in metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the icon images. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which uses the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the icon images. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which uses the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the icon images. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which uses the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which uses the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ==========
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which uses the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which use the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ==========
I change the update rule for icons: Chrome only sends update request if the best icon url + hash changed. We will not consider other icons. The only concern is if Android picks a different icon, we may fail to update. But I don't think this is a big concern. I also update the CL description, and hope it helps. PTAL, thanks! https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:63: public Set<String> iconUrls; On 2016/11/17 02:34:38, dominickn wrote: > Why does this need to be a set? It looks like it's an array elsewhere. It is because the order of the URLs doesn't matter. So if only the order changes, we should treat as the URLs didn't change. When using a set, it would be easy to do such a comparison without worrying about the order of the elements. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:24: void onGotManifestData(String startUrl, String scopeUrl, String name, String shortName, On 2016/11/17 02:34:38, dominickn wrote: > It's really confusing that this onGotManifestData takes lots of arguments, but > the onGotManifestData in WebApkUpdateManager just takes the FetchedManifestData. I haven't thought about it before, but it does make sense to me. Move the generation of the FetchedManifestData from ManifestUpgradeDetector to ManifestUpgradeDetectorFetcher. > I really think that all of them should take a WebApkInfo object and that should > have everything in it. The only time you should have an argument list this long > is for a CalledByNative method. Otherwise, we should use objects to encapsulate > the arguments. The WebApkInfo and FetchedManifestData are slightly different. For example, WebApkInfo have encodedIcon, while we need to store the bestIconUrl and bestIconHash in the FetchedManifestData. Personally I would prefer to use FetchedManifestData here. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:31: private static final String TAG = "cr_WebApkMetaData"; On 2016/11/17 02:34:38, dominickn wrote: > Nit: newline after this. Done. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:56: metaData.backgroundColor, false, webApkPackageName); On 2016/11/17 02:34:38, dominickn wrote: > Should this be metaData.iconUrlAndIconMurmur2HashMap.isEmpty() or something like > that? Good catch! https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:142: if (TextUtils.isEmpty(iconUrl)) { On 2016/11/17 02:34:38, dominickn wrote: > Reverse this conditional, move line 145 inside, and remove line 143. Done. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:151: String[] urlsAndHashes = iconUrlsAndIconMurmur2Hashes.split("[ ]+"); On 2016/11/17 02:34:38, dominickn wrote: > Is it ever possible for a URL to be printed that contains a space? Or (even > worse) two spaces? Can this be tested in some way? The server doesn't store the original icon URLs from the web manifest in the WebAPK's AndroidManifest, but the canonicalized icon URLs sent from Chrome. Because Chrome canonicalizes all the URLs before using them, so if we want to know whether the URLs change or not, we need to compare them with previously canonicalized ones. Filed a bug to add a test in a separate CL. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:166: String bestIconUrl, String bestIconMurmur2Hash, Bitmap bestIcon, Set<String> iconUrls, On 2016/11/17 02:34:38, dominickn wrote: > This shouldn't be a set. As mentioned before, using Set can ignore the order changes of the URLs. Keep a Set here is just for consistency. https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:170: bestIconMurmur2Hash, bestIcon, iconUrls.toArray(new String[0]), displayMode, On 2016/11/17 02:34:38, dominickn wrote: > Declare String[] iconUrlsArray = new String[iconUrls.size()]. Then call > iconUrls.toArray(iconUrlsArray). Relying on the JVM to implicitly resize the > array is magical (and seeing String[0] is just weird). Done. https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... File chrome/browser/android/shortcut_info.h (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... chrome/browser/android/shortcut_info.h:57: std::vector<GURL> icon_urls; On 2016/11/17 02:34:38, dominickn wrote: > Why is this a vector but it's a set in Java? In c++, we only need to get these URLs; while in Java, we need to compare them with the ones backed in WebAPK's metadata to see whether they changed or not. > Also, I'm not a big fan of the "best" terminology. I'll think about it > overnight... All right. > Also, is there any need for this to be a container of GURLs? It looks like > everything that accesses this member calls spec() on each object (or starts with > a string and has to call GURL()). Why not have a container of strings? It looks like every variable which is called ".._url" is declared as GURL in c++, I think it's better to keep this conventions.
https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:63: public Set<String> iconUrls; On 2016/11/17 18:09:58, Xi Han wrote: > On 2016/11/17 02:34:38, dominickn wrote: > > Why does this need to be a set? It looks like it's an array elsewhere. > > It is because the order of the URLs doesn't matter. So if only the order > changes, we should treat as the URLs didn't change. When using a set, it would > be easy to do such a comparison without worrying about the order of the > elements. But we're not doing a comparison with this anymore correct? Probably best to just make it a primitive array or something like that, since it's passed in as a primitive array. https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... File chrome/browser/android/shortcut_info.h (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... chrome/browser/android/shortcut_info.h:57: std::vector<GURL> icon_urls; On 2016/11/17 18:09:58, Xi Han wrote: > > Also, is there any need for this to be a container of GURLs? It looks like > > everything that accesses this member calls spec() on each object (or starts > with > > a string and has to call GURL()). Why not have a container of strings? > It looks like every variable which is called ".._url" is declared as GURL in > c++, I think it's better to keep this conventions. You've actually broken this convention in manifest_upgrade_detector_fetcher.cc, with std::vector<std::string> icon_urls. ;) There are plenty of cases where we have some url member which isn't a GURL type and I think this makes sense as one of them. It will save extra string <-> GURL type conversions in webapk_update_manager, webapk_installer, and manifest_upgrade_detector_fetcher so it's definitely worth having. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:47: public Set<String> iconUrls; As pointed out above, this isn't being used in an equality comparison any more, so it can just be a primitive array so you don't have the memory + construction overhead of a set. You might need it to be final to make FindBugs happy. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:155: if (urlsAndHashes.length % 2 != 0) { This is slighter nicer as: if (urlsAndHashes.length % 2 == 0) { for (int i = 0; i < urlsAndHashes.length; i += 2) { iconUrlAndIconMurmur2HashMap.put(urlsAndHashes[i], urlsAndHashes[i + 1]); } } else { Log.e(TAG, "Icon URLs and hashes were not in pairs."); } return iconUrlAndIconMurmur2HashMap; https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:166: String bestIconUrl, String bestIconMurmur2Hash, Bitmap bestIcon, Set<String> iconUrls, This can just take a String[] iconUrls once you change the type in FetchedManifestData. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:297: public void testIconUrlsChangeShouleNotUpgradeIfTheBestIconUrlDoesNotChange() { Nit: "ShouldNotUpgrade"
Patchset #8 (id:420001) has been deleted
PTAL, thanks! https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetector.java:63: public Set<String> iconUrls; On 2016/11/17 18:50:53, dominickn wrote: > On 2016/11/17 18:09:58, Xi Han wrote: > > On 2016/11/17 02:34:38, dominickn wrote: > > > Why does this need to be a set? It looks like it's an array elsewhere. > > > > It is because the order of the URLs doesn't matter. So if only the order > > changes, we should treat as the URLs didn't change. When using a set, it would > > be easy to do such a comparison without worrying about the order of the > > elements. > > But we're not doing a comparison with this anymore correct? Probably best to > just make it a primitive array or something like that, since it's passed in as a > primitive array. Done. https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... File chrome/browser/android/shortcut_info.h (right): https://codereview.chromium.org/2453423002/diff/360001/chrome/browser/android... chrome/browser/android/shortcut_info.h:57: std::vector<GURL> icon_urls; On 2016/11/17 18:50:53, dominickn wrote: > On 2016/11/17 18:09:58, Xi Han wrote: > > > Also, is there any need for this to be a container of GURLs? It looks like > > > everything that accesses this member calls spec() on each object (or starts > > with > > > a string and has to call GURL()). Why not have a container of strings? > > It looks like every variable which is called ".._url" is declared as GURL in > > c++, I think it's better to keep this conventions. > > You've actually broken this convention in manifest_upgrade_detector_fetcher.cc, > with std::vector<std::string> icon_urls. ;) > > There are plenty of cases where we have some url member which isn't a GURL type > and I think this makes sense as one of them. It will save extra string <-> GURL > type conversions in webapk_update_manager, webapk_installer, and > manifest_upgrade_detector_fetcher so it's definitely worth having. Done. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:47: public Set<String> iconUrls; On 2016/11/17 18:50:53, dominickn wrote: > As pointed out above, this isn't being used in an equality comparison any more, > so it can just be a primitive array so you don't have the memory + construction > overhead of a set. You might need it to be final to make FindBugs happy. Change it to String[]. We have some tests that modify the iconUrls to test whether update is needed, how about not making it as final for now? https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkMetaDataUtils.java:155: if (urlsAndHashes.length % 2 != 0) { On 2016/11/17 18:50:53, dominickn wrote: > This is slighter nicer as: > > if (urlsAndHashes.length % 2 == 0) { > for (int i = 0; i < urlsAndHashes.length; i += 2) { > iconUrlAndIconMurmur2HashMap.put(urlsAndHashes[i], urlsAndHashes[i + > 1]); > } > } else { > Log.e(TAG, "Icon URLs and hashes were not in pairs."); > } > return iconUrlAndIconMurmur2HashMap; Personally I would prefer early exist, but if you have strong preference, I can change it too. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java:166: String bestIconUrl, String bestIconMurmur2Hash, Bitmap bestIcon, Set<String> iconUrls, On 2016/11/17 18:50:53, dominickn wrote: > This can just take a String[] iconUrls once you change the type in > FetchedManifestData. Done. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java:297: public void testIconUrlsChangeShouleNotUpgradeIfTheBestIconUrlDoesNotChange() { On 2016/11/17 18:50:53, dominickn wrote: > Nit: "ShouldNotUpgrade" Done.
Just a couple of things. https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:47: public Set<String> iconUrls; On 2016/11/17 20:42:38, Xi Han wrote: > On 2016/11/17 18:50:53, dominickn wrote: > > As pointed out above, this isn't being used in an equality comparison any > more, > > so it can just be a primitive array so you don't have the memory + > construction > > overhead of a set. You might need it to be final to make FindBugs happy. > > Change it to String[]. We have some tests that modify the iconUrls to test > whether update is needed, how about not making it as final for now? If FindBugs doesn't complain, that's fine by me. I've recently sent a CL through with a array where it was unhappy at the modifiability is all. :) https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... File chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc (right): https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:195: std::vector<std::string> icon_urls; Can this just be: ScopedJavaLocalRef<jobjectArray> java_icon_urls = base::android::ToJavaArrayOfStrings(env, info.icon_urls); https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:155: if (icon_url.compare(shortcut_info.best_icon_url.spec()) == 0) Nit: use == https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... File chrome/browser/android/webapk/webapk_update_manager.cc (right): https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:92: base::android::JavaArrayOfByteArrayToStringVector( Can this just be base::android::JavaArrayOfByteArrayToStringVector(env, java_icon_urls.obj(), &info.icon_urls);
PTAL, thanks! https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java (right): https://codereview.chromium.org/2453423002/diff/400001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorFetcher.java:47: public Set<String> iconUrls; On 2016/11/17 21:16:43, dominickn wrote: > On 2016/11/17 20:42:38, Xi Han wrote: > > On 2016/11/17 18:50:53, dominickn wrote: > > > As pointed out above, this isn't being used in an equality comparison any > > more, > > > so it can just be a primitive array so you don't have the memory + > > construction > > > overhead of a set. You might need it to be final to make FindBugs happy. > > > > Change it to String[]. We have some tests that modify the iconUrls to test > > whether update is needed, how about not making it as final for now? > > If FindBugs doesn't complain, that's fine by me. I've recently sent a CL through > with a array where it was unhappy at the modifiability is all. :) Acknowledged. https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... File chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc (right): https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... chrome/browser/android/webapk/manifest_upgrade_detector_fetcher.cc:195: std::vector<std::string> icon_urls; On 2016/11/17 21:16:43, dominickn wrote: > Can this just be: > > ScopedJavaLocalRef<jobjectArray> java_icon_urls = > base::android::ToJavaArrayOfStrings(env, info.icon_urls); Good catch, thanks! https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... File chrome/browser/android/webapk/webapk_installer.cc (right): https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... chrome/browser/android/webapk/webapk_installer.cc:155: if (icon_url.compare(shortcut_info.best_icon_url.spec()) == 0) On 2016/11/17 21:16:43, dominickn wrote: > Nit: use == Done. https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... File chrome/browser/android/webapk/webapk_update_manager.cc (right): https://codereview.chromium.org/2453423002/diff/440001/chrome/browser/android... chrome/browser/android/webapk/webapk_update_manager.cc:92: base::android::JavaArrayOfByteArrayToStringVector( On 2016/11/17 21:16:43, dominickn wrote: > Can this just be > > base::android::JavaArrayOfByteArrayToStringVector(env, java_icon_urls.obj(), > &info.icon_urls); Done.
lgtm
On 2016/11/17 21:35:36, dominickn wrote: > lgtm Thanks for bearing with me!
The CQ bit was checked by hanxi@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pkotwicz@chromium.org Link to the patchset: https://codereview.chromium.org/2453423002/#ps460001 (title: "Nits.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by hanxi@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which use the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which use the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ==========
Message was sent while issue was closed.
Committed patchset #9 (id:460001)
Message was sent while issue was closed.
Description was changed from ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which use the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 ========== to ========== Send all of the icon URLs listed in Web Manifest to WebAPK Server. So far, Chrome only sends the best icon URL to WebAPK Minter Server to create/install WebAPKs. However, in the multiple icon world, it isn't correct to still keep the "best icon URL" and the "best icon hash" in AndroidManifest.xml. This is because the best icon URL will be different for devices with different resolution. For example, a nexus 5 and an Android one device will have different best icon URL. To prevent creating a WebAPK for a device with a wrong baked metadata, the "best icon URL" and "best Icon Hash" are removed from the metadata. Instead, all of the icon URLs, as well as all of the icon Hashs are baked in the AndroidManifest.xml. These icon URLs and Hashes are stored as a space separated single <meta-data> tag, as: "URL1 hash1 URL2 hash2 URL3 hash3..." Another change in this CL is to send all the icon URLs to the server, since the server wants to check if any of these icon URLs changed before starting a fetch of the raw icon data. Some behavior changes are involved: 1) For creating a WebAPK, Chrome sends all icon URLs + (the best icon URL + best icon hash + best icon raw image) to the Server. The reason to still send the best icon is for one-off WebAPKs which use the image from Chrome, since server will fail to fetch any of them. Server generates all the icon Hashs and bakes them in the WebAPK's metadata in AndroidManifest.xml. 2) When checking updates, Chrome compute the best icon URL and hash when fetching the Web Manifest, and compare the new computed hash with the one backed in the metadata to see whether the image is updated. The icon URL and icon Hash pairs are stored in a map in WebApkMetaData. BUG=627593 Committed: https://crrev.com/75ca9beb7e7fcd03feb23bb1e246be3ff5de6b6e Cr-Commit-Position: refs/heads/master@{#433215} ==========
Message was sent while issue was closed.
Patchset 9 (id:??) landed as https://crrev.com/75ca9beb7e7fcd03feb23bb1e246be3ff5de6b6e Cr-Commit-Position: refs/heads/master@{#433215} |
