Markers: add info about type of delta client

Summary: Adds information which type of delta client is used (if at all) to the `BundleInfo` object.

Reviewed By: fromcelticpark

Differential Revision: D7845139

fbshipit-source-id: e4bf6cda62c71a78aaff97aa69daec263e6d3cdf
This commit is contained in:
David Aurelio 2018-05-03 08:38:15 -07:00 committed by Facebook Github Bot
parent dd036c2328
commit 786c1ecc2a
1 changed files with 10 additions and 2 deletions

View File

@ -47,6 +47,7 @@ public class BundleDownloader {
private @Nullable Call mDownloadBundleFromURLCall; private @Nullable Call mDownloadBundleFromURLCall;
public static class BundleInfo { public static class BundleInfo {
private @Nullable String mDeltaClientName;
private @Nullable String mUrl; private @Nullable String mUrl;
private int mFilesChangedCount; private int mFilesChangedCount;
@ -59,6 +60,7 @@ public class BundleDownloader {
try { try {
JSONObject obj = new JSONObject(jsonStr); JSONObject obj = new JSONObject(jsonStr);
info.mDeltaClientName = obj.getString("deltaClient");
info.mUrl = obj.getString("url"); info.mUrl = obj.getString("url");
info.mFilesChangedCount = obj.getInt("filesChangedCount"); info.mFilesChangedCount = obj.getInt("filesChangedCount");
} catch (JSONException e) { } catch (JSONException e) {
@ -73,6 +75,7 @@ public class BundleDownloader {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
try { try {
obj.put("deltaClient", mDeltaClientName);
obj.put("url", mUrl); obj.put("url", mUrl);
obj.put("filesChangedCount", mFilesChangedCount); obj.put("filesChangedCount", mFilesChangedCount);
} catch (JSONException e) { } catch (JSONException e) {
@ -83,6 +86,10 @@ public class BundleDownloader {
return obj.toString(); return obj.toString();
} }
public @Nullable String getDeltaClient() {
return mDeltaClientName;
}
public String getUrl() { public String getUrl() {
return mUrl != null ? mUrl : "unknown"; return mUrl != null ? mUrl : "unknown";
} }
@ -281,7 +288,7 @@ public class BundleDownloader {
} }
if (bundleInfo != null) { if (bundleInfo != null) {
populateBundleInfo(url, headers, bundleInfo); populateBundleInfo(url, headers, clientType, bundleInfo);
} }
File tmpFile = new File(outputFile.getPath() + ".tmp"); File tmpFile = new File(outputFile.getPath() + ".tmp");
@ -333,7 +340,8 @@ public class BundleDownloader {
return true; return true;
} }
private static void populateBundleInfo(String url, Headers headers, BundleInfo bundleInfo) { private static void populateBundleInfo(String url, Headers headers, BundleDeltaClient.ClientType clientType, BundleInfo bundleInfo) {
bundleInfo.mDeltaClientName = clientType == BundleDeltaClient.ClientType.NONE ? null : clientType.name();
bundleInfo.mUrl = url; bundleInfo.mUrl = url;
String filesChangedCountStr = headers.get("X-Metro-Files-Changed-Count"); String filesChangedCountStr = headers.get("X-Metro-Files-Changed-Count");