Left: | ||
Right: |
OLD | NEW |
---|---|
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 * parameters. | 184 * parameters. |
185 */ | 185 */ |
186 getDownloadUrl: function(/**Downloadable*/ downloadable) /** String*/ | 186 getDownloadUrl: function(/**Downloadable*/ downloadable) /** String*/ |
187 { | 187 { |
188 let {addonName, addonVersion, application, applicationVersion, platform, pla tformVersion} = require("info"); | 188 let {addonName, addonVersion, application, applicationVersion, platform, pla tformVersion} = require("info"); |
189 let url = downloadable.redirectURL || downloadable.url; | 189 let url = downloadable.redirectURL || downloadable.url; |
190 if (url.indexOf("?") >= 0) | 190 if (url.indexOf("?") >= 0) |
191 url += "&"; | 191 url += "&"; |
192 else | 192 else |
193 url += "?"; | 193 url += "?"; |
194 // We limit the download count to 4+ to keep the request anonymized | |
195 let downloadCount = downloadable.downloadCount; | |
196 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.
| |
197 downloadCount = "4+"; | |
194 url += "addonName=" + encodeURIComponent(addonName) + | 198 url += "addonName=" + encodeURIComponent(addonName) + |
195 "&addonVersion=" + encodeURIComponent(addonVersion) + | 199 "&addonVersion=" + encodeURIComponent(addonVersion) + |
196 "&application=" + encodeURIComponent(application) + | 200 "&application=" + encodeURIComponent(application) + |
197 "&applicationVersion=" + encodeURIComponent(applicationVersion) + | 201 "&applicationVersion=" + encodeURIComponent(applicationVersion) + |
198 "&platform=" + encodeURIComponent(platform) + | 202 "&platform=" + encodeURIComponent(platform) + |
199 "&platformVersion=" + encodeURIComponent(platformVersion) + | 203 "&platformVersion=" + encodeURIComponent(platformVersion) + |
200 "&lastVersion=" + encodeURIComponent(downloadable.lastVersion); | 204 "&lastVersion=" + encodeURIComponent(downloadable.lastVersion) + |
205 "&downloadCount=" + encodeURIComponent(downloadCount); | |
201 return url; | 206 return url; |
202 }, | 207 }, |
203 | 208 |
204 _download: function(downloadable, redirects) | 209 _download: function(downloadable, redirects) |
205 { | 210 { |
206 if (this.isDownloading(downloadable.url)) | 211 if (this.isDownloading(downloadable.url)) |
207 return; | 212 return; |
208 | 213 |
209 let downloadUrl = this.getDownloadUrl(downloadable); | 214 let downloadUrl = this.getDownloadUrl(downloadable); |
210 let request = null; | 215 let request = null; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 289 |
285 delete this._downloading[downloadable.url]; | 290 delete this._downloading[downloadable.url]; |
286 | 291 |
287 // Status will be 0 for non-HTTP requests | 292 // Status will be 0 for non-HTTP requests |
288 if (request.status && request.status != 200) | 293 if (request.status && request.status != 200) |
289 { | 294 { |
290 errorCallback("synchronize_connection_error"); | 295 errorCallback("synchronize_connection_error"); |
291 return; | 296 return; |
292 } | 297 } |
293 | 298 |
299 downloadable.downloadCount++; | |
300 | |
294 this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url) | 301 this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url) |
295 { | 302 { |
296 if (redirects >= this.maxRedirects) | 303 if (redirects >= this.maxRedirects) |
297 errorCallback("synchronize_connection_error"); | 304 errorCallback("synchronize_connection_error"); |
298 else | 305 else |
299 { | 306 { |
300 downloadable.redirectURL = url; | 307 downloadable.redirectURL = url; |
301 this._download(downloadable, redirects + 1); | 308 this._download(downloadable, redirects + 1); |
302 } | 309 } |
303 }.bind(this)); | 310 }.bind(this)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 * while. | 378 * while. |
372 * @type Integer | 379 * @type Integer |
373 */ | 380 */ |
374 softExpiration: 0, | 381 softExpiration: 0, |
375 | 382 |
376 /** | 383 /** |
377 * Hard expiration interval, this is fixed. | 384 * Hard expiration interval, this is fixed. |
378 * @type Integer | 385 * @type Integer |
379 */ | 386 */ |
380 hardExpiration: 0, | 387 hardExpiration: 0, |
388 | |
389 /** | |
390 * Number indicating how often the object was downloaded. | |
391 * @type Integer | |
392 */ | |
393 downloadCount: 0, | |
381 }; | 394 }; |
OLD | NEW |