Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 connection.getInputStream(), StandardCharsets.UTF_8))) | 102 connection.getInputStream(), StandardCharsets.UTF_8))) |
103 { | 103 { |
104 for (int ch = r.read(); ch != -1; ch = r.read()) | 104 for (int ch = r.read(); ch != -1; ch = r.read()) |
105 { | 105 { |
106 sb.append((char) ch); | 106 sb.append((char) ch); |
107 } | 107 } |
108 job.responseText = sb.toString(); | 108 job.responseText = sb.toString(); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 public void enqueueDownload(final URL url, final String id, final Map<String, String> headers, final boolean allowMetered) | 112 public void enqueueDownload(final URL url, final String id, final Map<String, String> headers, |
anton
2018/01/19 10:53:02
the line seems to be too long
jens
2018/01/19 11:00:47
Acknowledged.
| |
113 final boolean allowMetered) | |
113 { | 114 { |
114 this.lock(); | 115 this.lock(); |
115 try | 116 try |
116 { | 117 { |
117 if (!this.enqueuedIds.contains(id)) | 118 if (!this.enqueuedIds.contains(id)) |
118 { | 119 { |
119 this.enqueuedIds.add(id); | 120 this.enqueuedIds.add(id); |
120 this.downloadJobs.add(new DownloadJob(url, id, headers, allowMetered)); | 121 this.downloadJobs.add(new DownloadJob(url, id, headers, allowMetered)); |
121 } | 122 } |
122 } | 123 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 try | 161 try |
161 { | 162 { |
162 if (!this.downloader.downloaderEnabled) | 163 if (!this.downloader.downloaderEnabled) |
163 { | 164 { |
164 Thread.sleep(30000); | 165 Thread.sleep(30000); |
165 continue; | 166 continue; |
166 } | 167 } |
167 job = this.downloader.downloadJobs.poll(5 * 60, TimeUnit.SECONDS); | 168 job = this.downloader.downloadJobs.poll(5 * 60, TimeUnit.SECONDS); |
168 if (job != null) | 169 if (job != null) |
169 { | 170 { |
170 if (this.downloader.engine.canUseInternet() || job.allowMetered) | 171 if (this.downloader.engine.canUseInternet(job.allowMetered)) |
171 { | 172 { |
172 Log.d(TAG, "Downloading '" + job.id + "' using " + job.url); | 173 Log.d(TAG, "Downloading '" + job.id + "' using " + job.url); |
173 download(job); | 174 download(job); |
174 Log.d(TAG, "Downloading '" + job.id + "' finished with response co de " | 175 Log.d(TAG, "Downloading '" + job.id + "' finished with response co de " |
175 + job.responseCode); | 176 + job.responseCode); |
176 this.downloader.lock(); | 177 this.downloader.lock(); |
177 try | 178 try |
178 { | 179 { |
179 this.downloader.enqueuedIds.remove(job.id); | 180 this.downloader.enqueuedIds.remove(job.id); |
180 } | 181 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 this.url = url; | 255 this.url = url; |
255 this.id = id; | 256 this.id = id; |
256 this.allowMetered = allowMetered; | 257 this.allowMetered = allowMetered; |
257 if (headers != null) | 258 if (headers != null) |
258 { | 259 { |
259 this.headers.putAll(headers); | 260 this.headers.putAll(headers); |
260 } | 261 } |
261 } | 262 } |
262 } | 263 } |
263 } | 264 } |
LEFT | RIGHT |