mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1300543 - IconDownloader: Use final keyword where appropriate. r=ahunt
MozReview-Commit-ID: DhWIRPZf7rg --HG-- extra : rebase_source : 797987c944e445a4ea7e00a2373c83c2003c0c1a
This commit is contained in:
parent
58d250abaa
commit
a5a657d556
@ -56,7 +56,7 @@ public class IconDownloader implements IconLoader {
|
||||
}
|
||||
|
||||
try {
|
||||
LoadFaviconResult result = downloadAndDecodeImage(request.getContext(), iconUrl);
|
||||
final LoadFaviconResult result = downloadAndDecodeImage(request.getContext(), iconUrl);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class IconDownloader implements IconLoader {
|
||||
@VisibleForTesting
|
||||
LoadFaviconResult downloadAndDecodeImage(Context context, String targetFaviconURL) throws IOException, URISyntaxException {
|
||||
// Try the URL we were given.
|
||||
HttpURLConnection connection = tryDownload(targetFaviconURL);
|
||||
final HttpURLConnection connection = tryDownload(targetFaviconURL);
|
||||
if (connection == null) {
|
||||
return null;
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class IconDownloader implements IconLoader {
|
||||
* @return The HttpResponse containing the downloaded Favicon if successful, null otherwise.
|
||||
*/
|
||||
private HttpURLConnection tryDownload(String faviconURI) throws URISyntaxException, IOException {
|
||||
HashSet<String> visitedLinkSet = new HashSet<>();
|
||||
final HashSet<String> visitedLinkSet = new HashSet<>();
|
||||
visitedLinkSet.add(faviconURI);
|
||||
return tryDownloadRecurse(faviconURI, visitedLinkSet);
|
||||
}
|
||||
@ -128,10 +128,10 @@ public class IconDownloader implements IconLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
HttpURLConnection connection = connectTo(faviconURI);
|
||||
final HttpURLConnection connection = connectTo(faviconURI);
|
||||
|
||||
// Was the response a failure?
|
||||
int status = connection.getResponseCode();
|
||||
final int status = connection.getResponseCode();
|
||||
|
||||
// Handle HTTP status codes requesting a redirect.
|
||||
if (status >= 300 && status < 400) {
|
||||
@ -169,7 +169,7 @@ public class IconDownloader implements IconLoader {
|
||||
|
||||
@VisibleForTesting
|
||||
HttpURLConnection connectTo(String faviconURI) throws URISyntaxException, IOException {
|
||||
HttpURLConnection connection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(
|
||||
final HttpURLConnection connection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(
|
||||
new URI(faviconURI));
|
||||
|
||||
connection.setRequestProperty("User-Agent", GeckoAppShell.getGeckoInterface().getDefaultUAString());
|
||||
@ -197,7 +197,7 @@ public class IconDownloader implements IconLoader {
|
||||
*/
|
||||
private LoadFaviconResult decodeImageFromResponse(Context context, InputStream stream, int contentLength) throws IOException {
|
||||
// This may not be provided, but if it is, it's useful.
|
||||
int bufferSize;
|
||||
final int bufferSize;
|
||||
if (contentLength > 0) {
|
||||
// The size was reported and sane, so let's use that.
|
||||
// Integer overflow should not be a problem for Favicon sizes...
|
||||
@ -208,7 +208,7 @@ public class IconDownloader implements IconLoader {
|
||||
}
|
||||
|
||||
// Read the InputStream into a byte[].
|
||||
IOUtils.ConsumedInputStream result = IOUtils.readFully(stream, bufferSize);
|
||||
final IOUtils.ConsumedInputStream result = IOUtils.readFully(stream, bufferSize);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user