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

Side by Side Diff: lib/downloader.js

Issue 6013081427640320: Issue 537 - Mark first few downloads (Closed)
Patch Set: Created Nov. 10, 2014, 5:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/notification.js » ('j') | lib/notification.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (url.indexOf("?") >= 0) 190 if (url.indexOf("?") >= 0)
191 url += "&"; 191 url += "&";
192 else 192 else
193 url += "?"; 193 url += "?";
194 url += "addonName=" + encodeURIComponent(addonName) + 194 url += "addonName=" + encodeURIComponent(addonName) +
195 "&addonVersion=" + encodeURIComponent(addonVersion) + 195 "&addonVersion=" + encodeURIComponent(addonVersion) +
196 "&application=" + encodeURIComponent(application) + 196 "&application=" + encodeURIComponent(application) +
197 "&applicationVersion=" + encodeURIComponent(applicationVersion) + 197 "&applicationVersion=" + encodeURIComponent(applicationVersion) +
198 "&platform=" + encodeURIComponent(platform) + 198 "&platform=" + encodeURIComponent(platform) +
199 "&platformVersion=" + encodeURIComponent(platformVersion) + 199 "&platformVersion=" + encodeURIComponent(platformVersion) +
200 "&lastVersion=" + encodeURIComponent(downloadable.lastVersion); 200 "&lastVersion=" + encodeURIComponent(downloadable.lastVersion) +
201 "&downloadCount=" + encodeURIComponent(downloadable.downloadCount);
201 return url; 202 return url;
202 }, 203 },
203 204
204 _download: function(downloadable, redirects) 205 _download: function(downloadable, redirects)
205 { 206 {
206 if (this.isDownloading(downloadable.url)) 207 if (this.isDownloading(downloadable.url))
207 return; 208 return;
208 209
209 let downloadUrl = this.getDownloadUrl(downloadable); 210 let downloadUrl = this.getDownloadUrl(downloadable);
210 let request = null; 211 let request = null;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 285
285 delete this._downloading[downloadable.url]; 286 delete this._downloading[downloadable.url];
286 287
287 // Status will be 0 for non-HTTP requests 288 // Status will be 0 for non-HTTP requests
288 if (request.status && request.status != 200) 289 if (request.status && request.status != 200)
289 { 290 {
290 errorCallback("synchronize_connection_error"); 291 errorCallback("synchronize_connection_error");
291 return; 292 return;
292 } 293 }
293 294
295 // We limit the download count to 5+ to keep the request anonymized
296 if (!isNaN(downloadable.downloadCount) && ++downloadable.downloadCount > 5 )
297 downloadable.downloadCount = "5+";
Wladimir Palant 2014/11/10 19:18:15 Storing numbers and strings in the same variable s
Thomas Greiner 2014/11/11 11:54:46 What I wanted to avoid is (a) stopping the counter
Wladimir Palant 2014/11/11 16:07:00 Yes, I was also considering whether (b) is a probl
Thomas Greiner 2014/11/11 17:17:18 Done.
298
294 this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url) 299 this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url)
295 { 300 {
296 if (redirects >= this.maxRedirects) 301 if (redirects >= this.maxRedirects)
297 errorCallback("synchronize_connection_error"); 302 errorCallback("synchronize_connection_error");
298 else 303 else
299 { 304 {
300 downloadable.redirectURL = url; 305 downloadable.redirectURL = url;
301 this._download(downloadable, redirects + 1); 306 this._download(downloadable, redirects + 1);
302 } 307 }
303 }.bind(this)); 308 }.bind(this));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 * while. 376 * while.
372 * @type Integer 377 * @type Integer
373 */ 378 */
374 softExpiration: 0, 379 softExpiration: 0,
375 380
376 /** 381 /**
377 * Hard expiration interval, this is fixed. 382 * Hard expiration interval, this is fixed.
378 * @type Integer 383 * @type Integer
379 */ 384 */
380 hardExpiration: 0, 385 hardExpiration: 0,
386
387 /**
388 * Number indicating how often the object was downloaded.
389 * @type Integer
390 */
391 downloadCount: 1,
Thomas Greiner 2014/11/10 18:14:55 This number is always one higher than the number o
Wladimir Palant 2014/11/10 19:18:15 Incrementing after success seems ok, but why not s
Thomas Greiner 2014/11/11 11:54:46 If this is set to 0 then the number we send is 0-b
Wladimir Palant 2014/11/11 16:07:00 I don't think we actually agreed on the exact mean
Thomas Greiner 2014/11/11 17:17:18 Done.
381 }; 392 };
OLDNEW
« no previous file with comments | « no previous file | lib/notification.js » ('j') | lib/notification.js » ('J')

Powered by Google App Engine
This is Rietveld