Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/downloader.js

Issue 6013081427640320: Issue 537 - Mark first few downloads (Closed)
Patch Set: Created Nov. 11, 2014, 5:14 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/notification.js » ('j') | lib/subscriptionClasses.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/downloader.js
===================================================================
--- a/lib/downloader.js
+++ b/lib/downloader.js
@@ -191,13 +191,18 @@
url += "&";
else
url += "?";
+ // We limit the download count to 4+ to keep the request anonymized
+ let downloadCount = downloadable.downloadCount;
+ if (downloadable.downloadCount > 4)
Wladimir Palant 2014/11/11 17:28:16 No need to reference downloadable again here, just
Thomas Greiner 2014/11/11 17:53:18 Sorry, I missed that. Done.
+ downloadCount = "4+";
url += "addonName=" + encodeURIComponent(addonName) +
"&addonVersion=" + encodeURIComponent(addonVersion) +
"&application=" + encodeURIComponent(application) +
"&applicationVersion=" + encodeURIComponent(applicationVersion) +
"&platform=" + encodeURIComponent(platform) +
"&platformVersion=" + encodeURIComponent(platformVersion) +
- "&lastVersion=" + encodeURIComponent(downloadable.lastVersion);
+ "&lastVersion=" + encodeURIComponent(downloadable.lastVersion) +
+ "&downloadCount=" + encodeURIComponent(downloadCount);
return url;
},
@@ -291,6 +296,8 @@
return;
}
+ downloadable.downloadCount++;
+
this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url)
{
if (redirects >= this.maxRedirects)
@@ -378,4 +385,10 @@
* @type Integer
*/
hardExpiration: 0,
+
+ /**
+ * Number indicating how often the object was downloaded.
+ * @type Integer
+ */
+ downloadCount: 0,
};
« no previous file with comments | « no previous file | lib/notification.js » ('j') | lib/subscriptionClasses.js » ('J')

Powered by Google App Engine
This is Rietveld