| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 (downloadCount > 4) | |
| 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) + |
| 201 "&downloadCount=" + encodeURIComponent(downloadable.downloadCount); | 205 "&downloadCount=" + encodeURIComponent(downloadCount); |
| 202 return url; | 206 return url; |
| 203 }, | 207 }, |
| 204 | 208 |
| 205 _download: function(downloadable, redirects) | 209 _download: function(downloadable, redirects) |
| 206 { | 210 { |
| 207 if (this.isDownloading(downloadable.url)) | 211 if (this.isDownloading(downloadable.url)) |
| 208 return; | 212 return; |
| 209 | 213 |
| 210 let downloadUrl = this.getDownloadUrl(downloadable); | 214 let downloadUrl = this.getDownloadUrl(downloadable); |
| 211 let request = null; | 215 let request = null; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 | 289 |
| 286 delete this._downloading[downloadable.url]; | 290 delete this._downloading[downloadable.url]; |
| 287 | 291 |
| 288 // Status will be 0 for non-HTTP requests | 292 // Status will be 0 for non-HTTP requests |
| 289 if (request.status && request.status != 200) | 293 if (request.status && request.status != 200) |
| 290 { | 294 { |
| 291 errorCallback("synchronize_connection_error"); | 295 errorCallback("synchronize_connection_error"); |
| 292 return; | 296 return; |
| 293 } | 297 } |
| 294 | 298 |
| 295 // We limit the download count to 5+ to keep the request anonymized | 299 downloadable.downloadCount++; |
| 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 | 300 |
| 299 this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url) | 301 this.onDownloadSuccess(downloadable, request.responseText, errorCallback, function redirectCallback(url) |
| 300 { | 302 { |
| 301 if (redirects >= this.maxRedirects) | 303 if (redirects >= this.maxRedirects) |
| 302 errorCallback("synchronize_connection_error"); | 304 errorCallback("synchronize_connection_error"); |
| 303 else | 305 else |
| 304 { | 306 { |
| 305 downloadable.redirectURL = url; | 307 downloadable.redirectURL = url; |
| 306 this._download(downloadable, redirects + 1); | 308 this._download(downloadable, redirects + 1); |
| 307 } | 309 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 /** | 383 /** |
| 382 * Hard expiration interval, this is fixed. | 384 * Hard expiration interval, this is fixed. |
| 383 * @type Integer | 385 * @type Integer |
| 384 */ | 386 */ |
| 385 hardExpiration: 0, | 387 hardExpiration: 0, |
| 386 | 388 |
| 387 /** | 389 /** |
| 388 * Number indicating how often the object was downloaded. | 390 * Number indicating how often the object was downloaded. |
| 389 * @type Integer | 391 * @type Integer |
| 390 */ | 392 */ |
| 391 downloadCount: 1, | 393 downloadCount: 0, |
|
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.
| |
| 392 }; | 394 }; |
| LEFT | RIGHT |