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

Side by Side Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AndroidWebRequest.java

Issue 29397615: Issue 5053 - Release JsValues explicitly (Closed)
Patch Set: Created March 29, 2017, 12:12 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
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 13 matching lines...) Expand all
24 import java.net.URL; 24 import java.net.URL;
25 import java.util.HashSet; 25 import java.util.HashSet;
26 import java.util.LinkedList; 26 import java.util.LinkedList;
27 import java.util.List; 27 import java.util.List;
28 import java.util.Map; 28 import java.util.Map;
29 import java.util.zip.GZIPInputStream; 29 import java.util.zip.GZIPInputStream;
30 30
31 import org.adblockplus.libadblockplus.AdblockPlusException; 31 import org.adblockplus.libadblockplus.AdblockPlusException;
32 import org.adblockplus.libadblockplus.FilterEngine; 32 import org.adblockplus.libadblockplus.FilterEngine;
33 import org.adblockplus.libadblockplus.HeaderEntry; 33 import org.adblockplus.libadblockplus.HeaderEntry;
34 import org.adblockplus.libadblockplus.JsValue;
34 import org.adblockplus.libadblockplus.ServerResponse; 35 import org.adblockplus.libadblockplus.ServerResponse;
35 import org.adblockplus.libadblockplus.ServerResponse.NsStatus; 36 import org.adblockplus.libadblockplus.ServerResponse.NsStatus;
36 import org.adblockplus.libadblockplus.WebRequest; 37 import org.adblockplus.libadblockplus.WebRequest;
37 38
38 import android.util.Log; 39 import android.util.Log;
39 40
40 public class AndroidWebRequest extends WebRequest 41 public class AndroidWebRequest extends WebRequest
41 { 42 {
42 protected static final String ENCODING_GZIP = "gzip"; 43 protected static final String ENCODING_GZIP = "gzip";
43 protected static final String ENCODING_IDENTITY = "identity"; 44 protected static final String ENCODING_IDENTITY = "identity";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 toCheck = toCheck.substring(0, idx); 77 toCheck = toCheck.substring(0, idx);
77 } 78 }
78 79
79 return this.subscriptionURLs.contains(toCheck); 80 return this.subscriptionURLs.contains(toCheck);
80 } 81 }
81 82
82 protected void updateSubscriptionURLs(final FilterEngine engine) 83 protected void updateSubscriptionURLs(final FilterEngine engine)
83 { 84 {
84 for (final org.adblockplus.libadblockplus.Subscription s : engine.fetchAvail ableSubscriptions()) 85 for (final org.adblockplus.libadblockplus.Subscription s : engine.fetchAvail ableSubscriptions())
85 { 86 {
86 this.subscriptionURLs.add(s.getProperty("url").toString()); 87 try
88 {
89 JsValue jsUrl = s.getProperty("url");
90 try
91 {
92 this.subscriptionURLs.add(jsUrl.toString());
93 }
94 finally
95 {
96 jsUrl.dispose();
97 }
98 }
99 finally
100 {
101 s.dispose();
102 }
87 } 103 }
88 this.subscriptionURLs.add(engine.getPref("subscriptions_exceptionsurl").toSt ring()); 104 JsValue jsPref = engine.getPref("subscriptions_exceptionsurl");
105 try
106 {
107 this.subscriptionURLs.add(jsPref.toString());
108 }
109 finally
110 {
111 jsPref.dispose();
112 }
89 } 113 }
90 114
91 @Override 115 @Override
92 public ServerResponse httpGET(final String urlStr, final List<HeaderEntry> hea ders) 116 public ServerResponse httpGET(final String urlStr, final List<HeaderEntry> hea ders)
93 { 117 {
94 try 118 try
95 { 119 {
96 final URL url = new URL(urlStr); 120 final URL url = new URL(urlStr);
97 Log.d(TAG, "Downloading from: " + url); 121 Log.d(TAG, "Downloading from: " + url);
98 122
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 Log.d(TAG, "Downloading finished"); 184 Log.d(TAG, "Downloading finished");
161 return response; 185 return response;
162 } 186 }
163 catch (final Throwable t) 187 catch (final Throwable t)
164 { 188 {
165 Log.e(TAG, "WebRequest failed", t); 189 Log.e(TAG, "WebRequest failed", t);
166 throw new AdblockPlusException("WebRequest failed", t); 190 throw new AdblockPlusException("WebRequest failed", t);
167 } 191 }
168 } 192 }
169 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld